What is the difference between a class and an object?
A class defines shared structure and behavior; an object is a particular class instance with its own state.
Study 8 Object-Oriented Design with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is the difference between a class and an object?
A class defines shared structure and behavior; an object is a particular class instance with its own state.
What does encapsulation protect?
Encapsulation combines data with governing operations, restricts direct access to representation, and protects invariants through a meaningful public interface.
When is inheritance appropriate?
Inheritance is appropriate when a subtype genuinely satisfies the behavioral contract of its supertype; otherwise, its coupling and rigidity can outweigh reuse.
How does polymorphism reduce conditional logic?
Polymorphism lets code use an abstraction while the concrete object selects the implementation, reducing conditional logic and easing the addition of new implementations.
What does an interface specify?
An interface specifies a contract of operations without requiring a particular implementation, allowing different classes to provide the same capability independently.
What is composition in object-oriented design?
Composition builds a class from references to other objects, allowing behavior to be replaced at runtime and making testing with substitute objects easier.
What is the information expert guideline?
The information expert guideline assigns behavior to the object that has the information needed to perform it. For example, an Order should usually calculate its own total.
What is pure fabrication?
Pure fabrication creates a focused service that is not a domain entity when doing so improves cohesion and reduces coupling, such as an InvoicePrinter.
What does high cohesion indicate?
Cohesion measures how closely a module’s responsibilities belong together. High cohesion gives a class a focused purpose and makes it easier to understand, test, reuse, and change.
Why should coupling be limited?
Coupling measures how strongly modules depend on one another. Low, intentional coupling limits ripple effects by using stable abstractions, necessary information, and hidden implementation details.
What does the Single Responsibility Principle require?
The Single Responsibility Principle says a class should have one coherent responsibility and one primary reason to change; it does not require the class to contain only one method.
What is the Open–Closed Principle?
The Open–Closed Principle says software entities should be open for extension but closed for modification, often by placing variation behind an abstraction such as ShippingStrategy.