Is my OO code any good?

Started by
18 comments, last by ANSI2000 22 years, 5 months ago
I started writing my own 3d engine for OGL. I have started a few bassic classes etc... I was wondering if any you guys can tell me if I can improve it or do better. Thanks. Get code here. Edited by - ANSI2000 on October 11, 2001 12:21:36 AM
Advertisement
I guess to stupid of a question?
more along the lines of people are too lazy to download and look :o)
That sux Cause I know if i had something like am creatin a new patern... People would be flockin by the masses.
I''m not the best C++ OO guru in the world, but I did notice a few errors:

class: G3DWin32App
You have G3DWin32App::main() defined as a pure virtual function, but G3DWin32App::~G3DWin32App() is not virtual. This is bad, if you ever have a virtual function in a class, make sure the destructor is virtual too. (You do this correctly in G3DOS).

It''s not Vertexes, it''s Verticies (G3DTriangle::setVertexes()).

It appears you''re trying to abstract out the OS-specifics to achive portability. But it''s confucing because you have your pure virtual G3DOS class & a Win32 subclass (looks good), but then you have your G3DWin32App class that accepts a G3DOS*, but you''ve named it with "Win32". Is this simply a mis-naming or is the G3DWin32App going to contain windows code? If so your design isn''t really going to save you much. What it appears you want is for G3DOS to be a facade for the host OS. If this is the case make sure all of your platform-specific API calls are in G3DWin32OS and rename G3DWin32App to G3DApp and have it rely on functionality provieded by the G3DOS class. See what I mean?

Looks like a good start though. One tip: DOCUMENT MORE. One liners for a function are not enough, document parameters and return values, preconditions, postconditions, etc.

Best o'' luck!

"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
quote:Original post by WayfarerX
It''s not Vertexes, it''s Verticies (G3DTriangle::setVertexes()).


Um, vertices. I know that was a typo, though.
Sigh, I can''t even spell when I''m trying to show someone else how to do so, damn these sly, mischievous fingers of mine!

Thanks Oluseyi.
As for Vertexes I call them that way because they will contain more info then just x,y,z like texture info maybe etc... plus it''s just different.

As for G3DOS it is the abstract class I guess what you call facade.
Need to learn the terms hehe.
I have the "Design Patern" book from Booch and gettin all kinds of ideas.

Now G3DOS will be abstract and contain all abstract methods for each OS, For instance, the getInstance method is applicable to Windows, whether it is applicable for X Windows I dont know. Eben though lets say the G3DLinuxOS will inherit that method it will not use it depending if applicable or not.... Then yes all Win32 will be done in G3DWin32OS as for Win32App let me see what I can do, maybe I had something behind the thinkin I will look why I did it that way.... Thinking more... Why there is Win32App is because in real world there is no real portability. You canot have geenric class for X Windows and Win32 just because they might handle Message pumps differently etc...

This way I implement all the necessary code for each OS and have the user Subclass and add all his game logic in there just as I did with myTest Class...

Also I will have an abstract Window Class and from there the different libs like Win32, KDE etc....
quote:
ANSI2000 wrote:
As for Vertexes I call them that way because they will contain more info then just x,y,z like texture info maybe etc... plus it''s just different

IMHO they should still be called vertices. How many 3D engine people do you think have nothing but coordinates in their vertex structs/classes?
Only a set of x,y,z coordinates are usually called a vector, and a vertex is a vector plus texture coordinates, colour, etc... (and the plural of vertex is vertices, as was already pointed out). But of course it''s up to you
quote:
ANSI2000 wrote:
You canot have geenric class for X Windows and Win32 just because they might handle Message pumps differently etc...

You could handle the message-stuff in G3DOS as well. For example you can have functions like GetMessage, PeekMessage, etc. in G3DOS that translate the OS specific messages into your own message format, and then have a generic message pump in G3DApp, that uses those functions.

There''s really no need to make G3DApp platform specific if you just design the G3DOS class well.
Like I said my Vertex will contain more info then just x,y,z....

Dactylos if you did look at my code my G3DOS clas is abastract and it has an updateMessage method... Now from there I subclass it to G3DWin32OS and G3DXWinOS etc.... Where each one implements the rather specific OS code.

Now the thinking behind Win32APP and maybe XWinApp etc... Is that Windows calls the updateMessages in a loop maybe XWin calls it through a call back so it might be diferent. Also these suposed classes will abstract the creation of a Window Specific to the OS etc....

This topic is closed to new replies.

Advertisement