Lesson 3
Last updated
Last updated
Object-orientation provides a real-world programming solution to people working in any type of applications. It's a concept, not a language per se, but rather a set of ideas that multiple languages support.
Two simple motives:
Code duplication is a bad.
Code will always be changed.
OOP provides code reusability which reduces the code duplication because once you have it duplicated, you have to make changes everywhere which degrades the application maintainability. Application's code and requirements can be changed anytime so when you want to make changes in your application, OOP makes it easier.
There are three main features of OOP:
Abstraction: The concept of abstraction hides all but the relevant data about an object in order to reduce complexity and increase efficiency. (Consult branch oop/swift)
Polymorphism: It's a concept that allows one interface to be used for a general class of actions. It’s an operation that may exhibit different behavior in different instances. (Consult branch oop/swift)
Inheritance: The process by which one class acquires the properties and functionalities of another class. Inheritance provides the idea of code reusability and each sub class defines only those features that are unique to it. (Consult brach oop/swift)
OOP provides a clear modular structure for applications which makes it good for defining abstract datatypes where implementation details are hidden and the unit has a clearly defined interface.
OOP makes it easier to maintain and modify existing code as new objects can be created with small differences to existing ones.
OOP provides a good framework for code libraries where supplied software components can be easily adapted and modified by the programmer. This is particularly useful for developing graphical user interfaces. Consult Javascript Design Patterns for web, React Design Patterns for React, Swift Design Patterns for iOS and Java Design Patterns for Java.
Javascript
Classes
Callbacks
Scope (this, local, global)
Swift
Classes
Callbacks
Scope (self, local, global)