I dont have enough of a grip on OO design to determine whether I am designing application well or not.
Here is a simple Idea:
I want to code a application for travelling on Metro.
I started of definining the following:
Trainline Interface which defines some methods. Then I create a concrete class called Lines. Lines class does nothing much at all. It has methods like getNumberOfStations() but it has no idea about any number of stations so just returns null.
Then I have a CentralLine class which does the real work and this extends Lines and this provides the real implementation.

Questions:
- Do I need "Lines" concrete class ? Should I just not have CentralLine and CircleLine implement TrainLines (these are both train lines on the London underground)?
- Or should I remove TrainLines interface and just have the Lines concrete class ?
- Or should TrainLines be an abstract class ?
- Does the interface or the Lines superclass provide any value at all apart from a pretty class map diagram ... see above :)
- What things can OO do for me that would be cool ? What things should I be looking to do with OO design ?
Thanks !!!!
Why not making your
Linesclassabstract? you would not have the problem of "returning null" => very very ugly.In this case, you would not have
TrainLinesinterface anymore.TrainLinesInterface would be interesting if you plan to deal with many different kind ofLineswhose implementation really differ. You would benefit thus with a great polymorphism by referencing your different classes in your code withTrainLinestype.To sum up, both solutions:
Linesas abstract class follows by concrete classes.TrainLinesas interface follows byLines(or other types) as abstract class follows by concrete classes.Keep in mind that abstract class implementing an interface doesn't need to implement the methods. Indeed, abstract class could defer this responsibility to concrete class. Thus, no need to implement dummy
return null;)