66 lines
1.2 KiB
Markdown
66 lines
1.2 KiB
Markdown
# Object Oriented Programming
|
|
|
|
<img src="https://i.imgur.com/qPsUYyd.jpg" alt="meme" style="zoom:50%;" />
|
|
|
|
## 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
|
|
|
|
```csharp
|
|
public class MyFirstClass {
|
|
public MyFirstClass() {} //constructor
|
|
}
|
|
MyFirstClass c = new MyFirstClass(); //new object
|
|
```
|
|
|
|
## Modelization
|
|
|
|
- First mandatory step
|
|
- |