From one newbie to another - Let's talk Java



Hi, and welcome to my blog, “Object-oriented Programming (OOP), and Java for Newbies.” Just like you, I too am learning about the many concepts of OOP and how they can be used in the real world. Now, there are other OOP’s out there such as Ruby as well as hybrid languages like C++ and Python, but for this blog, we will be concentrating on Java. Thank you for taking the time to read and I hope you find this blog informative.

 

Installing Java and an integrated development environment (IDE)

 

To start, we will quickly go over the installation process for Java as well as an IDE which will assist with many tutorials. While there are various outlets that provide these two items, the one widely known location is directly from the Oracle website, more specifically the Java Tutorials page which can be found by navigating to:

https://docs.oracle.com/javase/tutorial/getStarted/index.html.

This page has some additional topics as well, but we will be concentrating on the Java and IDE installations.

 

Within the tutorial page, there is a link that has a great checklist for the process which can be found at: https://docs.oracle.com/javase/tutorial/getStarted/cupojava/netbeans.html.

 

While we won’t go through the specifics of the installations, it is important to note that an IDE will be required along with the Java installation as suggested on the website. The Apache Netbeans IDE is listed, but this is one of many that are available to use. If you find one that is more to your liking, feel free to use what you feel is best for you but be sure to check its compatibility with Java. Within this page, you will also find instructions on creating a basic program that will provide a simple output of “Hello World!” Once you have Java and an IDE installed, feel free to return to the page and go through the steps to “Creating Your First Application”. Good luck!

 

 

 

What is an OOP?

 

As in the real world, an object can be something as simple as a tangible item such as a table, ball, or even the device you are using to read this blog. With object-oriented programming, the goal is to create a program that uses items such as objects and classes. It’s a simpler approach to software development with concepts that also benefit maintenance as well.

 

Let’s start off by discussing some of the OPP concepts. The following items are concepts are the syntax of the Java language.

 

Object: As mentioned above, software objects are typically modeled to real-world objects. With an OPP, an object is a software bundle that shows the related state and behavior.

Class: This concept is like a blueprint of objects that are created. One article from Oracle.com explains how different bikes are built from the same blueprint, yet can be different and have a model state and behavior.

Inheritance: This concept is also covered under the main principles below but is just as the word states. There are objects that share the same characteristics which are all inheritance. With inheritance, one class can derive from another.

Interface: The article states how the buttons on a TV are the interface between the wiring and the person powering the set. This is the same concept as an interface in Java, it is how a class is told what to do but not how to get it done. Just as when pushing power on a TV.

Package: This concept is just as it states, a package of organized classes and interfaces. It is similar to folders on a computer where the code is packed together to make it easier to manage large projects.

 


Now that we’ve covered the concepts of an OOP, let’s talk about principles. Not the type you find in a school setting, but the four main principles that make a programming language such as Java object-oriented.

 

Those principles are:

Encapsulation, Data Abstraction, Polymorphism, and Inheritance.

 

Encapsulation: This is essentially a form of protection that hides data implementation and restricts access to other items called accessors and mutators. What are accessors and mutators? I’m glad you asked.

 ·       Accessor: According to an article posted on vdocuments.net, “An accessor is a method that is used to ask an object about itself.”. (raymondlewallen, 2005). It is essentially a method of how the data is retrieved within an object. Access methods (also known as getters) tend to not have any restrictions and can be set as public methods.

Mutator: This method is just as the name states. It is the method that allows for the  “mutating” or changing of an object while hiding the process of how the data is changed. Mutators are also referred to as setters. Together, accessors and mutators work to protect all sensitive information in a class. These methods are what make encapsulation.

 

Data abstraction: This next item is a simpler concept to understand and works with encapsulation to hide specific details from implementation and display just functionality to the user. As mentioned in the same article by vdocuments.net, “An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of object and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer.” . (raymondlewallen, 2005). In short, it hides all the complex details and shows a much more simplified interface to the user.

 

Polymorphism: This is defined as many forms, and with Java, it means having multiple methods with the same name. With polymorphism, there are two types which are overriding (run-time) and overloading (compile-time). The major difference depends on how they are used. The overloading method is when multiple methods have the same name but different parameters while overriding is when a subclass provides its own implementation of a method that has already been defined.

 

Inheritance: The last, but certainly not the least principle is where functionality is allowed to be inherited from another class, known as a superclass or base class, rather than making a copy each time. An example mentioned in the article from vdocuments.net is how a library has many items to check out. While each item may be different such as a book to a CD to a magazine, they all share the same concept of being checked out as well as titles, cost, and checkout/return dates while still holding their separate identity.

 


While we covered a decent amount of information on Java, the installation, concepts and features, and the main principles, there is still so much more to learn. The benefit to learning a programming language in this day in age is the wide availability of multiple resources at our fingertips. This is through various tutorial pages such as the one mentioned before, to different websites and videos that are for newbies, just like us.


 

I hope I was able to shed some light on the amazing power of Java, but please feel free to check out the many resources I have listed below.

 

Thank you for taking the time to read my blog, and best of luck to you with your OOP adventure!

 

-Joey

 

 

 

References:

 

docs.oracle.com (n.d.). "Hello World!" for the NetBeans IDE

https://docs.oracle.com/javase/tutorial/getStarted/cupojava/netbeans.html

 

docs.oracle.com (n.d.). The Java™ Tutorials

https://docs.oracle.com/javase/tutorial/index.html

 

docs.oracle.com (n.d.). The Java™ Tutorials

https://docs.oracle.com/javase/tutorial/java/concepts/index.html

 

Javatpoint.com (n.d.). Java OOPs Concepts

https://www.javatpoint.com/java-oops-concepts

 

Plynko, P. (2022, June 7). Accessors And Mutators in Java. Codegym.cc

https://codegym.cc/groups/posts/accessors-and-mutators-in-java

 

PREMMAURYA. (2023, February 9). Polymorphism in Java. Geeksforgeeks.org

https://www.geeksforgeeks.org/polymorphism-in-java/

Raymondlewallen (2005, July 19). 4 major principles of Object-Oriented

Programming. Vdocuments.net

https://vdocuments.net/download/4-major-principles-of-object.html

Comments

Popular posts from this blog

Documenting a Day

Network Security