Lesson 1 Flashcards
A programming approach that organizes code around objects (things with data and behavior) instead of focusing on just functions and logic.
Object-Oriented Programming (OOP)
Great for large, complex programs that need to be regularly updated or maintained, like simulations, design software, and mobile apps.
OOP is best suited for large, complex, and actively updated programs.
Benefits of Object-Oriented Programming
- Code Reusability: Reuse parts of code in different projects.
- Scalability: Easily add features as your project grows.
- Efficiency: Organizes code for faster development and debugging.
- Collaborative Development: Makes teamwork easier by dividing projects into smaller tasks.
Is like a blueprint for creating objects. It defines what attributes (data) and methods (functions) an object will have.
A class defines the blueprint for objects, their attributes, and methods.
Is a specific instance created from a class. It has its own data and can perform actions (methods).
An object is an instance of a class with its own data and behavior.
Are the data inside an object, defined in the class, that represent the object’s state.
Attributes are data that represent the state of an object.
Are functions that belong to an object, defining its behavior or actions.
Methods
Procedural Programming vs OOP
In Procedural Programming, the focus is on functions manipulating data. In OOP, the focus is on objects with data and behavior (methods).
Hides the complex details and only shows the essential information. Example: You drive a car without needing to know how the engine works.
Abstraction hides complexity and shows only relevant information.
Keeps an object’s data safe and hidden from outside interference. Only the object’s methods can access its data.
Encapsulation protects an object’s data from unauthorized access.
Lets one class (child) inherit attributes and methods from another class (parent). The child can change or add new features.
Inheritance allows a child class to inherit attributes and methods from a parent class.
Allows methods to work in different ways. In Java, it can happen through method overloading or method overriding.
Polymorphism allows methods to perform actions in different ways.
Is a general relationship between two classes. For example, a Car and a Bicycle might interact, but they’re not directly connected.
Association is a general relationship between two unrelated classes.
Is a HAS-A relationship. One class (like a Passenger) can have another class (like a Car), but the Car doesn’t depend on the Passenger.
Aggregation
Is a stronger form of aggregation where two classes depend on each other. For example, a Car and an Engine cannot exist without each other.
Composition