Modular and Object-Oriented Design

  1. Classes, Instances, and Attributes

    A class describes how its instances are constructed and what operations they support. Each instance can hold its own state.

    Undergraduate
  2. Methods and the Object They Operate On

    An instance method receives the instance as part of a normal bound call. Its body can read or modify state belonging to that instance.

    Undergraduate
  3. Instance Attributes and Shared Class Attributes

    An instance attribute supplies one object's value. Access may fall back to a class attribute when the particular attribute lookup rules allow it.

    Undergraduate
  4. Constructing an Object in a Valid State

    A constructor can establish the properties other methods assume, so callers receive an object ready to use under its contract.

    Undergraduate
  5. An Object's Representation Invariant

    A representation invariant is an internal property that the object's creation and supported operations keep true.

    Undergraduate
  6. Encapsulation Through Operations

    Encapsulation gives callers operations with a declared meaning while allowing the object's representation to evolve.

    Undergraduate
  7. Composing Objects with Separate Roles

    Object composition supplies one object with collaborators handling responsibilities that can be described independently.

    Undergraduate
  8. Inheritance and Behavioral Contracts

    A subtype used through a common interface should satisfy the behavior that interface promises for supported calls.

    Undergraduate
  9. Method Overrides and Dynamic Dispatch

    A call through an object may select an overriding implementation according to the object's runtime type and language rules.

    Undergraduate
  10. An Interface Defined by Supported Operations

    Some interfaces describe the operations an object supports without requiring a shared named base class.

    Undergraduate
  11. A Named Constructor as a Class Method

    A class method can provide a meaningful alternate way to build an object while receiving the class used in the call.

    Undergraduate
  12. Choosing Fields for Object Equality

    A value object can define equality using the fields representing its meaning. Identity remains relevant when it represents a particular persistent entity.

    Undergraduate
  13. A Value Object for Durations

    A value object can pair a representation with construction and arithmetic rules that preserve the meaning of a duration.

    Undergraduate
  14. Entity Identity Across Object Edits

    An entity can retain its identity when mutable fields change. The chosen key and the latest snapshot describe different facts about it.

    Undergraduate
  15. A Module's Public Import Surface

    A module's public surface consists of names and behavior other modules are expected to import and rely on.

    Undergraduate
  16. Module State and Passed Configuration

    A module can hold shared values. Passing configuration explicitly provides a separate way to control which values a call observes.

    Undergraduate
  17. Module Dependencies and Import Cycles

    A module dependency graph shows which definitions are needed by others. Cyclic initialization can leave some definitions unavailable when they are first requested.

    Undergraduate
  18. Adapting an Existing Object to Another Interface

    An adapter translates how a component is called or what it returns, while preserving the meaning the receiving interface requires.

    Undergraduate
  19. Composing Small Validators

    Validators can check different conditions on one input and combine results under a rule for error collection or early exit.

    Undergraduate
  20. Selecting a Replaceable Algorithm

    A replaceable strategy gives several implementations the same role under one documented interface.

    Undergraduate
  21. Separating Input Acquisition and Parsing

    A parser uses supplied bytes or text to recover values. A separate reader can decide where the input comes from and when resources close.

    Undergraduate
  22. Returning an Independent Collection from an Object

    An object can protect writable internal state by returning a separate collection or an immutable view with a specified lifetime.

    Undergraduate
  23. Domain Errors and Infrastructure Errors

    A domain error explains why an operation is invalid under its rules. An infrastructure failure explains why the operation could not be completed or confirmed.

    Undergraduate
  24. Delegating Part of an Object's Work

    Delegation lets an object use a collaborator to perform a defined operation while keeping responsibility for the surrounding behavior.

    Undergraduate
  25. Configurable Objects with Explicit Defaults

    A configurable object can construct valid settings by applying documented defaults only when the caller leaves those settings unspecified.

    Undergraduate
  26. The Expected Call Sequence of an Interface

    An interface can specify which operations are allowed in each state, such as open before read and close after use.

    Undergraduate
  27. Separating a Computation from Presentation

    A computation can expose results as stable values so presentation can format those values for different readers.

    Undergraduate
  28. Explicit Dependencies for a Small Module

    A module becomes easier to test when operations that read outside state are selected at its entry boundary and passed where needed.

    Undergraduate
  29. A Focused Interface for Data Exchange

    A small public interface can define what import or export means while several private steps handle formats, conversions, and storage.

    Undergraduate
  30. Replacing an Implementation Behind an Interface

    An implementation can change independently when the stable inputs, outputs, failure outcomes, and observable effects of its interface survive.

    Undergraduate