Use [] to find tag! Example: [flutter, javascript]

Dart Basic Programming
Dart Basic Programming

Chapter 13

Object Oriented Programming

remove_red_eye 5108 Times
spellcheck 244 Words, 1445 Characters

In the dart programming language, Object Oriented Programming (PBO) or commonly called Object Oriented Programming (OOP) is a method in programming based on a class.


Class Description

Class is an object that has content (value) to describe the class itself. class can also have a parent to take another class. A more complete explanation can be seen in article Dart Programming - Class .


Object Description

On darts, objects are written based on the classes that have been created, with class attributes, which can be throw via constructor. Explanations for objects can be seen in this article


OOP Explanation

OOP (Object Oriented Programming) or commonly called PBO (Object Based Programming) is programming that prioritize attribute base on each class.

an example of an attribute in class



  class Ruangan{
    String guru;
    List siswa;
  }


The room is a class, teachers and students are attributes. Then how to implement the object so that it can be used in another method/class? the answer is the constructor, we can set the attribute of an object from the or method other classes use the constructor.

Here is an example code



  void main(){
    Room(teacher: "John", students: ["Agus", "Doe", "Gilang"]);
  }
  
  class Room{
    String teacher;
    List students;
    
    Room({required this.teacher, required this.students});//optional required constructor
  }
  


Next Article (Data Model)
Content Navigation