OOP Flashcards
What is Programming Model?
Programming Model tells you
1️⃣ How to organise the information and processes needed for a solution
2️⃣ Allows/facilitates a certain way of thinking about the solution
What are the THREE programming paradigms?
1️⃣ <b>Procedural</b>: C, Pascal
2️⃣ <b>Object Oriented</b>: Java, C++
3️⃣ <b>Functional</b>: Scheme, LISO
What are the <b>characteristics</b> Procedural language?
1️⃣ View program as a process of transforming data
2️⃣ Data and associated functions are separated
3️⃣ Data is <b>publicly accessible</b> to everyone
Advantages of Procedural language
1️⃣ Closely resemble the execution model of computer, <b>Efficient in execution</b>
2️⃣ <b>Less overhead</b> when designing
Disadvantages of Procedural language
1️⃣ Harder to <b>understand</b>. Logical <b>relation between data and functions is not clear.</b>
2️⃣ Hard to <b>maintain</b>
3️⃣ Hard to <b>extend/ expand</b>. Affect the current implementation.
Main features of OOP
1️⃣ Encapsulation
✅ <b>Group data and associated functionalities</b> into a single package.
✅ <b>Hide</b> internal <b>details</b> from outsider.
2️⃣ Inheritance
✅ A way of <b>extending current implementation</b>
✅ Introduce logical <b>relationship between packages</b>
3️⃣ Polymorphism
✅ <b>Behaviour of the functionality changes</b> according to the actual type of data
❌ No direct access to data
✅ Use process to manipulate data
Example: <b>Bank Account Object</b>
What are the <b>characteristics</b> OOP?
1️⃣ View program as a collection of <b>objects</b>
Perform computation through interaction of objects
2️⃣ Each object has a set of functionalities and data
Advantages of OOP
1️⃣ Easier to <b>design</b> as it closely <b>resemble the real world</b>
2️⃣ Easier to <b>maintain</b>
✅ <b>Modularity</b> is enforced
✅ <b>Extensible</b>
Disadvantages of OOP
1️⃣ <b>Less efficient</b> in execution, Further <b>removed from low level execution</b>
2️⃣ Program is usually <b>longer</b> with high <b>design overhead</b>
Encapsulation
<b>Group data and associated functionalities</b> into a single package.
Separating data (<b>attributes</b>) and functions (<b>methods</b>)
Classes
How to define a class? (MUFG)
Class = Data + Processes
A class is a user defined data type. Variables of a class are called <b>objects (instances)</b>.
A class contains: