Encapsulation(캡슐화): 객체의 내부 로직을 감추고 외부에는 상대적으로 안정적인 부분만을 공개함으로써 데이터를 안전하게 보존하는 기법이다. 캡슐화는 외부에 영향을 주지 않고 객체 내부의 구현을 변경할 수 있기 때문에 내부 로직에 대한 유연함을 제공한다.
출처:
https://velog.io/@suyeonme/JavascriptOOP
https://seunghunchan.tistory.com/23
(영문 해석)
OOP vs Functional Programming: What’s The Difference?
Object-Oriented Programming (OOP) is the most common and widely used programming model. OOP accentuates using objects and classes. For the application of this model, we need to divide the software variables into so-called classes (object categories) and then build the architecture based on the predefined classes. This paradigm is characterized by a structure that resembles a tree with a rod and branches. Each class inherits properties from its “parent”. And all this together is a complex artificial system that integrates for ease of use of the coding language. OOP-oriented coding languages include Python, Paskal, JS, C ++, Java, etc.
Why is OOP Good?
- OOP reproduces simple and understandable structures from complex things.
- You can reuse OOP objects to write other programs.
- Many libraries and frameworks speed up the development as can be easily integrated into your architecture.
- A wide segment of OOP developers is ready to assist you in any task.
Functional programming is a manner of software engineering in which we try to describe the solution via a mathematical function. This concept of coding belongs to declarative ones. In the OOP, the accent is on “how do we solve this?” At the same time, the FP focuses on “what do we solve?”. Some of the popular functional languages are Haskell, Rust, Nix, Elixir.
What Are the Pros and Cons of FP?
The FP functions are easy to comprehend since they do not alter in any way and depend only on the input data. What output we get from these functions is the outcome of the value they bring. Their signature can give us all the required data about them.
Moreover, the code of the software you are writing becomes simpler to interpret. The reason is that FP languages can perceive functions as values, or vice versa – they transmit different values to functions presented as parameters.
With FP, it is easy to test software and fix bugs. The functions, in this case, are simple – they take into account the argument and generate the original data. They guarantee that they will not generate redundant or secondary data that will not be easy to understand or count.
As for disadvantages, the introduction of pure functions can demand from the developer to get out of the box of OOP thinking and begin to work with the programming as with the mathematical case. Furthermore, if it is simple for you to introduce all the functions it will be burdensome to incorporate them into a unified software unit. As one of the examples of these difficulties, I can mention that it is rather unusual for OOP programmers to code recursively instead of using the loop method.
Source: https://www.emizentech.com/blog/oop-vs-functional-programming.html