pctechguide.com

  • Home
  • Guides
  • Tutorials
  • Articles
  • Reviews
  • Glossary
  • Contact

Object Oriented Programming 2

Imagine creating a blueprint for an intelligent robot. The robot’s purpose is very simple: to open the curtains in the morning, and to close them at night. You call them CurtainBots, build three of them, and install them in your home. Great…

Now, if you consider the blueprint as a class, then what you have done is to create three objects of the class CurtainBot, and you might call them CurtainBot1, CurtainBot2, and CurtainBot3. These objects have a particular set of features, and also have tasks defined which depend on certain events: dawn and dusk. In other words, they’re event driven.

It’s a little more complex than that, of course. You have three of the robots, and you may have a dozen or more windows with curtains. So, which robot does which window? Has this been pre-decided in the code? As an approach this is poor, as it would be better to have the robots know what a window is, to search for them, and to deal appropriately with any it encounters. It would be better still if the robots could cooperate with each other, so that they can between them decide that their task is completed, rather than all three having to circuit the entire house.

This, it turns out, is the basis of object oriented thinking: to create classes of objects that are similar and well defined in terms of their features and tasks. These objects need to communicate with each other and to cooperate in order to achieve tasks efficiently.

Maybe not so simple, but powerful. In fact so powerful that object oriented (OO) capabilities are now included in many modern programming languages. This introduction will look at the class, the fundamental concept in all languages that use OO.

The Class

In object oriented programming (OOP), a class is short for classification. According to dictionary.com, classification is the act, process, or result of classifying. It’s the basic process of grouping similar objects, and this is a useful concept in programming, because it’s what we do in our everyday life. It’s how we learn to understand the world, and develop thought, language and so on.

The OOP class, then, is a formal programming construction that mirrors this natural process of grouping similar things.

Abstract Data

Often a computer program’s job is to try and emulate in some way a real world situation, but it clearly can’t handle every single detail. Thankfully, it doesn’t need to; for instance, you really don’t need a person’s hair colour to get their bank balance.

To a computer program this is important. Efficient software requires everything superfluous to be filtered out while keeping the quality data that’s needed – in other words, to abstract the necessary data, and create variables for only those data.

As an example, take horses. With horses, you can make certain assumptions about them, because without certain basic things it wouldn’t be a horse. For instance, when someone is talking about a horse, you don’t need to be told that it has four legs, two eyes and it says neigh. They just say horse, and you know those things. But, you might want to know its breed, hands high and colouring, because these are the things that vary from horse to horse.

We know that if we were constructing a class for horses, we’d only concentrate on the information that’s relevant. In other words, we’d abstract what we needed, and the rest would be quietly ignored. So in our class, we’d likely have variables for breed, hands high, and colouring.

And with all this abstracting, guess what? Yup, a class is referred to as an abstract data type, or ADT.

But, we can’t stop just there…

Methods

Many languages provide abstract data types, like C’s structure. But this would be where a discussion of the C structure stops, because the structure is only able to hold data. The class, however, takes things a step further, and this is really where object-orientation begins to kick in.

Continuing with the horse analogy, if you imagine not only all the things that you would measure to define a horse, but also all the things that you would do with a horse, doesn’t it makes sense to describe the tasks together with the data? After all, riding, grooming and carting are as much a part of your general horsing as are its height and colour. So, if you’re going to have to write these methods anyway, why not keep them together with the horsey data?

In the OO class, this is exactly what happens, and it is the basic form of encapsulation which we’ll look at next

  • Object Oriented Programming 2
  • Object Oriented Programming 3
  • Object Oriented Programming 4
  • Object Oriented Programming 5
  • Object Oriented Programming 6
  • Object Oriented Programming 7
  • Object Oriented Programming 8

Filed Under: Object Oriented Programming

Latest Articles

Developing a Python to Extract Data from Your Smartphone

Many times we ask ourselves: "What part of the universe is this phone from?", even if we already know where it is, but we don't know which operator. Let me tell you that in this little tutorial I'm going to show you how to extract information from a phone through an API with Python. To use the … [Read More...]

CleanTalk as Your Weapon against Spam

Are you tired of spam? You aren't alone. It has become a massive epidemic over the past few years. Around 14.5 billion spam messages are sent every single day. Authorities around the world have started taking stricter penalties against spammers. In 2017, two of the world's worst spammers, … [Read More...]

Sony Memory Stick technology and background

Sony are the only consumer goods manufacturer to have stuck with their own proprietary removable memory card. Their Memory Stick brand, introduced in 1998, actually covers a variety of different formats that have evolved as devices have changed, getting physically smaller but demanding more storage … [Read More...]

Everything You Need to Know About Sourcing Circuit Boards From U.S. Suppliers

In This Article This article includes: Why Source PCBs From the United States?How to Get a Quote From a U.S.-Based PCB ManufacturerThe Top U.S. … [Read More...]

Top Taplio Alternatives in 2025 : Why MagicPost Leads for LinkedIn Posting ?

LinkedIn has become a strong platform for professionals, creators, and businesses to establish authority, grow networks, and elicit engagement. Simple … [Read More...]

Shocking Cybercrime Statistics for 2025

People all over the world are becoming more concerned about cybercrime than ever. We have recently collected some statistics on this topic and … [Read More...]

Gaming Laptop Security Guide: Protecting Your High-End Hardware Investment in 2025

Since Jacob took over PC Tech Guide, we’ve looked at how tech intersects with personal well-being and digital safety. Gaming laptops are now … [Read More...]

20 Cool Creative Commons Photographs About the Future of AI

AI technology is starting to have a huge impact on our lives. The market value for AI is estimated to have been worth $279.22 billion in 2024 and it … [Read More...]

13 Impressive Stats on the Future of AI

AI technology is starting to become much more important in our everyday lives. Many businesses are using it as well. While he has created a lot of … [Read More...]

Guides

  • Computer Communications
  • Mobile Computing
  • PC Components
  • PC Data Storage
  • PC Input-Output
  • PC Multimedia
  • Processors (CPUs)

Recent Posts

CoupMania Removal

CoupMania is another in a long list of annoying adware products. It is not a serious or malicious piece of software, but like other forms of adware, … [Read More...]

Think About Headless Commerce as of a Modular System

In recent years, eCommerce has transformed to where consumers no longer handle purchases on conventional websites. Shopping is currently carried out … [Read More...]

5 Tips to Secure Your Computer While Working From Home

Introduction Since its discovery in November of 2019, COVID-19 has grown to become a worldwide pandemic, forcing many people into the safety of … [Read More...]

[footer_backtotop]

Copyright © 2026 About | Privacy | Contact Information | Wrtie For Us | Disclaimer | Copyright License | Authors