title: Should i create a class that implements an interface or use the interface as it is?
body: <p>In this server app i am extending there is a class EventManager with a method:</p>
  
  <pre><code>pubic void addEvent(Event event, int time){ // code to process handling of events }
  </code></pre>
  
  <p>Event is and interface. I have several classes in which i need to run a very similar event that uses a lot of the same methods. Rather than rewriting each of those methods in each of the classes that i am running similar events in, i thought that if i created public class that implements event and had each of the methods in it:</p>
  
  <pre><code>public class someEvent impements Event{
  
  
      public void send(String message){
  
            for (int i = 0; i &lt; Server.playerHandler.players.length; i++) {
              if (Server.playerHandler.players[i] != null) {
                      if (Server.playerHandler.players[i].inPcGame()) {
                              Client c = (Client)Server.playerHandler.players[i];
                              c.sendMessage(message);
                      }                      
              }              
      }
  
      }
      public void spawn(int[] npcs, wave){ 
  
          int x = 4234;
          int y = 2343;
          int z = 1;
          int health = 10 * wave;
          int maxHit = 5 * wave ;
          int attack = 150;
          int defence = 200;
          NpcHandler.getNpcHandler().spawnNpc(c, 1, x, y, z, 0, health, maxHit, attack, defence, true, false);
  
     }
  
      // Event method override
      public void executeEvent(){
  
           spawn(npcList, waveNum);
           send(message);
  
      }
  }
  </code></pre>
  
  <p>Then use to then create objects in each of the class am running the events in. Then pass those objects to the EventManager. </p>
  
  <p>I taught myself and am still learning, my friend who also taught himself, but has been programming longer says i should do that and should do this instead:</p>
  
  <pre><code>import sever.event.EventManager;
  
  public class someClass {
  
      public void send(String message){
  
            for (int i = 0; i &lt; Server.playerHandler.players.length; i++) {
              if (Server.playerHandler.players[i] != null) {
                      if (Server.playerHandler.players[i].inPcGame()) {
                              Client c = (Client)Server.playerHandler.players[i];
                              c.sendMessage(message);
                      }                      
              }              
      }
  
      }
      public void spawn(int[] npcs, wave){ 
  
          int x = 4234;
          int y = 2343;
          int z = 1;
          int health = 10 * wave;
          int maxHit = 5 * wave ;
          int attack = 150;
          int defence = 200;
          NpcHandler.getNpcHandler().spawnNpc(c, 1, x, y, z, 0, health, maxHit, attack, defence, true, false);
  
     }
  
      EventManager.getSingleton().addEvent( new Event(){
  
          public void executeEvent(){
  
              spawn();
              send();
  
      }}, 12000
  
  
      );
  }
  </code></pre>
  
  <p>and do this in each class rewriting each of the methods in each class i use the event in. </p>
  
  <p>He insists that my way uses more memory and is CPU intensive. I do not understand how my way is heavier on the CPU instead of less intensive than his way. Which way is the correct way and why?</p>