You'll probably hear a few of these rules during your programming sessions (They are probably either not accurate enough, or they are completely false in every way):
- If you're seeing common code structures, they are to be restructured into a method. If you're seeing common methods, they are to be restructured into a method placed in a superclass or something static.
- If you're seeing objects with a common ancestor (or there appears to have an is-a relationship), they are to be restructured into an abstract class.
- If you're seeing common methods declared in a few classes in general, those methods are to be restructured into interfaces.
What is in your mind telling you and your guts that you should start using the rules mentioned (if any of them are correct)? And what makes you want to segregate parts of certain abstract classes into interfaces that follows the rules (if any are correct)? And while expanding objects (by adding more code to a regular class), when should you trust your instincts that you need to split them into either abstract classes, abstract methods, interfaces, or make them a subclass of another class?
To me, learning and understanding this will allow me to plan ahead in the very-near future of a simple concept of idea implementation in mind.
For example, a flexible bicycle. To make it flexible, I could start off with different interfaces. Then, I could create an abstract class, Bicycle, that implements all of the methods I will 100% use from the interfaces I will also 100% use. Finally, I could extend from the abstract class, and create a few more objects with a common design. Because I start off from creating Interfaces -> Abstract Class -> Subclass of the abstract class, my program design is crisp and clear. If I start off from creating a class, I might end up tiring myself in the future if I were to add a few more similar objects with similar methods.