Blueprints for building (OOP)

Object Oriented Programming has been around for a while. When I began my career, I programmed using procedural methods until I learned about OOP. What is OOP really? When I began learning about OOP, it took me a bit to catch on to the concept. I found it to be somewhat of a large topic that at first was muddy. There are a lot of OOP principles to learn…more than can be explored within one blog post. I will periodically explore various OOP principles and you will find them scattered throughout my code projects.

When I began programming with OOP principles, one of the first items I had to learn was what classes and objects are and how they work together.

First…the definitions…

Class – a set of functions that work together to accomplish a task. It can contain or manipulate data, but it usually does so according to a pattern rather than a specific implementation. An instance of a class is considered an object.

Object – receives all of the characteristics of a class, including all of its default data and any actions that can be performed by its functions. The object is for use with specific data or to accomplish particular tasks. To make a distinction between classes and objects, it might help to think of a class as the ability to do something and the object as the execution of that ability in a distinct setting.

Here is another way of thinking about it…

Let’s say you were going to build a brand new subdivision where all the houses look alike. You create the blueprints and build your first house. You then re-create the blueprints and build a second house that looks exactly like the first one. You then repeat this process throughout the subdivision. This would not be a very wise way to build your subdivision. Why re-create the blueprints if the houses are all alike? It is a waste. Instead, you would use the first set of blueprints to build all of the houses within the subdivision.

Classes = Blueprints

Objects = Houses

So you create the class once and then can build a lot of objects from that class. Here is an example in Java…

[code lang=”java”]
// This is my class
public class House{
public House(String name){
// This constructor has one parameter, type.
System.out.println("Passed Type is :" + type);
}
public static void main(String []args){
// Following statement would create an object myHouse
House myHouse = new House( "ranch" );
}
}
[/code]

Happy Coding!

Clay Hess

More To Explore

Code

Exploring the Broadcast Channel API: Inter-Tab Communication

Intercommunication between different contexts (like tabs, iframes or workers) of the same origin has often been a challenge. With the Broadcast Channel API, developers now have a powerful tool to easily communicate between browsing contexts. In this blog post, we’ll dive deep into the capabilities of the Broadcast Channel API, exploring its features, use cases, and how it can be effectively implemented in your projects.

computer, laptop, work place-2982270.jpg
Code

Unlocking Wireless Communication: A Dive into the Bluetooth API

Wireless communication has become an integral part of our daily lives, and Bluetooth technology is at the forefront of this revolution, enabling devices to exchange data over short distances and creating a world more interconnected than ever before. At the heart of this technology lies the Bluetooth Application Programming Interface (API), a powerful tool for developers looking to harness the capabilities of Bluetooth in their applications. In this blog post, we’ll explore what the Bluetooth API is, how it works, and the possibilities it opens up for innovation in wireless communication.

Share This Post

small_c_popup.png

Need help?

Let's have a chat...


Login

Jump Back In!

Here at Webolution Designs, we love to learn. This includes sharing things we have learned with you. 

Register

Begin Your Learning Journey Today!

Come back inside to continue your learning journey.