0

I've been reading about object oriented concepts, and I'm getting really lost. Conceptually, all I understand is that a method "does" something and that a class is a "blueprint". I've read all the analogies, but the only thing that really makes sense to me so far is: Loops,if then, variable assignments, primitive data types, and the basic syntax.

To me, a program is a program is a program. You type in instructions, and the computer executes. I guess I don't really see big picture.

Nathvi
  • 196
  • 1
  • 6
  • 14
  • 1
    takes experience! i understand u, but no worries.. you'll get it as u go forward – Caffeinated Feb 05 '13 at 17:47
  • 2
    What is your question? – smk Feb 05 '13 at 17:48
  • 1
    It is hard to see the big picture until you've programmed a bit. I'd suggest largely forgetting about OOP for awhile, until you "get" the general idea of imperative programming. Then it will begin to make more sense. – Hot Licks Feb 05 '13 at 17:48
  • Please see the [Object-Oriented Programming Concepts](http://docs.oracle.com/javase/tutorial/java/concepts/index.html) Java tutorial. – mre Feb 05 '13 at 17:48
  • Well, it took me about a 3 months... to get the whole picture about object oriented programming. Keep up learning. – Mordechai Feb 05 '13 at 17:50
  • And, in a weird way, it is probably easier to get a sense of what an "object" is with C vs Java, since in C (not necessarily C++) you are directly confronted with the distinction between values and pointers. – Hot Licks Feb 05 '13 at 17:50
  • 2
    @MouseEvent - 3 months?? I'd think maybe 3 years at best. – Hot Licks Feb 05 '13 at 17:50
  • @HotLicks impossible to drop OOP, everything in Java is objects. Hard to get any use of Java standard classes. – Mordechai Feb 05 '13 at 17:52
  • The definitive explanation: http://stackoverflow.com/a/154939/300257 – Gilbert Le Blanc Feb 05 '13 at 17:55
  • 1
    @MouseEvent -- That's true, one of the negative factors of learning from scratch with Java. – Hot Licks Feb 05 '13 at 17:59
  • abstraction ... a9n .. a*n .. a* – Caffeinated Feb 05 '13 at 18:06

2 Answers2

1

The biggest part of OOP from a sky view, is organization and code reuse. You want to organize 'objects' that do a particular thing and you want to be able to reuse that for other applications as well. This idea just makes it easier to maintain what you are doing and where the information is and how it is all working together. This is very broad so let me know what you are truly not understanding.

Bundling code into individual software objects provides a number of benefits, including:

Modularity: The source code for an object can be written and maintained independently of the source code for other objects. Once created, an object can be easily passed around inside the system.
Information-hiding: By interacting only with an object's methods, the details of its internal implementation remain hidden from the outside world.
Code re-use: If an object already exists (perhaps written by another software developer), you can use that object in your program. This allows specialists to implement/test/debug complex, task-specific objects, which you can then trust to run in your own code.
Pluggability and debugging ease: If a particular object turns out to be problematic, you can simply remove it from your application and plug in a different object as its replacement. This is analogous to fixing mechanical problems in the real world. If a bolt breaks, you replace it, not the entire machine.
Jane Doh
  • 2,883
  • 3
  • 15
  • 17
  • code reuse... but can't you do that in any language? Just define a custom function and then call it later? – Nathvi Feb 05 '13 at 21:43
  • I guess I'm having trouble seeing why a simple print command cant be something like print "hi", like in python. rather than System.out.printf("hi"). Its just appears more convoluted than it needs to be, unless I'm missing something about the benefits of using super verbose syntax. – Nathvi Feb 05 '13 at 21:52
  • from what I understand, the "System.out.print("Hi") " is listing dependencies for the method .print or .printf or whatever. it just seams really stupid. – Nathvi Feb 05 '13 at 21:58
  • 1
    It may seem that some of the basic needs from the language require more than necessary. But at a bigger level (especially enterprise) you will be working with thousands of classes. So there needs to be some organization and ease of use at this level. Check out : http://docs.oracle.com/javase/tutorial/java/concepts/index.html – Jane Doh Feb 05 '13 at 22:42
0

Unless you want to understand programming in an OO language, I'd say you don't need to understand "OO concepts". To someone who runs a program, provides inputs and looks at outputs, etc., it is not at all necessary to understand them. Some years back, US automobiles changed from being mostly carburetors to fuel-injection; in general, drivers of the cars didn't need to understand either one, nor that their new car had one and not the other. This is similar. Now, if you want to understand how to program in such a language, that's different, but in that case you should ask us a more specific question.

--

Based on your comment that you do want to understand the programming, I'll expand on this.

The difference as I see it is that OO languages such as Java facilitate the organization of a program by having programming constructs to represent things (or "items" or "objects") in your problem. Although you can represent things in older languages, you have to create the constructs for doing it yourself (which is how C++ got started).

So, if I'm creating a traffic control system, I can create a class for "vehicle" and subclasses for different kinds of vehicles, with different characteristics and/or behavior. Class definition and inheritance to make this easy are built-in.

I can define a Vehicle class and extend it for PassengerCar, PanelTruck, SemiRig, and other things that make sense in my problem domain. Characteristics and code for all vehicles fit logically with the superclass; characteristics and code specific to each specific type go with its subclass.

I CAN do a similar thing in in C, or FORTRAN, or assembler, by creating data structures and associating code with them, organizing them into groups to represent vehicles of different types, but the languages don't have built-in constructs to make it easy to do.

An additional and related fundamental difference is the language's definition of data and code in one unit. Again, I can do it in other languages, but OO languages have the association as part of the langauge and save me having to create naming conventions or whatever to do it myself.

arcy
  • 12,845
  • 12
  • 58
  • 103
  • I do want to understand programming in an OO language. Specifically Java. I have programmed in Java, and understand the syntax. But when people start using words like "objects" I get confused. I just think, "If I input in this code, I will get this output". I guess I'm not sure how the main paradigm of OO programming is so much different than running a set of instructions, and I feel like I keep getting the run around by people who like to hide behind terminology rather than give me a straight answer. – Nathvi Feb 05 '13 at 21:48