Mirage Source
Classes vs Types - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17)
+---- Thread: Classes vs Types (/showthread.php?tid=920)



Classes vs Types - JokeofWeek - 30-04-2007

Is there certain advantages to using either, such as speed and such? I was thinking of converting players and all that to classes, and I know it would be alot of work, but would it really be worth it? Or should I just stick with types.


- Matt - 30-04-2007

Um? Kind of lost me.

Could you explain a bit?


- Robin - 30-04-2007

Personally I find classes way more organized. I learned how to use them in probably the same amount of time as using types.


- Spodi - 30-04-2007

Dave Wrote:I would say a collection of classes would be faster than an array of UDT's, and the classes allow infinitly more possibilities to what you can do. It's a more "professional" way to do things, and also more modern.. It's also abstract, and hard to do.

I am almost positive classes would be slower. A UDT is just a collection of variables while a class is a collection of variables in an object that can raise events for the objects called.

They both have their ups and downs. Classes can help create a lot cleaner of coding since you can do invalid value checks directly from the class. For example, if you have the user's HP, you can check every time the HP changes that if it is over the Maximum HP.

I myself don't use classes that much. I should get in the habit of using them more. But I still see them used way the hell more than they used. For example, some people make classes for a FPS counter - what the hell is the point of that? Not only is that something that has absolutely no need for events, it is only done in one place in the code and referenced in the rest.

You also can't use classes with direct bulk alterations of memory. That means no CopyMemory, ZeroMemory, Put #f, , MyClass, etc. Of course, you could have a UDT in the class, but then you can still only go one class at a time.

So classes aren't there for performance, they're just easier. If it works without classes, don't touch it. No point in downgrading its performance farther unless you are really aiming for cleaner code.


- JokeofWeek - 30-04-2007

Ah, alright, thanks everyone for your anwsers Smile Guess I'll just stick to types for now ^_^