- Read this answer on composition over inheritancethis answer on composition over inheritance.
- Use one single method to create different entities, this leads to more maintainable code since configuration-specifics belong in external data files, not in code. So avoid
createPlayer(),createEnemyOne(),createAsteroid(), in favour ofcreateEntity(int id, string type, PhysicsComponent physics, SpriteComponent sprite, ...)with parameters being either primitives or complex objects themselves, and collectively specifying a unique object such as an asteroid. - Use the builder pattern specifically because you need a class dedicated to translating said configuration data into concrete entities, while maintaining separation of concerns between classes (e.g. your game class "Main" should not be constructing entities, but it should be delegating the task to another class).
- Read this answer on collision detection and entity destructionthis answer on collision detection and entity destruction.
replaced http://gamedev.stackexchange.com/ with https://gamedev.stackexchange.com/