Java and Object Oriented Programing (OOP)

 What is Object Oriented Programming?


Object-oriented programming is a form of programming that is more in tune with how we view things in other aspects of our lives. Rather than using functions or specific logic to create code, it centers software design around "objects" or data. It has been easier to wrap my head around because I can relate certain aspects of it to parts of my everyday life. In today's post, I'll go over a few of the core concepts of object-oriented programming, and you'll have a better understanding of what I'm getting at by the end. 

What are the core concepts of object-oriented programming?

In object-oriented programming, there are four core concepts. These concepts include encapsulation, inheritance, polymorphism, and abstraction.

  • Encapsulation: Encapsulation is the idea of bundling attributes and functions that operate on data into units called classes. There are different types of classes, but we won't dive too far into that here. Encapsulation also hides all of the messy parts of an object and only shows the user what is necessary for the task or information they are trying to accomplish or gain. You can think of it like the inner workings of a car. Whether that be its parts like its transmission or braking system or even something as simple as the radio. All of these things are contained within the car, and there are simpler ways of operating them that don't require you to see all the messy inner workings, such as your brake pedal, the gear shift, or the tuning knob on the radio.

  • Inheritance: Inheritance in the context of object-oriented programming involves the ability of a new class to inherit properties from an existing class. As you can imagine, this allows for a smoother relationship between classes and allows for the reuse of code. To give you an idea of how this might be applied to a real-world concept, we can use a similar car example. All cars have wheels, an engine of some sort, and a way to operate them. This is a concept that doesn't need to be redone for each new car that is released, so this formula of sorts can be reused. If we were to look at a subclass that might inherit this formula, we could break things down into SUVs, trucks, or sports cars. They all have the same properties as the original title of the car but are different in their own ways.

  • Polymorphism: Polymorphism is what allows objects from all different types of classes to still respond to the same method call. So, while you might be using a base action like "draw" or "sound," you are able to plug in the actual sound or picture that would be created. So, objects can keep the same way of calling upon them but simply require a different title for each sound that is loaded into the system. This is quite the time saver because you can have a single simple function instead of having to redo it every time.

  • Abstraction: Abstraction involves simplification. This allows you to see only the important details rather than every complex thing that goes into it. This goes hand in hand with encapsulation to provide a smooth experience. It's the reason you can move the volume knob without needing to know the inner circuitry of a radio.

Java and OOP

The core idea of Java and object-oriented programming is to make it easy to create classes and objects that serve as building blocks for creating something greater. Rather than having a specific code for a specific need, it sort of gives you the ability to create a simpler environment in which you can accomplish the given task. I like to think of this as the difference between drawing something and playing Minecraft. Rather than having to draw each individual block in Minecraft, you are able to gather the materials needed and set to work on the larger project. This creates a smoother experience and can make programming....dare I say it...fun?

Want to dive deeper?

Below, I've included some helpful links and descriptions to get you started on your journey to programming with Java. Installing Java is as simple as installing any other program. It involves going to the Oracle site to get the latest version of the Java Development Kit (JDK) that is compatible with your system, downloading it, and then simply running the installer. Once installed, you can find different programs that will simplify development in Java to make the experience even smoother. These are similar to sandboxes or editors in other programs. You can find tutorials all over the internet to get started. I'll include a few of those below as well. I wish you the best of luck on your journey!


Helpful Links:

Oracle site for gaining JDK: https://www.oracle.com/java/technologies/downloads/


Tutorials within the Oracle Site: https://docs.oracle.com/javase/tutorial/index.html

External site for tutorials: https://www.tutorialspoint.com/index.htm

Comments

Popular posts from this blog

Algorithmic Design and Data Structures For Newbies

Operating Systems Concepts