Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Vanukoff

Which is a "better" design?

This topic is 6304 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Obviously "better" is subjective, but I just want some opinions. Here is method 1:
  
struct Foo
{
    enum { NUMBAR = 4 };
    enum { WIDTH  = 20 };
    enum { HEIGHT = 20 };  
    //

    int flags[NUMBAR];
    int var_a[NUMBAR];
    int var_b[NUMBAR];
    int table[NUMBAR*WIDTH*HEIGHT];
}
  
Here is method 2:
  
struct Bar
{
    enum { WIDTH  = 20 };
    enum { HEIGHT = 20 };  
    //

    int flags;
    int var_a;
    int var_b;
    int table[WIDTH*HEIGHT];
}

struct Foo
{
    enum { NUMBAR = 4 };
    //

    Bar bar[NUMBAR];
}
  
Personally I''m partial to method 1, but method 2 seems more object oriented. However, I don''t want to overcomplicate things.

Share this post


Link to post
Share on other sites
Advertisement
No idea. You''re talking in complete generalities here. There''s no way to tell without seeing how this data is going be used.

Share this post


Link to post
Share on other sites
Why enum and not const?

      
class CFoo
{
public:
CFoo(int n=4, int w=20, int h=20) : number(n), width(w), height(h), table(0)
{
table = new int[number*height*width];
}
virtual CFoo()
{
if(table)
delete[] table;
}

const int number;
const int width;
const int height;
private:
int* table;

};

that's what I'd do given the information you gave us...

Magmai Kai Holmlor
- Not For Rent

There's always a bug...

Edited by - Magmai Kai Holmlor on September 6, 2001 12:19:01 AM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!