Skip to main content
gamedev.net
🔒 Locked

Windows program==one big class.

Started by tHiSiSbOb Jan 17, 2004 at 11:04 PM 13 replies 850+ views
Original Post
tHiSiSbOb
tHiSiSbOb
Is there anything wrong with making a windows program one big class? What I mean is having a class that has everything in it (includeing the main loop).
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
Nervo
Nervo
Um, have you tried putting main inside the class? O___O

[edited by - nervo on January 17, 2004 12:11:20 AM]
Well, R2D22U2..
tHiSiSbOb
tHiSiSbOb
Why, yes I have.
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
antareus
antareus
Those are called God classes and usually aren''t well regarded.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
tHiSiSbOb
tHiSiSbOb
quote:
Original post by antareus
Those are called God classes and usually aren't well regarded.


Ok. Thank you. Can you tell me why though?
EDIT: Well, I did some research and it says that a god class is a class that has more than one purpose. The program I am writing is a simple map editor and everything done has to do with pretty much the same stuff. Is it still wrong to have a god class?
EDIT2: Also, this god class of mine has several other classes in it. Is it still considered a god class?
[edited by - tHiSiSbOb on January 17, 2004 12:27:20 AM]

[edited by - tHiSiSbOb on January 17, 2004 12:28:26 AM]
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
fallenang3l
fallenang3l
Why even bother making it a class then. Just use namespaces and functions, cause it looks like to me you''re using classes just for the sake of using classes. If you want to do it the proper way, check out this tutorial.
antareus
antareus
quote:
EDIT2: Also, this god class of mine has several other classes in it. Is it still considered a god class?

Yes. God classes are named that way because they generally do more than one thing and/or they 'know' too much. In software engineering terms, the God class is coupled to almost all of the other classes, inhibiting maintainability. Usually God classes end up mangling presentation of data with the actual logic that is done on the data. Although that sort of thing is fine for quick, small programs, (think VB) it can become harder to maintain.

Decouple the two using something like signals and slots. I have an entire app that is based only on signals and slots. They are very robust and scalable.

[edited by - antareus on January 18, 2004 1:12:25 AM]
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Colin Jeanne
Colin Jeanne
quote:
Original post by tHiSiSbOb
Is there anything wrong with making a windows program one big class? What I mean is having a class that has everything in it (includeing the main loop).


There isn''t anything wrong with it if you are using C# or Java. The C++ language tends to disagree with this practice, however.


Colin Jeanne | Invader''s Realm
Zahlman
Zahlman
quote:
Original post by Invader X
There isn''t anything wrong with it if you are using C# or Java.


o__O

"Everything is a class" != "it''s ok to use just one class". WTF.
Extrarius
Extrarius
quote:
Original post by the_dannobot
It''s already been done. MFC is an object oriented wrapper around win32.
Many bad things have already been done.

It is generally a bad idea because monolithic software is more difficult to maintain, and one main class would pretty much have to be monolithic.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
psykr
psykr
I plan to make my main() look like this:

int wWinMain( HINSTANCE, HINSTANCE, LPSTR, int ) {
new Kernel();
Kernel::GetSingleton.Run();
Kernel::Destroy();
return 0;
}
antareus
antareus
quote:
Original post by the_dannobot
It''s already been done. MFC is an poorly designed and overly complex object oriented wrapper around win32.

There you go.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Colin Jeanne
Colin Jeanne
quote:
Original post by Zahlman
quote:
Original post by Invader X
There isn't anything wrong with it if you are using C# or Java.


o__O

"Everything is a class" != "it's ok to use just one class". WTF.



He did not specify the size of the program. Of course it's not very intelligent to always use a single class but for small programs in those languages a single class might be fine.


Colin Jeanne | Invader's Realm

[edited by - Invader X on January 18, 2004 3:43:11 PM]
thec
thec
One reason to try to split it up a little is because usually it''s better to make small parts of the working application that you can debug and make sure they''ll work.

If something goes wrong, it''s often easier to find the error this way.

You can also more easily work several people on the same project. If you''re not part of a team, this is no problem for you.

It''s also easier from a design point of view... searching through a large .cpp file is just time consuming, and using one(1) .h-file with several(>1) .cpp-files are just bad design and can confuse a lot IMO. Hope you understand what I mean by this.

But sure, for small->medium size applications I could imagine this being a good solution.

Albert
-------------------------------------------http://www.thec.org

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.