Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Classes vs Types
#1
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.
Reply
#2
Um? Kind of lost me.

Could you explain a bit?
Reply
#3
Personally I find classes way more organized. I learned how to use them in probably the same amount of time as using types.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#4
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.
Reply
#5
Ah, alright, thanks everyone for your anwsers Smile Guess I'll just stick to types for now ^_^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)