Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

using interfaces for organization

Started by DrZoidberg Feb 20, 2005 at 11:56 AM 0 replies 250+ views
Original Post
DrZoidberg
DrZoidberg
hello, a little while ago i took a look into java and really liked the way the language implemented the use of interfaces, but i still wanted to code in c++ so i began to use interfaces to help me program more OO, however lately i've started to use interfaces for organization purposes aswell and just wanted everyones opinion on what they think. to me it does sorta seem like a wasteful thing to do, i'll give an example below. ok first off, how i'd normally use an interface.

class CGameCore {
  IEventInput* inputReceiver;
public:
  CGame(IEventInput *ieventinput) : inputReceiver(ieventinput) { }
};

class GameCode : public IEventInput {
private:
  CGameCore *core;
public:
  GameCode() {
    CGameCore = new CGameCore(this);
  }
}


that's the general idea on what i've been doing, but lately i've been doing this. i guess it's not an interface anymore in the following example though.

struct INeedToUpdate {
  virtual void update() = 0;
  virtual void getStatus() = 0;
}

class AnyClass : public INeedToUpdate {
};

class SomeUnrelatedClass : public INeedToUpdate {
};


basically in this situation the interfaces exsist only to help me distinguish which classes have what functionality, but no class actually will use the above interfaces to perfrom any tasks. should i steer clear of this?
Woop woop woop woop!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.