-
Notifications
You must be signed in to change notification settings - Fork 0
Classes
Büşra Oğuzoğlu edited this page Jul 12, 2022
·
19 revisions
Object-oriented programming (OOP) involves programming using objects.
An object represents an entity in the real world that can be distinctly identified. A student, a desk, a circle, a button, a television or a Netflix account can be viewed as objects and can be represented as objects.
An object has a unique identity, state, and behavior. Using these, we can model the entities in real life.
- The state of an object is represented by data fields. These are the properties of said object. For example a Student object may have "name", "GPA", "age", "class" as its data fields.
- The behavior of an object is defined by methods. To invoke a method on an object is to ask the object to perform an action. For example a TV object may have methods like "turnOn", "turnOff", "changeChannel" etc.
Classes and objects can be modeled using a UML (Unified Modeling Language) diagram. From those diagrams, we can see the properties and methods of an object as well as the relationship between different objects. Simple UML diagrams for classes "Netflix" and "Movie" are given below: