Object oriented programming (oop)

In summary: Basically, the author is saying that procedural programming is good for small programs that don't need to be very complex, data hiding is good for hiding data inside modules so that it isn't visible outside of the module, and object oriented programming is good for organizing your code into classes so that you can easily access and use the data within those classes.
  • #1
PainterGuy
940
69
hello,

i have tried to read wikipedia and wisegeek articles on _objected oritented programming_ but didn't learn a bit. I'm simply trying to learn the basics and know almost nothing abt programming so far. can u give me some basic understanding of this oop, please? wut r these objects? i thought computer anguages are written using instruction not objects... please show me the light. peace
 
Technology news on Phys.org
  • #2
Hate to come off a little abrasive, but please make an attempt to use proper English while on the forums, I know that English isn't your first language, but you're not going to get much respect here when you use words like 'wat, r, wud, etc'.

painterguy said:
what are these objects? i thought computer languages are written using instruction not objects... please show me the light. peace

C++ is written using instructions, but you can think of these objects as tools. This is fairly advanced for someone who is just learning; usually you try to get the basic syntax and basic data structures down before learning Object Orientated Programming. These objects are data structures. These data structures are data types can can be decomposed into simpler data types. An example of an early data structure is an array, an array can be broken down into the individual elements that occupies it. A more complex data structure that is largely the foundation of OOP, is a class structure.

I highly suggest that for now you forget about the fact that C++ is an object orientated language and focus on learning the syntax and early data types.
 
  • #3
Read this: https://www.physicsforums.com/showthread.php?t=32703

Or if you want something a little more thorough, this is my textbook from my first C++ class:
https://www.amazon.com/dp/0619216778/?tag=pfamazon01-20

This textbook pretty much covers everything you would ever need to know, even though now that I'm in a class that covers object orientated programming we don't use it.
We use this one now:
http://www.amazon.com/dp/0132129485/?tag=pfamazon01-20

I guess that first textbook is good for a pretty general overview of everything, but the second textbook gets into data structures much more deeply.
 
Last edited by a moderator:
  • #4
painterguy said:
can u give me some basic understanding of this oop, please? wut r these objects? i thought computer anguages are written using instruction not objects...

OOP came about when software became so large that it was unmanageable using traditional functional programming. Objects are essentially a way to organize your program and data in a logical manner. Like putting your tools and parts in a nicely organized toolbox, rather than have them lying all over your garage (and never being able to find them).

An object is self-contained with its own constructor/destructor, functions, variables, and even operators. Each of those can be made inaccessible outside the object, which helps prevent bugs: if you accidentally try to access a non-public member, the compiler with say: “nope, can't do that!” You can also derive objects from other objects, which makes them reusable so you don't have to rewrite code over and over.

But on a lower level, C++ (OOP) is not that different from C (non-OOP).
 
  • #5
Try a C++ textbook. You can't expect to learn OOP (or C++ for that matter, if it's your first programming language) in dribs and drabs from web pages scattered all over the Internet.

Bruce Eckels's book "Thinking in C++" is available online for free. I've seen many people recommend it, although I haven't used it myself.
 
  • #6
I'd recommend learning how to program at all before trying to learn object oriented programming. You need to learn to walk before you can run...
 
  • #7
Jocko Homo said:
I'd recommend learning how to program at all before trying to learn object oriented programming. You need to learn to walk before you can run...

Agreed. But it doesn't hurt to be curious.
 
  • #8
  • #10
In 1988 in IEEE Computer Bjarne Stroustrup wrote "What is Object Oriented Programming?", there is a 1991 revision of this on the web if you search for the title in quotes.

Based on the description of the background of the person who posed the question I suspect the article might be a bit too complicated for him yet, so I will take the liberty of simplifying just a bit. The rest of you can breeze through the the paper itself.

He claimed that back in the olden days there was:
Procedural programming, decide what procedures and algorithms to use.

That was fine and then we wanted to write bigger and more complicated programs, so next was:
Data hiding, decide on what modules to use and hide data inside them, use procedural programming to implement these.

That was fine and then we wanted to write bigger and more complicated programs, so next was:
Data abstraction, decide what types and provide operations for these using data hiding.

That was fine and then we wanted to write bigger and more complicated programs, so next was:
Object oriented programming, decide what classes you want and use data abstraction to implement these.

In his paper he gives a lot more detail and describes the problems with each method that led to the next method.

In the 1988 paper he concluded with a statement something like "and these are the problems with Object Oriented programming, today nobody knows what the answers to these problems are, but in ten years someone will have found an answer." I always wondered what that answer turned out to be. The 1991 revision of the paper snipped off that summary and a few other things.
 
  • #11
jtbell said:
Try a C++ textbook. You can't expect to learn OOP (or C++ for that matter, if it's your first programming language) in dribs and drabs from web pages scattered all over the Internet.

Bruce Eckels's book "Thinking in C++" is available online for free. I've seen many people recommend it, although I haven't used it myself.

I second that recommendation. It is a good book that is very thorough.
 
  • #12
KrisOhn said:
Hate to come off a little abrasive, but please make an attempt to use proper English while on the forums, I know that English isn't your first language, but you're not going to get much respect here when you use words like 'wat, r, wud, etc'.

KrisOhn: thanks for the help. i would try my best to use proper full english words in future.
 

1. What is object oriented programming (OOP)?

Object oriented programming (OOP) is a programming paradigm that is based on the concept of objects. It allows for the creation of objects that have data and methods, which can interact with each other to perform tasks. OOP is widely used in software development as it promotes modular and reusable code.

2. What are the principles of object oriented programming?

The principles of object oriented programming include encapsulation, abstraction, inheritance, and polymorphism. Encapsulation refers to the bundling of data and methods within an object, abstraction involves hiding unnecessary details and exposing only essential information, inheritance allows for the creation of new classes based on existing ones, and polymorphism allows objects to take on different forms depending on the context.

3. What are the benefits of using object oriented programming?

Some of the benefits of using object oriented programming include code reusability, modularity, and maintainability. OOP allows for the creation of reusable code components, making it easier to maintain and modify code. It also promotes modularity, which means that different parts of a program can be developed and tested separately, increasing efficiency and reducing errors.

4. What is the difference between a class and an object?

A class is a blueprint or template for creating objects, while an object is an instance of a class. In other words, a class defines the characteristics and behavior of a group of objects, while an object is a specific instance of that class with its own unique data and functionality.

5. How is polymorphism achieved in object oriented programming?

Polymorphism in OOP is achieved through two main mechanisms: method overriding and method overloading. Method overriding allows a subclass to provide its own implementation of a method that is already defined in the superclass, while method overloading involves creating multiple methods with the same name but different parameters. This allows objects to take on different forms and behave differently in different contexts.

Similar threads

  • Programming and Computer Science
Replies
3
Views
985
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
32
Views
5K
  • Programming and Computer Science
Replies
24
Views
3K
  • Programming and Computer Science
Replies
8
Views
993
Replies
4
Views
4K
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
  • Linear and Abstract Algebra
Replies
1
Views
761
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
13
Views
8K
Back
Top