1.6 KiB
1.6 KiB
Object Oriented Programming

Introduction
- A programming paradigm
- Allows:
- Model objects
- Make objects interact with each other
- Objcts refer to complex variables
Benefits and motivation
- Modularity
- Abstraction
- Productivity and reusability
- Security and encapsulation
Concrete example
- When we develop a game with cars inside
- We develop the car one time and all other games can re-use the base of the car that we created
- We have access to characteristics
- Model
- Color
- Fuel type
- ...
- We also have the behavior of the car
- Start
- Accelerate
- Stop
Object
- Data part: object characteristcs
- Attributes
- Properties
- Fields
- ...
- Code part = oject behavior
- Methods
- Procedure
Class
- Object = classs instance
- Class
- New data type
- Collection of objects
- Figuratively
- Class = mold
- Object = cake
- Class at compilation VS object at runtime
public class MyFirstClass {
public MyFirstClass() {} //constructor
}
MyFirstClass c = new MyFirstClass(); //new object