What does object-oriented design organize a system around?
Object-oriented design organizes a system around objects, their responsibilities, and their collaborations. The goal is a system that is understandable, changeable, and testable.
Study 9 Designing Object-Oriented Systems with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What does object-oriented design organize a system around?
Object-oriented design organizes a system around objects, their responsibilities, and their collaborations. The goal is a system that is understandable, changeable, and testable.
What is the difference between a class and an object?
A class is a blueprint that defines data and operations for a kind of object. An object is a particular runtime instance with its own identity and state.
What is encapsulation?
Encapsulation combines state and behavior while controlling access to implementation details. It lets an object protect its invariants through meaningful operations.
What is an invariant in object-oriented design?
An invariant is a condition that must remain true for an object. Encapsulation protects it by preventing invalid state through ordinary operations.
How should a responsibility be assigned to an object?
Assign a responsibility to the object that has the needed information or should protect the related rule. This keeps behavior near relevant data and rules.
What does high cohesion mean?
High cohesion means an object’s responsibilities support one clear purpose. It makes classes easier to understand, maintain, and test.
What does an interface define?
An interface is a contract: a set of operations that an implementing class promises to provide, without specifying its implementation.
Why should interfaces be focused?
Interfaces should contain related operations that implementers actually need. Several small, coherent interfaces are usually easier to understand than one broad interface.
When is inheritance appropriate?
Inheritance is appropriate when a derived type is genuinely a kind of the base type and can honor its expectations. It should not be used only to reuse a few lines of code.
What is substitutability in inheritance?
A subtype is substitutable when code expecting the base type can safely use every proposed subtype without special-case checks.
What does polymorphism allow?
Polymorphism lets code use an abstraction while the actual object supplies the appropriate behavior at runtime. One contract can therefore support multiple implementations.
What relationship does composition express?
Composition builds an object from other objects it contains or uses. It expresses a “has-a” or “uses-a” relationship and often allows components to be replaced independently.