Is my OO code any good?

Started by
18 comments, last by ANSI2000 22 years, 6 months ago
actually, it's vertices..........never mind, I only got halfway through the post

Edited by - masonium on October 20, 2001 1:07:02 AM
Advertisement
I am not allowed to look at your source but from what others have mentioned the Vertexes would be an unforgivable mistake from the point of view of a maintainance programmer. This might be only in house, when I developed an in house level editor I made a Vertex class (describing a point in space), and derived a Vector class (point in space having direction and magnitude and whatever else in consideration of Quaternions) this made it much more readable and saved me alot of coding time. Of course, the functions that apply were class specific.

I have been working on a game engine for about four semesters now, and realized that downward compatibility is not always accurate, but hey, it''s better than not working at all.

Whatever!!
I need to see the source, but you say this is OGL and yet you seem to be going through all this trouble with different OS. It doesn''t matter what OS the person is using, OGL communicates directly with the hardware, but hey I could be wrong. Keep doing whatever it was that you were doing, I am sure it is attainable.
Yes OGL itself is cross platform when it comes to function calls. But binding OGL to a specific OS and window is another case.

I think for now I will only work on the Win32 version only.

But what I will do first is I will make a design/spec and maybe from there you guys can help add paterns or identify paterns etc.. How about that?
I''m in ANSI. Here''s a suggestion: get a copy of Dia. It''s like MS Visio (but much better IMO), you use it to create class diagrams. I personally find this an invaluable tool when trying to keep all my classes in order. It''s also nice to come back to a piece of your engine a week or two since working on it and be able to get back up to speed on how the code is organized by simply glancing at a diagram rather than digging through a bunch of source files. And it''s free!
Also, check out the book Design Patterns. If you actually want OO to make your life eaisier, this book is the key. From my (limited) experience in game development it seems like Factories and Facades are the most heavily used, but I''m sure many of the other concepts presented will be useful as well.

"If consquences dictate our course of action, it doesn''t matter what''s right, it''s only wrong if you get caught."
- 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
All the GoF patterns are useful one way or another in a game engine.

quote: - ANSI2000
Like I said my Vertex will contain more info then just x,y,z....

They''re not vertices unless they contain more than just x,y,z info, in which case they would just be points.

WayfarerX:
Have you used any other tools beside Dia? ArgoUML is another free one, but I hate the Java UI almost as much as I hate gtk. And Argo''s load time makes Black&White look like light speed. All the Windows one''s I''ve tried have that FlexLM virus...


- Magmai Kai Holmlor
"If consquences don''t dictate our course of action, there''s no such thing as right nor wrong!"

"If [negative personal] consquences dictate our course of action, it doesn''t matter what''s right, it''s only wrong if you get caught."
- Tool


- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
I tried Poseidon, which is the ongoing development of ArgoUML in a commercial scenario - but there is a community edition which is free. It plugs in to Netbeans/Forte too. Bit slow though, owing to the Swing UI. I think you can find it at http://www.poseidon.de

I''m lucky enough to use the expensive Rational Rose at work, and while its a lot faster, Poseidon is a better UML modeller IMHO
It''s really a problem of the language that it is too flexible, so you''ll like something about one tool and not the other. Such is life

~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
Community Service Announcement: Read How to ask questions the smart way before posting!
~~~Cheers!Brett PorterPortaLib3D : A portable 3D game/demo libary for OpenGLCommunity Service Announcement: Read How to ask questions the smart way before posting!
Magmai:

I have used ArgoUML, and for some reason it never really struck my fancy. Dia always just fit right with me (although I agree the UI is a little ''ugh''). Recently I ''ve been using it to map out the electronics setup of my house (which, BTW, rivals some of my most complex OO diagrams ).

As for the sig, it is not my job to provide interperatation, just to relay the message .
What do you think of my new one? (Changed because when they played this song at the concert it blew me away)

"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
Hey, ANSI2000, I finally got around to dl''ing your code
When you zip up code to distribute to people - delete the debug directories!

Well, I have a few suggestions:
Don''t bother with get/set tuples - xsp ones like getX, getY, etc... The abstraction doesn''t do anything useful if it''s transparent (tuples get you access to the implementation data), and data-access side-effects are absolutely moronic. And that''s my professional opinion :p

For a class like CTriangle, it'' job is to make manipulating the vertex data easier and perhaps more intitive. And in this case it''s too fine of a granularity to implement methods for. You don''t want to call a method on each triangle you want to manipulate - you want to call a method on each mesh you want to manipulate and it should directly twiddle the vertex data. I''m using D3D8 not OGL, but using vertex buffers (or the collary in OGL) is a much faster way to render. Every triangle may not need 3 distinct vertices either - you want to use triangle-fans when possible to minimize the geometry data sent across the pipe. So the next thing to design is a set of classes that manage vertex buffers and fills them in given a set of model control points.

ctor''s & dtor''s are not replacements for Initialize and Shutdown. Except for cases where you want to minimize data copying (like matrix or vector type classes) don''t do anything in the ctor . Set the internal variables to a known state or initialize them to 0 (except, again, for matrix/vector type classes). I have been boned by my own code and others countless times because they do intialization in the ctor. Unless there''s a very good reason to do it in the ctor - don''t. This goes doublely so for dtor''s.


WayfarerX: I like the new quote better 8)

Um, www.poseidon.de is a freight shipping company.

Dia is just a charting program, oui? Is there snap-ins or something for f/r engineering?

Magmai Kai Holmlor
- Not For Rent
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Yup, Dia has plugins. The program itself comes with ones for UML, circutry, networks, flowcharts, pneumatics/hydraulics, and a bunch of other weird stuff.

"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

This topic is closed to new replies.

Advertisement