OOP vs NON-OOP

Started by
17 comments, last by Cobra 22 years, 2 months ago
quote:Original post by CGameProgrammer
I use basically pure OOP for my latest project Literally zero global functions (besides WndProc and WinMain of course).


I''ve got you beat! My WndProc is a static class function!

As for "to OO or not to OO", it''s really a matter of taste, both methods can accomplish the same ends. The important thing with object design is doing it effectivly. I''ve seen too much "Object-Oriented" code that was nothing but procedural code with the functions defined on classes instead of globally.



"So crucify the ego, before it''s far too late. To leave behind this place so negative and blind and cynical, and you will come to find that we are all one mind. Capable of all that''s imagined and all conceivable."
- Tool
------------------------------
"There is no reason good should not triumph at least as often as evil. The triumph of anything is a matter of organization. If there are such things as angels, I hope that they're organized along the lines of the mafia." -Kurt Vonnegut
Advertisement
it really depends on the size of the project. if it''s something simple, like just a variation of nehe''s base code (which it isn''t) then C will do. but get anywhere beyond that, and C++ becomes a lot more flexible and powerful... I, and I''m sure many people here, have seen what bad C can do to code... seeing programs where the main cpp is 7000 lines +.

But, obviously, the project is only as good as it''s planning. A well planned C project will always beat a poorly planned C++ project, and the other way around.

I''d say that anything that has potential to get over a total of about 4000 lines should really be written in 100% C++.
a good example, in my opinion, of what a nightmare can come from not doing this, is the Quake2 code.. Yes, the code is fast, and it is obviously well planned, but I just get the feeling that if it was true C++, it would have been half the size, and infinitly easier to read, and given id more time to work on the game.

(just look at how every enemy in Q2 has it''s own unique code, yet, for example, in HL, everything is based from a generic base entity...)

my current app, if it was C, would likly be around 30,000 lines. yet due to the way I''ve built it, it''s around 12,000 at the moment. and everything is independant of each other, so no errors occur with one object effecting another... something that makes debugging A LOT simpler.
In fact, I''d doubt it''d be possible without severly crippling how it works if it were C.
just a quick one, as i am in dire need of breakfast

you say you are targetting machines 2 years from now... well, we all know how ridiculously fast things can change in that time with computers You''re looking at about 2 evolutions of hardware (regarding CPU and graphics cards), so its safe to say things will be kickin pretty hard in two years time. Over that time, compiler technology is also likely to improve.

With that in mind, I think its safe to say that you should really focus on clean and well-structured design, and make the move to OO, as it really is a boon for handling complexity. The performance difference between C and C++ is infinitesmally small (compilers are improving)... it all really hinges on the quality of your design... a well designed and implemented OO system will kick seven shades of shit out of a badly written old-school one.

And as many have said before me, you will probably find it much easier to design and manage a large project (such as a game engine) using an OO approach.
OOP is dead, use Aspect Oriented Programming and Design. Te way of the future.

(AspectJ)


http://www.CornflakeZone.com
//-- Modelling and animation in every dimension --//
Thx for all your input guys. I''ve made a decision in what I''m going to do.

Firstly.. im gonna work for another week or so on the engine without changing anything.
Then... i''m going to rewrite it all in OOP.
It should prove to be a fair ol'' challenge, and will hopefully reap some nice consequences, even if it is just cleaner code.

Thx for all the replies. :D

*runs off to code like a maniac*

~Cobra~
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
Wat''s Aspect Oriented Programming and Design ?
"THE INFORMATION CONTAINED IN THIS REPORT IS CLASSIFIED; DO NOT GO TO FOX NEWS TO READ OR OBTAIN A COPY." , the pentagon
WayfarerX : You have 0 global variables. What about things like EPSILON and PI...?
Any tips how to get rid of global functions like optimized sin/cos/sqrt.. I realy hate global functions but I don''t know what else to do...

There are more worlds than the one that you hold in your hand...
You should never let your fears become the boundaries of your dreams.
quote:Original post by _DarkWIng_
WayfarerX : You have 0 global variables. What about things like EPSILON and PI...?

Those arent variables. They are constants.
quote:
Any tips how to get rid of global functions like optimized sin/cos/sqrt.. I realy hate global functions but I don''t know what else to do...

You can make them static methods of a class. In certain languages(C#/Java), you have to do this, since they dont support freestanding functions. In languages like C++ its more a matter of taste. It has no impacts on performance whatsoever.




Once there was a time when all people believed in God and the church ruled. This time is called the Dark Ages.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
It''s the successor to OOP, http://aosd.net/ for more info.

-fs

http://www.CornflakeZone.com
//-- Modelling and animation in every dimension --//

This topic is closed to new replies.

Advertisement