222.4 Notes on OOP design decisions

This section reflects on key object-oriented programming principles used in the Task Tracker app design, including abstraction, encapsulation, cohesion, and separation of concerns.

Abstraction

Abstraction involves identifying the essential features of an object while ignoring unimportant details. In this design, the Task class abstracts the concept of a task into attributes like title, description, due date, and status. Unnecessary complexities (such as visual formatting or file storage) are kept separate from the object’s core purpose.

Encapsulation

Encapsulation is the bundling of data and methods that operate on that data within a single unit. Both Task and TaskManager encapsulate their own data and behaviour. The internal state of a task (e.g. whether it is complete) can only be changed by calling specific methods like mark_complete() or mark_incomplete(), not by accessing attributes directly from outside the class.

Cohesion

Cohesion refers to how closely related and focused the responsibilities of a single class are. Each class in the Task Tracker app is highly cohesive:

  • The Task class is only responsible for managing its own state and displaying its own data.

  • The TaskManager is only responsible for managing the collection of tasks and coordinating actions across them.

High cohesion makes each class easier to test, debug, and extend.

Separation of concerns

Separation of concerns ensures that different parts of the system have clearly defined roles. The app design separates:

  • Task data (handled by Task)

  • Task management (handled by TaskManager)

  • User interaction (to be added in the main program logic)

This structure avoids mixing unrelated responsibilities and allows for flexible changes in future sprints.

Extensibility

This design can easily be extended in later modules. For example:

  • New attributes like priority or category can be added to the Task class

  • Methods like sort_by_due_date() or filter_by_category() can be added to TaskManager

  • Persistence features like saving to a file can be introduced without disrupting existing logic

These changes can be added incrementally by modifying one class at a time.

Last updated

Was this helpful?