Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,655 members, 7,813,210 topics. Date: Tuesday, 30 April 2024 at 08:43 AM

Please What Really Is Object Oriented Programming. - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Please What Really Is Object Oriented Programming. (1661 Views)

A Beginners Guide To Object-oriented Programming (OOP) In PHP 5+ / Fundamentals Of All Object Oriented Programming(oop) Languages / Criticism Of Object Oriented Programming (2) (3) (4)

(1) (Reply) (Go Down)

Please What Really Is Object Oriented Programming. by 0Edward0(m): 11:16am On Jun 09, 2011
Please all the gurus in the house.

I have read about OOP but the thing no just wan enter my head      , abeg who fit explain the concept with analogies in simple terms (pidgin accepted).

Abeg I dey wait
Re: Please What Really Is Object Oriented Programming. by dellnet: 2:19pm On Jun 09, 2011
lol! let me try and see if you can get it but not in pidgin though.

Think of OOP as programming an object, an object is any real world thing for example lets take a car.


class car
{
//method/functions
void speedup();
void slowdown();
void stop();
//etc

//properties
int engine;
int wheel;
int shift;
}


A real car (V-Boot) has method to accelerate, decelerate etc as this little class above illustrate. Then there are properties of a car for example color, engine, wheel, gearbox etc. The concept here is instead of programming a car by using procedure methods, you look at a car as an object and implement just about anything a car has or can do. This will make your programming task a whole lot easy. So the essence of OOP is software engineering and re-usability, you can create software that mimic a real object through OOP. I will not use any programming jargon here but keep in mind this your car, because it is a vehicle, can inherit features of other vehicle like features of boat, airplane etc. So you see how good a concept of engineering is OOP?
Re: Please What Really Is Object Oriented Programming. by Nobody: 3:07pm On Jun 09, 2011
OOP is a style of coding that views coding in Objects/Class Form,unlike typical procedural coding that only dealt with the flow of coding,OOP focuses much more on how Object related with each other,it allows you to have a Sort of Object oriented way of viewing codes.for instance.
I am a Boy,i smoke,drink,sleep around with harlots.thanks to dell_net coding me will be a lot easier.but first before jumping into it,A Class is a like a Blueprint of an Object.meaning a If a Class is like an arhictectural buiilding design ,the Objeect is the Main building created from the design.
so let's code me in OOP.am assuming Java since they both the same my C++ knowledge is blurry and PHP is not ideal for learning OOP at first;

class Okeowo{


string name="Okeowo Aderemi";
bool alcholic=true;
bool seekHarlots=true;
int age=25;

String void speak()
{
System.out.println("I am Okeowo Aderemi"wink;
}

Int void myAge()
{
return this.age
}

}

i don try next person take over.
Re: Please What Really Is Object Oriented Programming. by gifted: 3:08pm On Jun 09, 2011
@dell_net, I am now getting the concept, I will never for get this car. Secondly how can i use other classes with my own class. Pls add me on yim netzro@ymail.com
Re: Please What Really Is Object Oriented Programming. by Nobody: 3:51pm On Jun 09, 2011
To use other classes with ur class there has to be a relationship.check this instance out

public void Nitro(ExoticCars car)
{
car.nitroSpeed();

}

that way if the car argument is not of a class of ExoticCars it throws an error that way u can used other classes with ur methods.
Re: Please What Really Is Object Oriented Programming. by dellnet: 3:59pm On Jun 09, 2011
The simplest way to use other classes is through inheritance. Imagine now you want to make your car to fly, all you have to do is inherit (and implement) the features of an airplane. Thus class car can be said to inherit from class airplane which produces a flying car.

But if you were not to use OOP, you will probably have to tear down your car completely to build a new flying car. See how seamless and easy OOP is again?
Re: Please What Really Is Object Oriented Programming. by ABAboi: 4:17pm On Jun 09, 2011
This is an easier way to understand OOP. It is just an interesting interpretation of your DFD diagrams. You structure your classes (abstract, inherited etc) based on diagrams you have modelled.
Re: Please What Really Is Object Oriented Programming. by roadsta(m): 2:50pm On Jun 18, 2011
nice job guys.
another way to use other classes inside your class is known as composition.imagine dat ur car.u instantiate ur car  e.g  Car myCar = new Car.but a car have an engine.
so u write another class,an Engine class.Create an engine object e.g Engine moto = new Engine
Now in ur car class,when declaring the attributes
like say          int[] doors;
                     int[] tires;
                     Engine moto;  //this is an engine object from Engine class.
                                    // so ur car now contains another(Engine) class instance.

she u dey get the idea small small.
Re: Please What Really Is Object Oriented Programming. by Ghenghis(m): 8:56pm On Jun 19, 2011
To add to what everyone has said and dell_net's example OO allows you to express complex programming tasks in the language of the problem.

Imagine baking bread : the recipe might be :

1 gram flour
2 spoons sugar
1 teaspoon yeast etc.

The recipe then goes on to show you how to mix and how long to bake. Simple enough ?
The complexity that's hidden away is you didn't worry about how was the flour made ? corn, yam, wheat ? Who planted the corn ?
What kind of oven was the bread baked in ? blah blah blah

OO allows us to worry about just parts of the problem that are immediately important/interesting to us.
dell_net:

The simplest way to use other classes is through inheritance. Imagine now you want to make your car to fly, all you have to do is inherit (and implement) the features of an airplane. Thus class car can be said to inherit from class airplane which produces a flying car.

Yes dell_net is right but it's also usually the wrong way, roadsta makes a good point about composition. I don't have to be a plane to "fly" i could simply use/board a plane.
(dell_net i get what you're trying to pass on, just wanted to show @0Edward0 how OO focuses on everyday language rather than **$% ) wink

(1) (Reply)

Beginning Coders Get Dirty / Laravel Group On Whatsapp / Help A Brother On Solution

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 24
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.