These several weeks, we learnt about a new concept: OOP. OOP stands for “object-oriented programming”.
First, program paradigms are a way to classify programs into different categories, and two typical examples are procedural programming and object-oriented programming (OOP). The former one is a relatively old paradigm, which focus on the functions. OOP, on the other hand, is more advanced and complex. It focuses on an object, which are smaller unit in a program.
This concept is a little hard to understand. Take a bottle as an example. We know that a bottle is an object, and we can do different manipulations on that bottle. For example, a bottle has several states (field): open, close, full, empty, etc. And when we want to make use of it, we can open it and drink it. The behavior (method) “open” changes its state, and those functions are known as properties.
And object has three key aspects: identity, attributes, and behaviors.
- Identity is identifier in Java. It is the thing that separate different objects.
- Attributes are class fields in Java. It means those independent states of a class or object.
- Behaviors are methods in Java. It means what manipulation we can do on an object.
Then we were asked to find some examples in the real life of objects with the above elements. Our group took door as an example. It has two basic states: closed and open. When we want to use it and go to another room, we can simply open it, and that’s its behavior.

Another important concept in OOP is called class, the blueprint of individual objects. It’s like a model; programmers can make more identical objects through this blueprint. For example, in the circle activity, the circle class is like a blue print, all those circles that composed that picture were all created based on this blueprint, which is the circle class. Classes allow us to separate the data for each object, while using a unified code to manipulate each object.
Actions that an object can take are called methods. It’s the final important concept in OOP. For example, we can change the color, size, position of the circle in the in-class activity, and all those behavior are called methods. They have headers and body parts, and contains declarations (to create additional, temporary variable spaces) and statements (to describe the actions of the method).

Method Classifications
The first one is accessor. It’s also known as the “get” method. It returns the current values of object data. The second one, mutator, is also known as “set” method. It changes the value of object data. The third one is called utility, and they are designed to accomplish certain tasks. The final one is constructor, which construct the whole basic tools in a program.

HL Topic: Stack
This week, we learnt specifically on one abstract data type: stack.
There are three method in stack: push, pop and isEmpty; which means, we can do these three manipulation to a stack. Pop is to add an element to the top of the stack; push, on the other hand, is to remove it. IsEmpty is to check whether the stack is empty. If it is, the method would return “true”.
There are some other methods for stack, like peek (see the value or content of the top) and size (to return the size of the stack, which means to print the location of top).
Stack is everywhere in our life. For example, the clipboard in our computer is a stack. You can only add one or read one to the very top of the list of items in the clipboard. Another is the record of manipulation. When clicking the back button, we can only go back one step, which is the opposite to the sequence of actual manipulation.
Using this property, we made a program that really works as a stack.



Conclusion
OOP is a popular tide in recent years, so we should learn this part well to follow the trend. It makes the class more difficult, but I know it’s the beginning of challenges.