Results 1 to 10 of 25

Thread: CLASS vs. OBJECT and memory management

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    There's a modern revival of functional programming that has some very interesting points. Even if you're a die hard fan of functional or object orientated coding - there are advantages and 'disadvantages' to both approaches.

    Yes classes are slower to initialise and destroy but when it comes to even fairly recent hardware? the cost is negligible - the vast majority of modern engines and games are object orientated - engines used in games such as the original 'max payne' were amongst the first fully OO engines and we still have OO engines leading the field today. Forget the performance hit, just pre-initialise if you're using thousands of class instances and it won't matter compared to the computationally heavy sections of code.

    Some parts of your design are complex lumbering beasts that are easier to maintain and modify when designed as classes.

    Some parts of your design are time critical or logically flat and functional programming and the minor performance gains are worth losing the inheritance flexibility of high level classes.

    I think a combination of both is a good idea - as a general rule of thumb anything that's being touched many times per frame (such as entities etc) should be as functional as possible and everything else should be as modular as possible.
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  2. #2
    By functional programming, are you talking about this?
    No signature provided yet.

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
  •