The busy Java developer's guide to Scala: Implementation inheritance

摘自: IBM developerWorks Worldwide  被阅读次数: 132


yangyi 于 2008-09-13 23:47:46 提供


Level: Intermediate

Ted Neward (ted@tedneward.com), Principal, Neward & Associates

28 May 2008

Scala gives you just as much support for implementation inheritance as the Java™ language does — but Scala's inheritance yields a few surprises. This month, Ted Neward introduces you to polymorphism done the Scala way, blending functional and object-oriented language styles while still mapping perfectly to the Java platform's inheritance model.

For the better part of 20 years, a staple of object-oriented language design has been the notion of inheritance. Languages that do not support inheritance, such as Visual Basic, are derided for being "toy languages," unsuited to real work. Meanwhile, languages that do support inheritance do so differently, leading to many hours of debate. Is multiple inheritance really necessary (as the maker of C++ decided), or is it gratuitous and ugly (as determined by the makers of C# and the Java language)? Ruby and Scala are two newer languages that have taken the middle course on multiple inheritance — as I discussed last month when introducing Scala's traits (see Resources).

About this series

Ted Neward dives into the Scala programming language and takes you along with him. In this new developerWorks series, you'll learn what all the recent hype is about and see some of Scala's linguistic capabilities in action. Scala code and Java code will be shown side by side wherever comparison is relevant, but (as you'll discover) many things in Scala have no direct correlation to anything you've found in Java — and therein lies much of Scala's charm! After all, if Java could do it, why bother learning Scala?

......

Please access the below link to view the full content.

Original link: http://www.ibm.com/developerwork...