6.5. Language-Specific Issues

 < Free Open Study > 

Approaches to classes in different programming languages vary in interesting ways. Consider how you override a member routine to achieve polymorphism in a derived class. In Java, all routines are overridable by default and a routine must be declared final to prevent a derived class from overriding it. In C++, routines are not overridable by default. A routine must be declared virtual in the base class to be overridable. In Visual Basic, a routine must be declared overridable in the base class and the derived class should use the overrides keyword.

Here are some of the class-related areas that vary significantly depending on the language:

  • Behavior of overridden constructors and destructors in an inheritance tree

  • Behavior of constructors and destructors under exception-handling conditions

  • Importance of default constructors (constructors with no arguments)

  • Time at which a destructor or finalizer is called

  • Wisdom of overriding the language's built-in operators, including assignment and equality

  • How memory is handled as objects are created and destroyed or as they are declared and go out of scope

Detailed discussions of these issues are beyond the scope of this book, but the "Additional Resources" section points to good language-specific resources.

 < Free Open Study > 


Code Complete
Code Complete: A Practical Handbook of Software Construction, Second Edition
ISBN: 0735619670
EAN: 2147483647
Year: 2003
Pages: 334

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net