[Dart] OOP : Object Oriented Programming

 

[Ko]

 

1. Abstraction in Action

 - OOP : Object Oriented Programming

 - OOP 4가지 특징을 가짐 : Abstraction, Encapsulation, Inheritance, Polymorphism

 - Abstraction : app 복잡한 기능을 object 이용해서 별도의 기능으로 세분화, 모듈화 하는 .

 

2. Encapsulation in Action

 - 실수로든 고의로든 의도하지 않은 접근을 하지 못하도록 encapsulation . 외부에서 접근하지 못하도록 class property private하게 만들고(_ 추가), 해당 클래스 내부에 class property 접근하는 method 만들어서 method 통해서만 data 한정된 권한을 가지고 접근하도록 만든다.

 - , abstract 개념에 의해서 모듈화 해놓은 각각의 object class들이 서로 간섭하지 못하도록 encapsulation 처리를 .

 

3.  Inheritance in Action

 - class super class 또는 parent class로부터 property method 상속(inherit) 있음.

 - 예 : StatelessWidget StatefulWidget extends문을 사용해서 상속함.

 

4. Polymorphism in Action

 - Polymorphism : 다형성

 - extends문으로 상속해서 새로 만든 class에서 부모가 가진 method 덮어써서 자신만의 method 가지기를 원하는 경우에는 @override 선언하고 아래에 덮어쓰기를 원하는 method 정의해줌으로써 object 다형성을 부여해 있음.

 - overrrid 대상 method 내용 일부에 부모의 method 활용하고자 하는 경우에는 super.method_name 형식으로 부모의 method 접근할 있음. (super 부모 class 나타냄, 부모 method 어떤 추가 특성을 더하고자 하는 경우)

 - 예 : 일반적으로 Stateless widget 또는 Stateful widget에서 build method createState method override하고 있음.

 

=================================================================

 

[En]

 

1. Abstraction in Action
 - OOP: Object Oriented Programming
 - OOP has 4 characteristics: Abstraction, Encapsulation, Inheritance, Polymorphism
 - Abstraction: To subdivide and modularize the complex functions of the app into separate functions using objects.

2. Encapsulation in Action
 - Encapsulation prevents accidental or intentional access. Make the class property private (_ add) so that it cannot be accessed from outside, and make the method to access the class property inside the class to access with data-limited authority only through that method.
 - That is, encapsulation processing is performed to prevent each object class modularized by the abstract concept from interfering with each other.

3. Inheritance in Action
 - Class can inherit properties and methods from super class or parent class.
 - Example: StatelessWidget and StatefulWidget are inherited using extends statement.

 

4. Polymorphism in Action
 - Polymorphism: Polymorphism
 - If you want to have your own method by overriding the method owned by the parent in the newly created class by inheriting with the extends statement, declare @override and define the method you want to overwrite below to give polymorphism to the object. Yes.
 - If you want to use the parent method for a part of the contents of the overrrid target method, you can access the parent method in the form of super.method_name. (super indicates the parent class, if you want to add some additional properties to the parent method)
 - Example: Generally, build method and createState method are overridden in stateless widget or stateful widget.

'플러터(Flutter) > 다트(Dart)' 카테고리의 다른 글

[Dart] Final vs. Const  (0) 2020.03.19
[Dart] Class Constructors  (0) 2020.03.18
[Dart] Conditionals - If/Else  (0) 2020.03.18
[Dart] List  (0) 2020.03.18
[Dart] Arrow Functions  (0) 2020.03.18

+ Recent posts