Teen Programmers Unite  
 

 

Return to forum top

what does object orientated mean?

Posted by have_dinner [send private reply] at July 13, 2001, 02:19:14 AM

what does object orientated mean?

i'm really confused here. please help me out

Posted by infryq [send private reply] at July 13, 2001, 10:40:26 AM

object-oriented programming is a way of organizing your code into compact modules called _objects_. Instead of dealing with functions and long strings of complex code, you've just got these objects that you create & destroy and bounce around and talk to eachother. Say you've got an object-oriented room. Insead of running the function turnlighton(); you'd tell the LightSwitch object to do the method TurnOn(); which is what you'd do in a normal situation -- you wouldn't think about forcing electrons through the ittle filament in your light bulb, you'd just flick the switch. Objects have properties and methods. Properties are the variables assigned to each object -- say, lightBulbType for our example, which could be either fluorescent or incandescent. You're supposed to make methods to allow outside code to change an object's properties, that way the object can check to see whether it's been handed the right information, and do any other twiddling it might need to do -- LightSwitch.TurnOn() might check to see if the light bulb's burned out, or whether you thought it was a dimmer switch or something and tried to pass it a "percent on" or some such.
I was taught that OOP was designed to model the way we see the world. It's also a lot easier to do group programming in OOP... you don't really have to know how an object works inside, just what methods you need. Sun's Java tutorial(http://java.sun.com/docs/books/tutorial; head for _Learning_the_Java_Language_) does an okay job of explaining how object-orientedness works; there may be better sources out there. HTH.

Posted by gian [send private reply] at July 13, 2001, 06:35:28 PM

Great analogy :-)

Posted by have_dinner [send private reply] at July 13, 2001, 07:58:11 PM

ok, that was about as much as i needed... how the hell did you write that?? it makes total sense now... thanks heaps... :)

Posted by CHollman82 [send private reply] at October 01, 2001, 09:57:40 PM

Posted by CHollman82 [send private reply] at October 01, 2001, 10:01:02 PM

Posted by Psion [send private reply] at July 14, 2001, 12:25:20 PM

That second explanation was totally unneccessary, having something in common with your C++ tutorial, though perhaps lacking the outright factual errors.

Posted by lordaerom [send private reply] at July 14, 2001, 03:59:01 PM

Objects are simply classes, classes are structures that can have either private or public member functions

Bzzt. Thanks for playing!

Posted by CHollman82 [send private reply] at October 01, 2001, 09:58:04 PM

Posted by lordaerom [send private reply] at July 14, 2001, 11:12:36 PM

Disregarding the fact that public and private are not the only C++ access modifiers, don't go throwing around terms without explaining them. While once you know the meaning, they're understandable, without coupling public/private with a description of what they are, it's a waste. And, then there's how you then perform a disservice to him by shoving a link to your 'C++' tutorial in. Oh well. SmallTalk's OOP is much nicer than C++'s anyways. Of course, that is my opinion! But, if you want to have some fun, check out Squeak.

Posted by CHollman82 [send private reply] at October 01, 2001, 09:58:17 PM

Posted by CHollman82 [send private reply] at October 01, 2001, 09:58:32 PM

Posted by Psion [send private reply] at July 15, 2001, 04:43:27 PM

I said that your explanation of "OO" was unnecessary, because one had already been given. What I said about your tutorial was that it was quite conspicuously error-ridden.

Posted by CHollman82 [send private reply] at October 01, 2001, 09:58:44 PM

Posted by Psion [send private reply] at July 16, 2001, 07:27:41 AM

"the C in C++ stands for class"

Posted by CHollman82 [send private reply] at October 01, 2001, 09:58:57 PM

Posted by triplec1986 [send private reply] at July 16, 2001, 03:10:19 PM

No it isn't true because that would mean C meant class.

Posted by sphinX [send private reply] at July 17, 2001, 12:49:18 AM

C doesn't exactly mean anything does it? I always thought that C was originally a hybrid of COBOL and they just shortened the name...then again, I could have it completely backwards....anyone know the real story?

Posted by Psion [send private reply] at July 17, 2001, 07:56:37 AM

I have read from credible sources that C is named as the successor of the "B" language, the origin of whose name I do not know, save for the fact that it had nothing to do with any "A" language. :-)

Posted by CHollman82 [send private reply] at October 01, 2001, 09:59:10 PM

Posted by lordaerom [send private reply] at July 17, 2001, 09:25:53 PM

The silly use of goto

Posted by CHollman82 [send private reply] at October 01, 2001, 09:59:24 PM

Posted by infryq [send private reply] at July 18, 2001, 01:24:02 AM

C is the successor to B, that's right, and B came from BCPL(basic combined programming language) which was "A programming language developed by Martin Richards in Cambridge in 1967. It is remarkable for its rich syntax, small size of compiler (it can be run in 16k) and extreme portability. It reached break-even point at a very early stage, and was the language in which the original hello world program was written. It has been ported to so many different systems that its creator confesses to having lost count. It has only one data type (a machine word) which can be used as an integer, a character, a floating point number, a pointer, or almost anything else, depending on context."
-the jargon file, www.tuxedo.org/jargon/

Posted by infryq [send private reply] at July 18, 2001, 01:26:01 AM

...incidentally, that's why it's called C... there was some dispute over whether the language to evolve from C would be named D or P, because of B-C-P-L...

Posted by CHollman82 [send private reply] at October 01, 2001, 09:59:37 PM

Posted by have_dinner [send private reply] at July 22, 2001, 06:53:13 PM

strange how a simple post asking what object orientated means turned out to solve the origin of C... that's really interesting stuff guys!!!

Posted by RedX [send private reply] at July 24, 2001, 01:56:15 PM

Threads behave in mysterious ways.

RedX

Posted by spaceleader [send private reply] at July 28, 2001, 11:02:29 PM

WOW! after reading this thread i dont need to go ask my teacher what OOP programming means OR why C is call C!! you guys are good...............i've been through many tuts on the internet and NONE of them have that much info on what OOP REALLY is or where C came from. i'm glad that i read this thread. and btw, you guys argue a WHOLE LOT! every thread i read, i always see u guys argueing!

Posted by eternaldisciple [send private reply] at July 29, 2001, 12:16:10 AM

ya...and orientated isn't a word

Posted by sphinX [send private reply] at July 29, 2001, 12:52:59 AM

sure is:

Orientate \O"ri*en*tate\, v. t. [imp. & p. p. Orientated; p. pr. & vb. n. Orientating.] [From Orient.]

1. To place or turn toward the east; to cause to assume an easterly direction, or to veer eastward.

2. To arrange in order; to dispose or place (a body) so as to show its relation to other bodies, or the relation of its parts among themselves.

A crystal is orientated when placed in its proper position so as to exhibit its symmetry. --E. S. Dana.


Posted by eternaldisciple [send private reply] at July 29, 2001, 01:31:54 PM

Huh, I stand corrected. I've always heard it used oriented, but both are correct. You learn something everyday.

Posted by spaceleader [send private reply] at July 29, 2001, 12:19:58 PM

hmmmm.........interesting....

Posted by buzgub [send private reply] at August 01, 2001, 01:35:13 AM

Getting back to errors with CHollman's tutorial, conio.h is mentioned in tutorial 2. That's not ansi c++ is it?

Posted by lordaerom [send private reply] at August 01, 2001, 03:23:17 PM

But neither is goto!
oh, wait, yes it is!

Posted by RedX [send private reply] at August 01, 2001, 05:01:28 PM

Goto is evil. If you use it 3 times in a program, the big scary codingmonster will come to you and hunt you down and make you eat your program. (very painfull, since the program is on HD and HD is made of something hard)
Those who were caught, were never able to tell others. (mostly because they didn't have much theeth left, HD is bad for them. But they were able to write it down)

RedX

Posted by gian [send private reply] at August 02, 2001, 03:31:16 AM

Goto CAN be useful. Yes, if you structure your program right, they are avoidable... but they can be useful.

Posted by Psion [send private reply] at August 02, 2001, 05:59:46 AM

I just realized that Java alleviates the need for goto's by allowing you to continue/break a specific loop if you label the start of the loop. I know Perl has had this for a while. You could take goto out of C if it had this.

Posted by RedX [send private reply] at August 02, 2001, 02:34:49 PM

Imagine a 10.000 lines C++ file . Image several gotos and labels.
now image you have to debug it. Happy hunting.

Goto is bad programming practice at the same level of naming variables just "a".
Just say no to goto.

RedX

Posted by Psion [send private reply] at August 02, 2001, 02:58:35 PM

RedX, as much as I appreciate your repeating hackneyed dogma, I don't see the purpose of it at this point. goto is needed in C to do things like break out of multiple loops.

Posted by lordaerom [send private reply] at August 02, 2001, 08:12:39 PM

It's not really required, is it? It just makes things 'cleaner'. I could try to illustrate my point, but I am lazy. Yes, No, 'It Depends'?

Posted by Psion [send private reply] at August 02, 2001, 08:30:03 PM

It is required to actually break out of the loop instead of doing something to cause the loop to end later.

Posted by lordaerom [send private reply] at August 02, 2001, 11:28:09 PM

Well, OK, but, by structuring your code properly, could you emulate its functionality without it?

int x = 0;
int y = 0;
bool notDone = true;
while(y == 0 && notDone) {
while(x == 0) {
//relevant interior loop thing.
if(1==1) {
notDone = false;
break;
}
}
//once out here, in case we'd need code below, check notDone.
if(notDone == false)
break;
}
//And we are out!

In function, would be comparable to

int x = 0;
int y = 0;
while(y == 0) {
while(x == 0) {
if(1==1)
goto loopDone;
}
}
loopDone:
//we're out!
With regard strictly to functionality, anyways.


Posted by infryq [send private reply] at August 02, 2001, 11:33:40 PM

but that's an _awful_ lot of extra code if you're several loops thick -- also makes for a lot of extra work and potential for error if you revamp and delete a loop -- you'd only have to remember the 'label' line if you used a goto, but with multiple 'break's you'd have a whole if set to get rid of for every loop down to where the goto would put you.

Posted by lordaerom [send private reply] at August 03, 2001, 12:10:55 AM

Yeah, I'm not saying it's better.
Just that it is not 100% required.

Posted by CHollman82 [send private reply] at October 01, 2001, 09:59:55 PM

Posted by gian [send private reply] at August 03, 2001, 02:05:38 AM

CHollman82: You better buck up your ideas laddy, or you'll find yourself on detention! I don't think you can pass judgment on ther people's code, when your own is no better, you are just trying to pick a fight.

Posted by CHollman82 [send private reply] at October 01, 2001, 10:00:11 PM

Posted by gian [send private reply] at August 03, 2001, 02:22:33 AM

CHollman82: You just edited that... I was referring to your (almost legendary) cpp tutorial code.

Posted by CHollman82 [send private reply] at October 01, 2001, 10:00:26 PM

Posted by lordaerom [send private reply] at August 03, 2001, 03:07:59 AM

Mm, it seems my reply did not actually get posted!

Well then.
First off, my point was purely to ask whether goto was required as a language feature to affect certain behaviours, not which was prettier. But even so, while it may be that this is a trivial example, even here, while has an advantage in that the indentation and braces serve as guides to where control will be transferred, and when.

While your goto version could be structured like this:

RETRY:
<spaces>cout >> "enter a number between 1 and 10";
<spaces>cin << x;
<spaces>if(x<1||x>10){cout << "try again"; getch(); clrscr(); goto RETRY;}

One, perhaps small problem is that pretty-printers wouldn't format this in the same manner. A loop-based variant, however, would look spiffy. And, even if it is a matter of style, I don't think that you would find yours all that popular.

Posted by RedX [send private reply] at August 04, 2001, 02:28:10 PM

"you'd only have to remember the 'label' line" fine if it's one or two goto's.
But what about a hundred or even more. Or if it's to be maintained for a longer period and by multiple programmers? For a 100-line program that's written and used it would work. However if you decide after a year to add something to that program, it will be a lot harder to remember all those goto destinations.
I try to tread every program as if it's going to become a big project, because I've had several programs coming to a point where I had to rewrite most of it because I had written it with those shortcuts.
A good programming style is important. Consistency even more.

If someone knows a good tutorial covering good programming technics, please mention it here. Most programming tutorials don't even mention these.
Or tutorials covering other topics of software ingeneering.

RedX

Posted by CHollman82 [send private reply] at October 01, 2001, 10:00:41 PM

Posted by infryq [send private reply] at August 05, 2001, 01:15:11 AM

CHollman: exactly.
RedX: that's why we document our code( /*these are useful*/ )... and also why you use a text editor with a "search" function, so in the odd event you put some label out in the middle of nowhere and don't tell yourself where it is, you can find it again.
Note: i don't use goto's myself. If i can find a way around them that's not a big hassle, i'll use something else. but saying something absolute, like 'gotos are evil and should not be used under any circumstances', is a bit silly.

Posted by RedX [send private reply] at August 05, 2001, 04:50:31 PM

Well, a wise man or woman once said: "Opions are like asses, everybody has one.". Same goes for programming habbits.
If the rest of the Homo Sapiens Sapiens want to use goto, then I let them. And if this particular opinion happens to be wrong, I'll have to learn to live with it. At least I made a few CS-teachers happy.

RedX

Posted by gian [send private reply] at August 06, 2001, 12:29:58 AM

It actually went: Opinions are like asses, everybody has one, but no-one wants to see yours on TV :-)

Posted by PurpleStorm [send private reply] at September 20, 2001, 01:11:00 AM

It is true, earthchild RedX, each person has his, or her, or its own special opinion as to how the world ought to be, and those opinions must be respected. However, when you work in a team of five people, you all have to be using mutualy intelligiable code, so /*use this alot*/ and be free from petty arguments. You must remember, however, that different programming styles have harder times talking to eachother than similar ones, and hungarian notation looks funny.

Posted by taubz [send private reply] at September 20, 2001, 02:39:00 PM

I often delete posts when they are put onto a thread that's nearly a month old.... Try not to revive (or at least "bolden") dead discussions unless there's a really good reason.

- taubz

Posted by lordaerom [send private reply] at October 01, 2001, 06:32:00 PM

OK, sir, wouldn't want to foster an atmosphere where discussion that's not approved takes place!

Posted by gian [send private reply] at October 01, 2001, 07:04:56 PM

I often delete posts based on my personal dislike of that person... well not often, only when appropriate...

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.