Object-Oriented Design

Understanding Object-Oriented Design

  • Object-Oriented Design (OOD) in software development aims at organising software system architecture around objects and data rather than actions and logic.

  • This approach models real-world things as objects with states (attributes) and behaviours (methods).

  • OOD is rooted in four major principles: Encapsulation, Inheritance, Polymorphism, and Abstraction.

Encapsulation

  • Encapsulation is about hiding the inner workings (implementation details) of an object and exposing only what is necessary.

  • Keeps data safe from outside interference and misuse.

  • Achieved by using ‘private’ to restrict access to methods and variables.

Inheritance

  • Inheritance allows a new class to acquire properties and methods of an existing class.

  • Promotes code reuse and is a key way to expedite software development.

  • The class that is inherited is the ‘Superclass’, and the class that inherits is the ‘Subclass’.

Polymorphism

  • Polymorphism refers to the ability of one interface to be used for a general class of actions.

  • Helps prevent long and complex code using ‘if’ or ‘case’ statements by utilising overridden methods.

  • Facilitates flexibility while enforcing consistency in syntax.

Abstraction

  • Abstraction helps to manage complexity by handling objects in a way that separates their general qualities from the specific details.

  • Grants the ability to work at higher levels of complexity which encourages the use of several layers of abstraction.

Understanding UML (Unified Modelling Language)

  • UML is a standardised modelling language which includes a set of graphic notation techniques to create visual models of object-oriented software systems.

  • Key elements often include use case diagrams, class diagrams, object diagrams, behavioural diagrams and so on.

Advantages of Object-Oriented Design

  • Closer to human thinking and real world problems, therefore, easier to understand and design.

  • Enhances modularity by encapsulation, which allows object data and functions to be treated as a single entity.

  • Easier debugging and testing due to dividing objects with distinct behaviour, data, and functions.

  • Enhances code reusability through inheritance and polymorphism.

Challenges of Object-Oriented Design

  • Can be considered complicated or unnecessary for simple, straightforward programmes.

  • Performance could suffer due its features like encapsulation and abstraction.

  • Requires careful planning and a clear understanding of the principles of object-oriented design, unlike procedural programming that could be more flexible.