Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

matias suarez

Is OOP the right one for game development?

This topic is 5472 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

One very important point I''d like to make.

Why is it that OOP has to always be represented as a class? I mean, sure, in UML, of course we do so. But in an implementation - in C++, that is - a class is not always necessary.

For example, consider a "renderer" class, which could be considered a singleton. We could make a class, CRenderer in files CRenderer.h, CRenderer.cpp ... But I propose (and this is my style of coding), to rather code the renderer, in the case of a singleton, using "C" style. That is, files renderer.h and renderer.cpp - you can of course hide implementation in this method, such that head files reveal all that is usable. Then you don''t have to worry about the Singleton design pattern either ...

What''s so wrong with that? Is that not "using" OOP?

- Ben

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by carb
What's so wrong with that? Is that not "using" OOP?


What you described is also OOP (imo), but classes have some big advantages so it's usually better to use classes.

Well, object-oriented design isn't limited to code either. It can be used for practically anything.

[edited by - Erkki on October 22, 2003 5:31:58 PM]

Share this post


Link to post
Share on other sites
carb, I think that was called modular programming which came after structured programming and before c++ compilers became efficient. The idea was to mark worker functions in .c file as static to hide them(no globals). Singleton is nice because you can put data there as well otherwise you would have to wrap data in namespaces to prevent global space pollution. But then we got a whole object anyways so better to make it a singleton from the start. Bottom line is that OO can be used on small and large projects and looks much better than C ie. structured way. I wrote some C in OO style but it was clunky:

Person bob;
Person_SayName(&bob);

rather than:

bob.SayName();

The above is cleaner and takes less typing. The other advantage is the categorical nature of classes. It''s a recursive approach so you can have object of objects of objects. Methods are also included in that. Also, it''s manageable in the IDE''s class viewer.

It''s kind of funny but if you take out the modular C approach and use structural programming then you will cringe in horror. There is no going back once you''ve gained OO knowledge. SP is too spread out, not cohesive. It''s like looking at the trees and not seeing forest. We''ve basically gained design facility in C++ which was lacking in C so now we have a design and implementation layer. Which means people need to go thru the design phase first before doing implementation. In C you can jump into imp. first but then much later you realize it lacks proper design. Then it will be too late to fix things because they''re so spread out and cause domino effect.

Share this post


Link to post
Share on other sites
Why has this not been mentioned yet?

Fiami, private methods are not faster than public methods. PERIOD. Once compiled, the two work EXACTLY the same.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
modular programming is a communist plot :D
hehe, c is such a strange thing... if you want do 'objects' in c you can do really funny things... (do not try this at home kids)

int (*_get_Age)();
typedef _get_Age get_Age;

struct _person {
get_Age getAge;
int weight;
};

typedef struct _person person;
... etc...

Well i wouldnt say that is better than c++ objects at all, just for educational purposes.

EDIT: some syntax mistake :D

[edited by - matias suarez on October 23, 2003 4:39:02 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by Sneftel
Why has this not been mentioned yet?

Fiami, private methods are not faster than public methods. PERIOD. Once compiled, the two work EXACTLY the same.


He is probably thinking Java. A public method in Java is always virtual, while a private one never is.

--
AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
[Project site] [Blog] [RSS] [Browse the source] [IRC channel]

Share this post


Link to post
Share on other sites
quote:
Original post by Filami
Ok, that seems....equal? It seems that getDummy is inline, isn''t it?
well, how you did see the asembly output? When I try to do in msvc6, i can only see it in debug mode, not in release (it says that it hasn.t the debug information).
But ok! Don''t forget that this is completly compiler dependent! In that function example, it hasn''t created the this pointer. May be that what compiler tryed to optimize.
But, in that case, what you thinck about this desing guys?:

class test{
BigType data;
public:

__inline void _fastcall set(const BigType& d){
data = d;
}

__inline BigType get(){
return data;
}

__inline BigType& ref(){
return data;
}
};

Ok, it''s more an implementation than a design, but it looks great and fast, don''t it?


The assembly came out the same whether the function was inline or not. I also disabled any optimizations in the compiler.

You have to remember that you''re unique, just like everybody else.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Erkki
And IMHO it is currently the best way to think if you don''t want to remain as a code writer forever. Imagine the things that you need to do in your job as methods of classes. Now if you move up your career ladder by one step, you can mostly forget about how the methods work and only remember the class and it''s interface (public methods). If you don''t have object oriented thinking, doing this might be much harder.



I can''t possibly imagine the horrible confusion of ideas that would lead to this series of statements.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
quote:
Original post by Erkki
And IMHO it is currently the best way to think if you don''t want to remain as a code writer forever. Imagine the things that you need to do in your job as methods of classes. Now if you move up your career ladder by one step, you can mostly forget about how the methods work and only remember the class and it''s interface (public methods). If you don''t have object oriented thinking, doing this might be much harder.



I can''t possibly imagine the horrible confusion of ideas that would lead to this series of statements.




))))))))))))))))))))))))))
Actually that would explain quite well why the hell not a single manager or boss have a clue on how things are (or must be) done
Anyway i think in a quite opposite way, if you know the inner working of something you can take better decisions and evaluate things more appropiately rather than superfluous (is that a real english word?) understanding

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!