Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Object-oriented programming (OOP) is a programming paradigm that uses objects to represent data and behavior. Objects are self-contained units of code that can be used to create complex programs. OOP is based on the following four concepts:

  • Encapsulation - Encapsulation is the process of wrapping data and behavior together into a single unit. This makes the data and behavior of an object private, and it prevents other objects from accessing them directly.

  • Inheritance - Inheritance is the ability of one object to inherit the properties and behavior of another object. This allows developers to reuse code and create more complex objects more quickly.

  • Polymorphism - Polymorphism is the ability of an object to respond to a message in different ways, depending on its type. This allows developers to create more general-purpose code that can be used with different types of objects.

  • Abstraction - Abstraction is the process of hiding the implementation details of an object from other objects. This makes the object easier to use and understand, and it allows developers to focus on the object's functionality rather than its implementationClasses: Think of a class as a blueprint for creating objects. A class defines the properties (data fields) and behaviors (methods) that the objects created from it will have.

  • Objects: These are instances of classes. An object in OOP is a self-contained component that consists of methods and properties to make a particular type of data useful. Object properties can include things like color, size, text, or numbers.

  • Aggregation: This is a particular type of association in which objects are assembled or configured together to create a new object. It's often referred to as a "has-a" relationship, where one object is a part of another object.

  • Encapsulation: This is the practice of keeping the fields (data) in a class private and then providing public methods (getters and setters) to access and modify them. It's a protective barrier that keeps the data and code safe within the object and prevents unauthorized access.

  • Inheritance: This is a mechanism where a new class is derived from an existing class. The new class, known as a subclass, inherits the attributes and methods of the parent class. It allows for reusability of code and can be thought of as a "is-a" relationship.

  • Polymorphism: This concept allows objects of different classes to be treated as objects of a common superclass. It's the ability of different classes to respond to the same method call in different ways.

  • Interfaces: An interface in OOP is a completely "abstract class" that is used to group related methods with empty bodies. Implementing an interface allows a class to become more formal about the behavior it promises to provide.

  • Abstraction: This is the concept of hiding the complex reality while exposing only the necessary parts. It's a way of creating a simple model of a more complex underlying entity, which includes only the details that are relevant to the current perspective.

  • Object Design: This is a phase in the software development process that involves planning the structure and relationships between different objects in a system. It's where the conceptual model is translated into actual code.

OOP has several advantages over structured programming, including:

...

  • (CO-9) Develop well-documented programs using best practices

  • (CO-10) Create classes incorporating object-oriented techniques

  • (CO-11) Use data abstraction, polymorphism, inheritance, and interfaces.

  • (CO-12) Apply Object Design PatternsĀ 

...