Results 1 to 5 of 5

Thread: Why use objects?

  1. #1

    Why use objects?

    I am not a big expert on objects, but they really seem to make debugging very hard and complicated. Also you can have a lot of nasty memory leaks. I am a coder for a complex game engine and simple arrays are easy to use and cause much less trouble. On top of this, they make code harder to read and less easy to understand.

    Objects of course make sense if you want reusable, standalone components, but if it is just for yourself, you can simply cut and paste code. Yes, it could be a bit more work, but you avoid tons of problems that can happen to objects.

    Any thoughts?

  2. #2

    Why use objects?

    In fact the opposite is true. Using objects makes your code easier to manage, easier to read and easier to add to and fix.

    I don't see how using objects creates more memory leaks - if you stick to rules of creating and freeing then their is no problem. Great thing in my mind at least is that you can make really complicated objects that interact with the rest of your program/game without making the code harder to read and follow.
    The views expressed on this programme are bloody good ones. - Fred Dagg

  3. #3

    Why use objects?

    Objects allow for modular dependency, and a level of versatility you cannot achieve in records. For example I could have a simple particle definition within my game with a few special case child objects. We'll call 'em:

    TParticle
    TTimelineParticle class(TParticle)
    TFaderParticle class(TTimelineParticle)

    Rather than go into details I'll keep it high level and abstract. You could use specific definitions within the 2nd class to provide specific or scriptable points in the particle's lifetime, changes to anything it has or does, while the 3rd class could provide a specific fade one image out and another in. Doesn't really matter how or what you do with it, but the framework is simpler than that of a huge record with data variables for every possible particle setting. Not to mention smaller and more compact.

    You must adhere to strict creation and destruction protocalls to avoid memory leaks, yes, but this is very easy and not obstructive in any way. It makes debugging no less or more difficult though, as you can trace problems etc to their source, plus you can manipulate the object(s) without affecting any other game code.

  4. #4

    Why use objects?

    There's a time and place for everything, even objects. But I would urge everyone to take a look at other programming paradigms (e.g. functional and generic), too. Learning is fun.
    [size=10px]"In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite." -- Paul Dirac[/size]

  5. #5

    Why use objects?

    Objects can be derived from the previously created objects, adding a new functionality or replacing the old one (thanks to virtual methods). Objects are a great mechanism and a must-do for any higher-level game structures. Although I don't think that using them for particles is advisable. Same for vertexes in a model and other low-level stuff.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •