SOFTWARE DESIGN
DESIGN PATTERNS
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Use abstract classes to implement what varies.
|
|
Put what varies and what stays the same together. Do ti so that starting with an abstract class, all other classes inherit in a clever way.
|
|
Program to an interface, not an implementation.
|
|
The number of classes should be identical with the number of interfaces.
|
Detailed explanation-1: -It means that you should try to write your code so it uses an abstraction (abstract class or interface) instead of the implementation directly. Normally the implementation is injected into your code through the constructor or a method call.
Detailed explanation-2: -"Programming to an interface” means, that when possible, one should refer to a more abstract level of a class (an interface, abstract class, or sometimes a superclass of some sort), instead of refering to a concrete implementation.
Detailed explanation-3: -In discussing data structures, it is important to understand the difference between a data structure’s interface and its implementation. An interface describes what a data structure does, while an implementation describes how the data structure does it.