you are viewing a single comment's thread
view the rest of the comments
[–] 105 points 6 months ago* (1 child)

Hold on, I’m in the middle of drawing an inheritance graph so I know how Dog is related to AircraftCarrier.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 78 points 6 months ago* (3 children)
    public interface ICanTravelThroughTheAir
    {
    
    }
    
    public class Flea : ICanTravelThroughTheAir
    {
    
    }
    
    public class AircraftCarrier
    {
      private readonly List<ICanTravelThroughTheAir> _aircraft = new();
    
      public void AddAircraft(ICanTravelThroughTheAir flyingThing)
      {
        _aircraft.Add(flyingThing);
      }
    }
    
    public class Dog : AircraftCarrier
    {
        public void Woof()
        {
            Console.WriteLine("Bitch I'm an aircraft carrier!");
        }
    }
    
    public static class Program
    {
      public int Main(string[] args)
      {
        var dog = new Dog();
        
        for (var i = 0; i < 10000; i++)
        {
            dog.AddAircraft(new Flea());
        }
    
        dog.Woof();
      }
    }
    
  • source
  • parent
  • hideshow 6 child comments
  • [–] 63 points 6 months ago (2 children)

    Needs more AbstractDefaultProxyBeanFactoryFactories

  • source
  • parent
  • hideshow 4 child comments
  • [–] 24 points 6 months ago (2 children)

    And dependency injection!

    Every class needs to use DI for calling other classes, even though we'll have anyway just a single implementation for all of them, and we won't be using this flexibility at all (not even for tests where it might be useful for mocking dependencies).

  • source
  • parent
  • hideshow 4 child comments
  • [–] 3 points 6 months ago* (last edited 6 months ago) (2 children)

    Now someone needs to make it an entity component system!

    Attempt 1:

    public struct Entity {
      bool isDog : 1;
      bool isAircraftCarrier : 1;
      bool isFlea : 1;
      bool canFlyInAir : 1;
      ubyte opt_numOfAircrafts : 4;
      int entityID;
      int opt_parentID;
      static Entity createDog(int entityID) {
        Entity result;
        result.isDog = true;
        result.entityID = entityID;
        return result;
      }
      static Entity createFlea(int entityID) {
        Entity result;
        result.isFlea = true;
        result.canFlyInAir = true;
        result.entityID = entityID;
        return result;
      }
      void addAirCraft(ref Entity aircraft) {
        if (aircraft.canFlyInAir && this.isAircraftCarrier) {
          aircraft.opt_parentID = this.entityID;
          this.opt_numOfAircrafts++;
        }
      }
      void woof() {
        if (isDog) {
          if (isAircraftCarrier) writeln("I'm a motherfucking aircraft carrier");
          else writeln("Woof!");
        }
      }
    }
    
    void main() {
      Entity dog = Entity.createDog(1);
      Entity flea = Entity.createFlea(2);
      dog.woof();
      dog.isAircraftCarrier = true;
      dog.addAirCraft(flea);
      dog.woof();
    }
    
  • source
  • parent
  • hideshow 4 child comments