6.4 Class hierarchies

Class hierarchies

Creating proper class hierarchies is both a science and an art there is no easy recipe. People say a good portion of it is experience. I'm sure this doesn't sound very good to you. After all, you bought this book to learn these kind of things rather than going through the painful process of gaining experience. Fortunately, some basic rules and good habits can provide at least a starting point.

First, make sure you create your own set of base classes and derive all your own classes from them. Try to categorize your classes. For instance, create a DialogForm class and a DocumentForm class that are subclasses of your own form class. This way you can build a simple class hierarchy that will provide some flexibility. Once you become more experienced, you can go back and change a couple of things, which shouldn't be too hard if you followed these basic rules.

Don't be afraid to redesign! Every software project will go through a certain amount of redesign and rewriting. That's fine! Analyze your classes on a regular basis. Check for methods and properties you create. You might find that a lot of classes you derived from one parent class have the same newly defined method or property, in which case it's time to move the class to the parent class rather than defining it separately in every subclass. You might discover classes that have a lot of similarities but that are in different inheritance branches. In this case it might be time to redesign the class hierarchy. This can be a lot of work, but usually it's worth doing.



Advanced Object Oriented Programming with Visual FoxPro 6. 0
Advanced Object Oriented Programming with Visual FoxPro 6.0
ISBN: 0965509389
EAN: 2147483647
Year: 1998
Pages: 113
Authors: Markus Egger

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