Re: Is this a good class hierarchy for my project
On Mar 22, 10:28 am, "crea" <n...@invalid.com> wrote:
Goran wrote:
On Mar 21, 6:25 pm, "crea" <n...@invalid.com> wrote:
// Data
class WeatherData
{
...}
// classes for analysing data
class WeatherAnalysis
{
protected:
WeatherData m_Data; // data to analyze
void SetData(...);
WeatherData& GetData();
void DoSpecialAnalyze();
virtual void DrawDifferentMark();
...}
You hold m_Data by value, but you speak of having weather data per
country. If so, you can't make base class WeatherAnalysis to hold e.g.
USAWeather.
USA weather data is set this way:
WeatherData usa_data;
USAWeatherAnalysis usa;
...
usa.SetData(usa_data);
(But I see, below, that you equate Weather with
WeatherAnalysis, so I don't quite know what to make of this).
The idea is that there is whether data for eatch country. But there is
*also* a different set of analyze functions for eatch country. So eatch
country has its own "system" to analyze the data. The different data per
country is not really the main point but rather the different systems per
country.
Ah, OK then. But still, it looks like containment is better. What,
there's no two countries that you will "analyze" in the same way?
DrawDifferentMark seems to be UI-related. That's UI, not "analysis",
and so, it's suspect (you seem to be violating "single responsibility
rule").
Yes true. How about changing the name something like: "DifferentMark" so
then the receiver of the function can deside what to do (like draw)?
OK, I think I see what you mean. It's your analysis that's "producing"
these? If so, that's the classic MVC operation: model changes, so
views need to update. In light of MFC, that means calling
UpdateAllViews with "DifferentMark" or whateverr explained by means of
lHint and pHint.
Goran.