Hello, this is Bndsbon. In this very blog post, I am going to talk about Object Oriented Programming. Different than Java, OOP is more broadly defined, let us first compare OOP with Procedural programming.
Procedural programming:
Focuses on how to accomplish a target or how to finish a task.
large bulk part of the program is divided in the bits of small parts called unite procedural programming.
It mostly concentrates on functions
It is regarded as the oldest paradigms
Example: FORTRAN
OOP:
Emphaises on the events that occur on those objects
small parts of the program is called objects
Data and functions are combined together called class
comparatively difficult for beginner
Example: Java
picture from pinerest
First, let us look at the object in OOP, which is the most basic, fundamental, and crucial thing in OOP.
Every object in OOP has state and behavior. Objects also have their own identity, their own attributes, including color, weight, and signs. Last but not least,they have different behaviors as well.
A class, can be regarded as a blue print in OOP. Class itself allows us to separate data from each object, and in the mean time, allow us to manipulate the codes using common codes.
We use classes in OOP on a daily bases because they manipulate units like flights and ships.
Objects are the instances that we created in a class. And the actions that the object do or does is called Methods
Fields of classes includes instances variables and static variables. It can be any of the objects from the same class, or primitive data types.
picture from study tips and tricks
Here are the exercises I did in Chapter 1
For Mac touchpad users, all you need to activate the circle is to use two fingers and click it, chose the “void makeVisible().” you will see the picture below
After giving some simple commands, this is what happens to the circle
After we invoke the move horizontal method, this is what happens
with the help of the method call, we can move the cirle any units we want, in a very simple click.
Once we insert the value in, this is what the program gives
The “State” is like an examiner, it examines the state that the code is in.
Here is another example that is adding students to a lab class
All in all, in this class we are learning about OOP, and some fundamental key words. Though they are the very basics, if we do not pay special attention to them, we will be in “big trouble”. And after learning about them, I found myself more clear on programming, and everything is getting more organzied. However, even you know how to program an application with OOP, it is still important to type it down by your own, whenever the question asks you to do so. Because it is the only way to get familiar with all those complicated codes and programs.
Looking forward to our next class!
References:
Leave a comment