Posts

Dependency Inversion Principle

Image
DIP  High-level modules should not import anything from low-level modules. Both should depend on abstractions Abstractions should not depend on details. Details (concrete implementations) should depend on abstractions DI is about wiring, IoC is about direction, and DIP is about shape. - Martin Fowler Easy Extension and Decoupling

Interface Segregation Principle

Image
ISP Keep interfaces small so that users don’t depend on things they don’t need. ISP is intended to keep a system decoupled and thus easier to refactor, change, and redeploy Many client-specific interfaces are better than one general purpose interface. The principle of separating interfaces from the client's perspectives When interface which we don't use is changed, Client use the interface need to recompile, rebuild and deployed again. If we stick to ISP, Program can get decoupled. 

Liskov Substitution Principle

LSP A program that uses an interface must not be confused by an implementation of that interface A subclass should require nothing more and promise nothing less LSP is a principle of extension and definition of method. LSP is a principle of Polymorphism supporting OCP Violated LSP can not support OCP if S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program. When replaced with object of type S, Don't use downcast, instanceof for specific type. For example There is a Vehicle Class is a super type. Police car, truck and  taxi can be a subtype of Vehicle, but Helicopter can not. It means even if police car should be replaced by taxi or truck, The program should work well. It's similar to OCP and shows Polymorphism of OOP

Open-Closed Principle

Image
OCP Objects or entities should be  open for extension  but  closed for modification . A class should be extendable without modifying the class itself When modifying some module for adding a new feature,  If I should modify another modules use it, It's too hard work. So if we stick to OCP, We can add new operations easy without modification. Open for extension is not adding a function but adding a new type and Closed for modification means high level policy shouldn't be modified. DIP and Abstraction is required for OCP. Abstraction are two ways for OCP. First is extension for abstract class. Second is implementation of interface. Therefore OCP linked Polymorphism one of the features OOP.

Single Responsibility Principle

Image
SRP A module  should be responsible to one actor A module should serve for one client. It means coupled resposibilities should be segregated A class should implement only one functionality A module which has over one functionality is responsible to many. It is likely to be strongly coupled. It makes test harder and maintenance cost higher. SRP is good for reuse and maintenance on the oter hand, increase number of objects and class hierachey and structure become complex. Dependency Inversion Principle and Interface Segregation Principle are solutions for SRP.

Functional Programing

Functional Programing 하나의 프로그램을 수학에서의 함수의 합성체로 보는 paradigm FP Features 1.  Pure Functions 2.  Stateless and Immutablity paradigm, input-output, 외부환경으로부터 철저히 독립적이다.순수함수 특징 선언형 함수도 변수다. 고계함수, 커링, 함수콤비네이터

Object Oriented Programing

OOP (Object Oriented Programing) OOP is a programing paradigm based on Objects which can contain Data and Procedure . Identification Objects, Definition Objects, Making a relationship each Objects. OOP Features 1.  Classes and Instance Class is a definition for instance. It contains meta data of member variables and method. It looks like specification for making a car. It describes parts of car and assembly process. Instance is a car which made according to specification. 2.  Data Abstraction Data abstraction is the reduction of a particular body of data  to a simplified representation of the whole. Abstraction, in general, is the process of removing characteristics from something to reduce it to a set of essential elements. To this end, data abstraction creates a simplified representation of the underlying data, while hiding its complexities and associated operations 3. Encapsulation  Open or Hiding Data and methods in class as access modifier. Encapsulation i...