I was wondering what thought process some of you go through when organizing classes and their hierarchies in an OO design? I'm doing my first major embedded project, while I'm strong at programming I don't have much education regarding computer science ideology.
For instance, I'm doing a basic subset right now that is a clock component. I have a Real Time Clock device, so I thought I should create a class to encapsulate those functions and setup parameters. Then I also have a I2C class, which needs to be used in the RTC class to communicate with the physical device.
Both objects are created on the same level of hierarchy, my thought is that I should be initializing the I2C object first, and then passing a pointer to it as part of my RTC object creation, so the RTC class can access its sibling class. I've run into several challenges like this, I don't know if I'm over thinking the problem at hand, or missing the idea of how objects should be built on each other, or doing it exactly right.
Another example would be the class for my LED clock display, I want the RTC to update it, but it doesn't seem logical to have it simply be a subclass of a totally different component. Again this idea of passing one sibling object pointer to the other object comes to mind.
So, any words of wisdom from experience designing systems like this?
For instance, I'm doing a basic subset right now that is a clock component. I have a Real Time Clock device, so I thought I should create a class to encapsulate those functions and setup parameters. Then I also have a I2C class, which needs to be used in the RTC class to communicate with the physical device.
Both objects are created on the same level of hierarchy, my thought is that I should be initializing the I2C object first, and then passing a pointer to it as part of my RTC object creation, so the RTC class can access its sibling class. I've run into several challenges like this, I don't know if I'm over thinking the problem at hand, or missing the idea of how objects should be built on each other, or doing it exactly right.
Another example would be the class for my LED clock display, I want the RTC to update it, but it doesn't seem logical to have it simply be a subclass of a totally different component. Again this idea of passing one sibling object pointer to the other object comes to mind.
So, any words of wisdom from experience designing systems like this?