Jump to content
  • Advertisement

Archived

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

ChaosEngine

Game Development and OO

This topic is 6545 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

Ok, this is probably gonna get me killed or something, but I think it''s a valid question. Most of us on this forum would have some exposure to OO. Personally I work with it everyday and I think it''s brilliant. Anyway, alot of articles, books, etc state that the modelling aspect of OO is particulary applicable to games. And thats true in a lot of ways. However it seems from reading posts on this forum that most game developers do things for the sake of speed that violate encapsulation and do other bad OO things (casting, etc). So is OO worth it? -- ChoasEngine "Those parts of the system that you can hit with a hammer (not advised) are called hardware; those program instructions that you can only curse at are called software." -- Unknown

Share this post


Link to post
Share on other sites
Advertisement
I think part of the way to become a GREAT programmer, is to find when you break the principles, and when to stick to them.
Object Orientation is a pretty idea, and it sometimes really helps to bring a design together, but sometimes you need to violate some principles for ease-of-use, or speed.

Though, usually, in a language like C++, there is a LOT you can do before you are really violating any Object Orientation principles


Give me one more medicated peaceful moment..
~ (V)^|) |<é!t|-| ~

Share this post


Link to post
Share on other sites
I''m a big OO programmer. I use it so much I can''t go back to regular procedural programming unless I am doing a simple tool. I think OO programs are easier to design, implement, debug, and are easier to buiid among teams. Don''t sacrifice good design for speed. If you design your program well, you won''t need to.

Domini

Share this post


Link to post
Share on other sites
Actually, designing a GOOD OO approach is a very hard thing to do, especially with large projects. It takes a lot of planning and vision, but it makes it SO much easier to program if you do it right.

Also, as MadKeithV said, there may be a few extreme times you may "break the rules" for speed, but if the design is good, you shouldn''t have to break rules for ease of use.

Share this post


Link to post
Share on other sites
quote:
Original post by Domini

Don''t sacrifice good design for speed. If you design your program well, you won''t need to.




I don''t mean this as an inflammatory question, but where do you get this wisdom? Have you experienced it, or is it just "what everyone else says".
Be very careful where you tread, optimising C++ is a lot harder than it seems at the beginning, and sometimes you DO need to tradeoff.



Give me one more medicated peaceful moment..
~ (V)^|) |<é!t|-| ~

Share this post


Link to post
Share on other sites
Myself I think that a good compiler should be able to optimise most of the speed deficiencies in C++.

For example get and set routines if declared inline can be optimised away.

I happen to agree with domini. I couldn''t possibly go back to procedural programming.

As an aside what about generic programming( templates )? Do they have a place in game programming?

Share this post


Link to post
Share on other sites
I''ve experienced it. If you make sloppy code that runs fast, especially at the beginning of the project, you will run into problems. I also develop my programs with the intention that I will want to upgrade them later. By using classes and encapsulating code, you can easily upgrade by just reimplementing a class, and you never have to touch other stuff.

I use to break OO design alot. I still do some of the time. Usually, I''ll just make another class a friend instead of making everything public.

Domini

Share this post


Link to post
Share on other sites
Generic programming is brilliant - it actually lets you work out some of the performance considerations of C++ without having to think about it too much. I just wish Visual C++ 6.0 would have better support for it, they''ve really skimped on the ANSI standard with respect to templates.


Domini - if you have experienced, I agree with you.
Check the resent "C++ operator overloading, and why it blows " thread, to find the evolution that lead to it.
I wrote an article on C++ Optimisation, that I hope will get published here. I''ve been editing it with some of the people here on the ''boards to make it worth reading.
You can get a version at my web page. That''s a word95 document by the way.

If you have any suggestions or criticisms, I''ll be happy to hear them!

Give me one more medicated peaceful moment..
~ (V)^|) |<é!t|-| ~

Share this post


Link to post
Share on other sites
Im a big OO user and learned the hard way. My first game was in C++ but wasnt very OO designed, I have tried to go back and update the code almost a dozen times and given up becasue even I can not follow it.
OO is essential in any big project, even a one-man project.

http://www.positech.co.uk

Share this post


Link to post
Share on other sites
Personally, I have been working with OO (language and design methodolgy) for more than 10 years.

An OO language does have certain pitfalls for new programmers resulting in (and always do) awful code and badly implemented designs, this leads to bugs, inefficient code and general bad mouthing of OO.

Experience can produce fast efficient OO code. In fact IMHO OO methododolgy is ideal for game writing.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!