Please enable JavaScript.
Coggle requires JavaScript to display documents.
Object-oriented vs Functional (OOP (Principle (Inheritance (Benefit…
Object-oriented vs Functional
OOP
Principle
Abstraction
A class define a high-level interface to the outside world, leaving the lower-level details to implementation-specific code
Inheritance
A child-class can modify or extend the behavior of its parent-classes
Allow child classes inherits the characteristics of existing parent class
Benefit
EXtensibility
Reusability
Provides abstraction
Eliminates redundant code
Polymorphism
Child-classes can use its own method or parent class. When child and parent classes have two different methods but have the same name, the program will pick the methods depend on which class you are referencing an instance off
Encapsulation
A class hide details of how it does its thing, while supplying a nice, clean interface to the outside world
Benefit
Hiding implementation details reduces complexity
Ensure structural changes remain local
Cohesion and Coupling
Cohesion
Describe how closely all the routines in a class or all the code in a routine support a central purpose
Ex
Good
Math has Sin(), Cos()..
Bad
Magic has MakePizza
Coupling
Describes how tightly a class or routine is related to other classes or routines
Coupling must kept loose
Modules must depend little on each other
All classes and routines must have small, direct, visible and flexible relations to other classes and routines
One module must be easily used by other modules
interface
set of operations (methods) that given object can perform
definition
programmers define not only data type of a data structure but also the types of operations ( functions ) that can be applied to the data structure. The data structure becomes an object that included both data and functions.
Functional programming
Process of building software by composing pure functions, avoiding shared state, mutable data, and side effects.