Hi,
I have question regarding architecture when dealing with composition/aggregation hierarchy. The three classes below "House", "Room" and "Door" describes a simple nested architecture used for this question. This architecture means that when I use a House object and want to refer to a door nested in a Room I will brake the "Law of demeter" rule that states that I should only use direct connection like House.ToString() not indirect connection like House.Room.Door.ToString(), is this okay or bad practise, is there any better way of organising the architecture?
 
Would it be better to do helper functions for the door in the Room Class, and not expose a Door object public, like:
DoorOpen();
DoorClose();
 
If this arhitecture is prefered, what should be done with the events inside the Door class, should they also be defined once again in the Room class and be "chained" back thru it's parent classes some way ?
 
 
Any thoughts, tips and ideas would be helpful.
C#
public class House
    {        public House()
        {
            Room = new Room();
        }
Code
        public Room Room { get; private set; }
Code
    }
Code
    public class Room
    {
Code
        public Room()
        {
            Door = new Door();
        }
Code
        public Door Door { get; private set; }
Code
    }
Code
    public class Door
    {
C#
        public event EventHandler OnOpen;
        public event EventHandler OnClose;
        private bool _isOpen;
Code
        public Door()
        {
        }
C#
        public void Open()
        {
            _isOpen = true;
            OnOpen(this, new EventArgs());
        }
C#
        public void Close()
        {
            _isOpen = false;
            OnClose(this, new EventArgs());
        }
Code
    }