Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Question for OOP disciples

Author
Message
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 8th Oct 2003 04:06
Just out of interest, what is in your opinion the most important part/the greatest advantage of OOP?
Imagine a light-weight-OOP language like JavaScript, what OOP stuff would you want see in there?

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
DrakeX
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location:
Posted: 8th Oct 2003 05:54
ummm there is none.

at least not as far as i can see.

TYPEs are about as OOP as i need it. beyond that, most of it is useless. i could care less about member functions, inheritance, and polymorphism. i've never used them and they can always be achieved with simpler methods.

stop looking at me!
QuothTheRaven
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 8th Oct 2003 06:31
no advantage

just slightly more organized

but stricter as well

empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 8th Oct 2003 15:44 Edited at: 8th Oct 2003 15:44
Thanks guys.

And what about event handling.
Let's say you have a button, would you want to check "manually" whether the user clicked that button , ie in your own procedure, or, if the button was an object, would you prefer "automatic" event handling?

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 8th Oct 2003 15:49
Empty:
As drake said.

I have no problem coding my own button procedure, I have done so more then once. DBP could get mouse to sprite commands if enough ppl asks about them.

kingius
21
Years of Service
User Offline
Joined: 16th Oct 2002
Location:
Posted: 8th Oct 2003 16:41
Code re-use, structured programming, code readability and the storing of data that makes sense in the context that it is being used are all advantages of OOP.
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 8th Oct 2003 17:31
Kingius:
I could say the same about non OOP, exept for code reuse. However you can reuse a lot of non OOP code as well if you program wisely.

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 8th Oct 2003 17:40
Classes, inheritance, structures, events, threads, delegates....
the list could go on forever

-RUST-
kingius
21
Years of Service
User Offline
Joined: 16th Oct 2002
Location:
Posted: 8th Oct 2003 17:49 Edited at: 8th Oct 2003 17:55
Dead Glory- Youd be wrong, because data stored in a non-OOP format does not bare any resemblence to the way the data is modelled in real life. Let me try to explain.

In a non-OOP language, when trying to program a roleplay game, you may use an array to store a characters attributes such as strength, hit points and so on. This is a good way to store related data together.

In an OOP language, however, you would approach the problem by storing the data in an object. Lets call this object objCharacter. objCharacter has exactly the same data stored in it as the array in the non-OOP example, so this might not seem like a big deal. However, lets talk about a scenario where it is.

Imagine if you wanted to create a new monster in your game, and it had additional attributes to store that would be a waste of memory to put into the array for characters that it didnt apply to. For example, you may wish to store special attack data. In the OOP model, you create a new object that inherits from objCharacter and expands on the data that is stored there with its own properties, but because it inherits from the base class, it has every property of the base class too.

Whats the advantage of this? You arent wasting memory storing redundant, not applicabale data for one thing, and also if you change something in your base class then the change propagates through your inherited class(es) too, automatically.

What other advantages does modelling data through objects bring? Methods. Methods are functions that are part of the object. You cant call the method without going through the object, they are not globally available in your program like regular functions, and they apply to that object only. So, for example, you may have a function in the objCharacter object called Attack. Attack cannot be called without referencing the object that you wish to call it with, so it helps stop some bugs appearing before they happen (the idea is, that you already know which character you want to be attacking with because you can only do it through a character, see?)

Lastly, the other advantage I can think of off the top of my head is reusability. You can create as many instances of objCharacter as you want and the data associated with each instance is completely seperate. So every objCharacter you declare has his own hitpoints, etc, as soon as the object is substantiated. Also, when destroying the object, you can be assured that there is no residule data still lying around in a variable somewhere, since all variables were part of the object!

Cool huh
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 8th Oct 2003 18:48
Kingius:
I see nothing I can't do in DBP already in different ways. Simply put it: I have no use att all for OOP so I would never bother to learn it. It just makes things more confusing.

empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 8th Oct 2003 19:01
@DG:
Quote: "I see nothing I can't do in DBP already in different ways. Simply put it: I have no use att all for OOP so I would never bother to learn it. It just makes things more confusing."

So why did you post here when the title says "Question for OOP disciples? Nah, just kidding, I'm interested in everyone's opinion. So thanks alot for yours.

@CattleRustler & @kingius:
Thanks for your input. What do you think would a light-weight OOP language essentially need?

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
kingius
21
Years of Service
User Offline
Joined: 16th Oct 2002
Location:
Posted: 8th Oct 2003 19:10
Dead Glory - The more you get into OOP the more you realise its beauty. Objects are data and code, self contained! OOP is about modelling the problem in terms of the problem as it exists and not in terms of the constraints of the underlying machine.
heartbone
21
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 8th Oct 2003 19:20 Edited at: 8th Oct 2003 19:30
kingius OK, but if you actually want to create functional software in a reasonable time with limited resources that is unique,
you still need to get your hands dirty with real programming.
C/ASSEMBLER/BASIC/FORTRAN/PASCAL(Delphi)

Look at the base code in your object classes... procedures!

Look man, all that you are doing when programming is flipping switches.

If you work for some big mega coporation then you can afford the time to conceptualize a large project on a OOP basis. But the rest of us need to get something done and move on.

In general OOP is for small drone clone programs.

As an engineer I think that it is unsuitable for large projects. Accounts receivable yes, a basic compiler yes ( if you have several years ) , a CAD system yes if you have 10 years.

Look at the CATIA v4 to v5 port. Procedural (FORTRAN) to OO (C++). CATIA is the Microsoft of CAD. It was supposed to be prodution ready in 1995. It is just now going into true production. Who can afford that! There is nothing beautiful in that.

The more you see, the more you know.
The more you know, the more you see.
kingius
21
Years of Service
User Offline
Joined: 16th Oct 2002
Location:
Posted: 8th Oct 2003 19:35 Edited at: 8th Oct 2003 19:37
Real programming involves objects, heartbone. The Windows API is a bunch of objects, DirectX is a bunch of objects.... etc!

As for building in a reasonable time frame, what is the greatest Rapid Application Development software in the world? VB... and guess what VB is? OOP! Its much faster to leverage the work of others through OOP than any other way, the more complex the work the quicker it can be implemented through OOP methodologies.

Classes are built on functions and basic data types as you have pointed out. OOP builds on basic function programming and allows you to do far more, far quicker and in a way that makes sense to other coders who work on the same project too. Objects represent the higher order of programming, because they consist of both dataand code encapsulated.
Martyn Pittuck
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 8th Oct 2003 19:52
I use OOP in PHP, it is much easier to debug code where there is code like:

$a = new thing();
$a -> shoot_the_messenger();



Also reusing code is much easier, i mainly use function libaries becasue i can very easily implement my code libary into my sites. I even have my function highlighted as generic PHP functions/

Web Design Starting from $200. Special limited offer. MSN or Email me for more information.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 8th Oct 2003 19:56 Edited at: 8th Oct 2003 19:58
@Kingius - where have you been? I love you!

@DeadGlory - Yes it is more confusing. When I started in VB I was hating all this object crap and was becoming lost - just wanting my old school procedural basic coding back but with the ability to make windows programs -- but after lots of hard work and changing my shallow thinking to a deeper level (the bigger picture) I finally realized how powerful OOP really is and how I ever got by without it! This is not to say there aren't genius programmers out there in procedural, and yes technically you can do just about anything in proc that you could in say VB6, but all in all Kingius sums it up best when he says
Quote: "OOP is about modelling the problem in terms of the problem as it exists and not in terms of the constraints of the underlying machine"


Just MHO

EDIT: Also, just to clarify vb6 was about 95% OOP IMHO, and VB.NET is about 99.5% OOP, C++/C# are 100% OOP.

-RUST-
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 8th Oct 2003 20:02
not to mention I think having known OOP prior to DBP, OOP has made me a better DBP coder. I find I have very little inline code and tons of broken-out reusable subs and functions in my programs - just MO

-RUST-
AM_
20
Years of Service
User Offline
Joined: 5th Oct 2003
Location:
Posted: 8th Oct 2003 20:03
Quote: "Real programming involves objects, heartbone. The Windows API is a bunch of objects, DirectX is a bunch of objects.... etc!"

Now, I for one definately love OO programming with classes etc. But mainly for ease of use, reusability and structural reasons - it has nothing to do with being more real programming. Windows API and DX just use objects to make them easier for you to use.

Dig deeper down and mess with assembler or machine code and there aren't any fancy objects; there aren't even functions or proper loops - it's just basic maths, data copying/movement and jumps.

I do not however quite agree with heartbone about OOP being less good for larger projects. IMHO OOP helps the reusability of your code and makes it easier to keep things structured properly, two things I definately want in a large coding project.
kingius
21
Years of Service
User Offline
Joined: 16th Oct 2002
Location:
Posted: 8th Oct 2003 20:13 Edited at: 8th Oct 2003 20:20
Define "Real Programming"?

If you want to do any programming at all, you have to link to external objects. Even if you think you dont, its because your development tool is doing it for you in the background. E.g. DarkBASIC links to the DirectX API in its source code. I cant think of any programs that dont leverage the code of other people, through objects - except at the embedded level.

OOP is everywhere

PS CattleRustler - If you were female I might say - Maybe we should get together and make beautiful objects just kidding!
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 8th Oct 2003 20:45
I only use OOP to the extent of UDT and member functions

c:/dos
c:/dos run
run dos run
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 8th Oct 2003 20:51
Kingius



-RUST-
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 8th Oct 2003 21:02
Empty:
I don't know what disciples mean so I didn't bother with the topic =)

Kingius:
I don't understand what you're saying =) Real programming starts when you have bolean statements. The program do things differently depending on the data. HTML for example is not a programming language as it have no way of controlling the flow through the code.

Cattle:
I'm a game designer first and then a programmer. If I can make my games work in a simple way I chose to make them that way. Not having to bother about how good programmer I am means I can spend my time on design instead.

Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 8th Oct 2003 21:41
Kingius

"the more complex the work the quicker it can be implemented through OOP methodologies."

Ok, call me curious , but it'd be nice to have some involved examples to back these type of statements up. The above example is far to trivial to show off any real benefits. The problem most of us procedural dinosaurs have, is our extensive previous experience in procedural languages. In some cases a few decades worth. Whenever OOP is suggested however, it seems that OO people like to talk in 'conceptual' jargon, rather than practical examples to demonstrate advanced functionality over procedural model. The result, the point being raised is lost.



" Lastly, the other advantage I can think of off the top of my head is reusability."

Well, that depends upon the user/language really. If more people designed code in the from of an abstraction layer. Then It's not really a big issue. But, sadly so many hard code everything.

Kevin Picone
Play Basic - Visible Worlds - Kyruss II
[url]www.underwaredesign.com[/url]
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th Oct 2003 22:24
Turning a bit religious in here ...

Personally, I think that any programming language that forces you to work its way and no other is a language waiting to die ... which is why I like C++.

OO stuff I use:
Inheritance ... hardly ever.
Multiple inheritance ... never (except see below)
Resource control ... all the time.
General object use ... mostly from existing libraries, and only when it simplifies the task do I create my own classes.

Actually, one of the more powerful paradigms just coming to the forefront ATM is generic programming ... templates. When you combine it with traditional OO and multiple inheritance it can blow your socks off with its flexibility and power.

Just to answer one of the arguments placed in favour of OO ... I find that designing and creating reusable objects correctly takes longer than the equivalent procedural code, but (and it's a big 'but' IMO) the code will be far more tolerant and stable.
Yian
21
Years of Service
User Offline
Joined: 16th Jun 2003
Location: Nicosia, Cyprus(the Greek half)
Posted: 8th Oct 2003 22:36
huh...call this a flamebait?

Jeriko The Slyz,Yian The Craft,The Mechanist,The Lost One,Master Of Dots,Bambos O Bellos,Zolos O Kolos
Eddie Gordo
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 8th Oct 2003 22:47
Object Oriented Programming...is that what OOP means...well i like EPIC better...heh heh heh...my own creation and style of programming...but yeah OOP is pretty cool it takes complex parts of programming and adds order to chaos, which is really needed for some languages.

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 8th Oct 2003 23:00 Edited at: 8th Oct 2003 23:00
Thanks for all your opinions so far. Some interesting points there.
Although I'm not sure why this is labeled a flamebait now, but everyone else, post your opinion here (and please, answer one or more of my questions ).

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 8th Oct 2003 23:53
@DG

I don't know why this was directed to me specifically...
Quote: "Cattle:
I'm a game designer first and then a programmer. If I can make my games work in a simple way I chose to make them that way. Not having to bother about how good programmer I am means I can spend my time on design instead."


I agree! I have learned from much turmoil and reworking that overall Design (Games or any kind of program) is 99% of the battle. With a great design, well thought out, structured, and planned you need not be the worlds greatest programmer to write the worlds greatest program - DESIGN is the most important, followed by efficient solid coding practices - so I agree with you totally. I don't know where I implied design was unimportant. Anyway I just prefer the OO way of doing things. Now what was this thread about again...

-RUST-
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 9th Oct 2003 00:56
UW:
Couldn't agree more =) Actually reminds me of the swedish EMU debate (we woted no).

Cattle:
"but after lots of hard work and changing my shallow thinking to a deeper level"

I don't wanna go through lots of hard work to learn something I find no use in when I can just design the game and code it =) I lern myself on need to know basis. I don't need OO so I won't lern it.

DrakeX
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location:
Posted: 9th Oct 2003 01:28
i think there is a right way to use OOP and a wrong way to use it.

one: i see no point in member functions. what's the difference between a function that's part of a class and a function that can only accept paramters of that class?

a.Print()
Print(a)

same functionality, it's just a different way of writing it.

two: why must overzealous C++ programmers think that they *MUST* use classes wherever possible? how is encapsulating your entire program in a class going to help you? if your code is not going to be reused in anything else, or if you're making something that can't really be reused at all, why put it in a class?

three: what use is inheritance? i can see where it might be useful in some cases, but let me rephrase it: why does inheritance have to be so damn complicated? why do there have to be virtual functions? why does there have to be private and public inheritance? i have yet to find good explanations for these things!

stop looking at me!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Oct 2003 01:39 Edited at: 9th Oct 2003 01:40
one: Hooray for you. Functions that operate on objects *are* a part of the objects interface.

two: Hooray again. Pick and choose the best for the job I say

three: it does have one or two uses...

Virtual functions are just a part of the C++ way of doing things and are not a part of inheritance per se.
The different types of inheritance are for stopping those who would bypass the encapsulation of the objects. Objects are supposed to be 'black box'.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Oct 2003 02:45
@DG
Quote: ""but after lots of hard work and changing my shallow thinking to a deeper level""


This was not intended as a slam, I was trying to say that I had to change my way of thinking if I was going to wrap my head around OOP, that's all. Once I grasped OOP, I had to change how I thought of design process as well - just a different way of doing things. Using a different tool causes you to rethink how you are going to go about performing the task.

Anyhow for those who like and embrace OOP, good for you. For those who don't, good for you too. I would just be sad if someone who didn't try oop for whatever reason, years later realized that this "great" thing was at their finger tips but didn't give it a chance

To each his own

-RUST-
heartbone
21
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 9th Oct 2003 02:50
CattleRustler: ...not to mention I think having known OOP prior to DBP, OOP has made me a better DBP coder.

Any previous exposure to any programming would subseqently make you a better programmer. Nothing special about OOP there.

kingius: Define "Real Programming"?
If you want to do any programming at all, you have to link to external objects....


Those objects are all data. There is nothing there but the API. Your objects are all bits, millions of switches.

Real Programming is accomplished by real programmers. Some real programmers do use Object Oriented programming when practical and efficient. Look at Python for the way to do OOP right.

The more you see, the more you know.
The more you know, the more you see.
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 9th Oct 2003 03:16
Quote: "Look at Python for the way to do OOP right."

Very interesting. Kind of a light-weight implementation I had in mind.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Oct 2003 04:27 Edited at: 9th Oct 2003 04:30
@Heartbone

If you're going to quote me, quote me correctly...
Quote: "not to mention I think having known OOP prior to DBP, OOP has made me a better DBP coder. I find I have very little inline code and tons of broken-out reusable subs and functions in my programs"


and include the most important part
Quote: "just MO"


I didn't realize I had to qualify my personal opinions about MYSELF with you

-RUST-
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 9th Oct 2003 06:25
Cattle:
And I was trying to say that instead of using my time learning a new way of programming I can just program the way I do and make games instead =) No need to learn a different way to do things if the way you do them makes them how you want them. "Don't fix what's not broke"

kingius
21
Years of Service
User Offline
Joined: 16th Oct 2002
Location:
Posted: 9th Oct 2003 10:44 Edited at: 9th Oct 2003 12:21
It would seem some more explanation is required, perhaps from a different angle.

Objects in OOP are about sandboxing. The data that belongs to the object and the code that operates on the data are stored together inside the object. The data is not global, you have to create an instance of the object and that object has its own data seperate from any other instance of the same object. The object has an initialisation procedure and a cleanup procedure for when the object is destroyed, and also the data within an object can have default values.

Why is this sandboxing any kind of advantage? Typically procedural code is a speghetti mess of functions and global variables. The bigger a project gets the harder it is to follow the code and work out what is going on. Objects, being self contained, bring organisation, simplicity and convenience to programming that not only helps keep the code readable and the program understandable, it also makes the program more accurately reflect the problem being modelled.


In response to this :
Quote: "a.Print()
Print(a)"


This makes sense when you want to provide context. E.g.

Screen.Print("Hello")
DirectDrawSurface.Print("Hello")
Printer.Print("Hello")

The example objects above would have their own properties associated with them too, not just the one method, of course. E.g. the Printer object could have DPI and Paper Type. Etc.
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 9th Oct 2003 18:43
Kingius:
"Typically procedural code is a speghetti mess of functions and global variables. The bigger a project gets the harder it is to follow the code and work out what is going on."

This depends on the programmer. The more experienced I get the more structured my code gets.

"keep the code readable and the program understandable"

Procedural code is more readable since it looks more like english while OO code is something you have to get used to. Making the program understandable is again up to the programmer. And depending on what style you are used to read the more or less understandable it gets.

I personally have problems coding in VB. That's why I chose PHP for my site even though I hate the ; after every command.

kingius
21
Years of Service
User Offline
Joined: 16th Oct 2002
Location:
Posted: 9th Oct 2003 19:12
"The more experienced I get the more structured my code gets"

You will eventually end up in OOP land then, because OOP is the higher order of structured programming.
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 9th Oct 2003 22:56
I can't end up with OO without wanting to learn it.

heartbone
21
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 9th Oct 2003 23:17
kingius: Why is this sandboxing any kind of advantage? Typically procedural code is a speghetti mess of functions and global variables. The bigger a project gets the harder it is to follow the code and work out what is going on. Objects, being self contained, bring organisation, simplicity and convenience to programming that not only helps keep the code readable and the program understandable, it also makes the program more accurately reflect the problem being modelled.

You sound like a computer scientist. I'm sure that after enough classes you actually believe what you typed. To each his own. If you are smart enough to effectively code OOP (I'm not), then more power to you.

Personally I don't like depending on a lot of other assistgance to get my job done. That's the power and beauty of DarkBASIC.

The more you see, the more you know.
The more you know, the more you see.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Oct 2003 23:30
if you can program in procedural you will THRIVE in OOP - that's the point!

-RUST-
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 9th Oct 2003 23:51 Edited at: 9th Oct 2003 23:52
Ian:

Quote: " Turning a bit religious in here ... "


Not at all. I dunno about other users, but coming form an assembly background, I've limited experience with oop. So It'd be interesting to hear/see some of these benefits layed out in real detail, by those who are proficient in it. Rather than just more 'dust jacket' jargon.


Quote: " Personally, I think that any programming language that forces you to work its way and no other is a language waiting to die ... which is why I like C++. "


erm, Have you seen basic ?

Kevin Picone
Play Basic - Visible Worlds - Kyruss II
[url]www.underwaredesign.com[/url]
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 10th Oct 2003 00:20 Edited at: 10th Oct 2003 00:21
Ideally (to me at least) a language should support both approaches PLUS (and that's the important point) allow easy code/source-lib sharing no matter what method the user prefers. So if the author wrote the lib in OOP, the user should be able to work with it procedural and vice versa.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 10th Oct 2003 01:23
Empty:

Agreed.. Although It's certainly been difficult building enough flexibility for 'stand alone' libraries in PB. It's not quite there yet .

It does make me wonder if taking some structural ideas from classes, would be in order/beneficial to promote more 'structured' code libraries. Mainly public/private (data/functions), and a more rigid definition of the library. Not to consider the library an object however... but anyway, that's a bit off topic

Kevin Picone
Play Basic - Visible Worlds - Kyruss II
[url]www.underwaredesign.com[/url]
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 10th Oct 2003 01:39 Edited at: 10th Oct 2003 02:30
Quote: "Agreed.. Although It's certainly been difficult building enough flexibility for 'stand alone' libraries in PB. It's not quite there yet . "

Yeah, but 'stand-alone' libs will certainly help to create a bigger code-base for Play.


Quote: " that's a bit off topic"

Well, compared to some other posts... not really
It's not easy to combine the benefits of the two methods. I've been thinking about this now for quite some months. I'm working on a basic concept of one of an idea, though.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Sonic
22
Years of Service
User Offline
Joined: 10th Sep 2002
Location: UK
Posted: 10th Oct 2003 02:14 Edited at: 10th Oct 2003 02:39
IMO anything, ANYTHING you can do in OOP you can do procedureally.

However, for me, OOP comes into its own on larger projects. I definately agree with those who would question its use on small programs unless they were intended as the building blocks for classes that would be used in larger programs.

To build big you really need structure & code re-use.

In gaming terms, and to give a practical example one might think of something like a Sprite "object".

It would be defined to have certain "properties" or "member variables" including the bitmap that represents it.

It would probably have Position coords, Velocities, a Collision bounding box rectangle etc. It might also have its own Update() and Draw() methods where it could be programmed to display itself on a given (or global) device/surface/whatever. You would build your sprite bit by bit, testing each aspect as you go.

You have this working class now and you're writing a new (bigger) game but you need more functionality in your sprite, say the ability to animate the bitmap image or/and calcule the collision bounds in different way.

A procedural approach might be to go back to the original (working) code and tinker with it, possibly breaking something else down the chain. Or, worse, a copy might be made of the original functions and THEN tinkered with to add the new functionality. As soon as you do this you'll lose control.

In OOP you would just subclasss your (working) sprite class and Add new "properties" & methods or "Override" existing ones. Thus you get the best of both worlds - you have a codebase you can depend on, but it's not "ring fenced" you can still subclass and create new types of Sprite to extend and enhance the abilities of the object.

Much later you discover a bug in the code of your base Sprite class. This bug once discovered has been seen in all the games you've used your Sprite or subclasses of it. With OOP you can be confident that if you change the code in just one place, and test just one Sprite object successfully that all other sprites will inherit this bug fix. This saves you time both in fixing the bug and in testing the fix.

So, one might think of the ancient "Lucy" as an Abstract Data Type, or rather the first instance of an ADT, which with each generation was subclassed down the generations to us, all being subclasses of the original (working) version (but different and unique). If some subclasses had bugs in where they had overridden methods of the original to do things their own sweet way, then natural selection saw them off. Only the Subclasses that improved on the original design would flourish lol

"My ignorance amuses me..."
http://www.victory-road.co.uk
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Oct 2003 03:07
Quote: "Turning a bit religious in here "

@uwdesign, I stand by that statement ... we are discussing programming style preferences, not absolute Truth. This is therefore one of those 'religeous' issues that anyone can have a valid but conflicting opinion about

Quote: "IMO anything, ANYTHING you can do in OOP you can do procedureally"

Absolutely ... up to and including the equivalent of subclassing and overriding methods (been there, done it using C).

The problems that you point out with procedural code can and do happen with oop code too. Also, the single bug fix to fix all children classes is too simplistic. You *can* break existing subclasses by changing the superclass (even if you think you are fixing the code). You cannot be sure that you have not done so without testing all the subclasses.

This is one of the myths of oop coding. Fix it once and it's fixed everywhere ... but what about the code that in all innocence depended on that broken functionality?

Now don't get me wrong, I like oop, but it ain't the cure-all that it was originally touted to be. My own C++ code is a mixture - I will put together objects for major parts of the system where appropriate, but I have not written one program that is entirely OO - I code in a way that seems appropriate to the task at hand
DrakeX
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location:
Posted: 10th Oct 2003 08:00
"Typically procedural code is a speghetti mess of functions and global variables"

as opposed to a program-in-a-class where you have "global" member variables and nothing but functions?

"The example objects above would have their own properties associated with them too, not just the one method, of course."

true, true. however to me personally, having three classes with three identical procedure names seems a little confusing in the first place. i'd probably opt for three individual names, like PrintToScreen, PrintToDDS, and PrintToPrinter. but that's just me

"OOP is the higher order of structured programming"

doesn't necessarily make it better.. people seemed to get by just fine with non-structured assembly for a long time! not to mention C did pretty well for having data structures really no more advanced than DBP's TYPEs.

"if you can program in procedural you will THRIVE in OOP"

i don't thrive in it. but again, that's just me

stop looking at me!
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 10th Oct 2003 19:25
Ian:

Well the way this is going you'd think were all seeking 'spiritual enlighten' here. Not seeking absolute truth. Just opinion / pearls of wisdom. Sure beats learning the hard way

So to re-reiterate. What I and many others (I'd assume) would be interested in, is more clarification of those 'instances' where oo abilities become the more logical solution, from those who are skilled at this model. Yep, anybody can wack together some classes, but that doesn't necessity make them a proficient solutions.

In your previous reply, you stated that your C/C++ projects are mix of approaches. Which is the point I'm most interested in. So what types of things would you use oo model for, or why not use it ?.

Kevin Picone
Play Basic - Visible Worlds - Kyruss II
[url]www.underwaredesign.com[/url]

Login to post a reply

Server time is: 2024-09-20 18:35:24
Your offset time is: 2024-09-20 18:35:24