Need some external advices for designing this class diagram!
Summary
I have to modernize an application written in FORTRAN that, in short, is responsible for demographic projections through years. As such, I have an initial population given as an input. This initial population is categorized by years of age, that is, the sum of all numbers per year of age represents the total population for this year.
Let's take a look on data for a few seconds.
Year: 2009
Age 0: 43786.0000
Age 1: 42997.0000
Age 2: 42656.0000
...
Age 99: 2439.0000
Then, we have to project year 2010 according to certain death rate set the same way as this above-mentioned initial population, except that it includes rates instead of totals per year of age.
Year: 2009
Age 0: 0.000213345
Age 1: 0.000212543
Age 2: 0.000201938
...
Age 99: 0.04824421
Age 106: 0.50000000
The idea is to group these entities under classes. I have already designed one, and I wonder whether it could be improved in some ways.
Objective
To simplify design and to embed statistical calculations within object classes so that it is more easily testable and mockable when required.
Actual Class Diagram

I feel like it can be improved. For your information and ease of readability, here's a index of the French terms used in the diagram:
TauxFeconditeAnnuel -> Annual Fecondity Rate
TauxMortaliteAnnuelle -> Annual Death Rate
PopulationAnnuelle -> Annual Population
SoldeMigratoireAnnuel -> Annual Net Migration
StatistiqueAnnuelle -> Annual Statistic
StatistiqueAnnuelleParSexe -> Annuel Statistic per Sex
My reflections are about whether or not to include a Death Rate class instance within a PopulationAnnuelle class. There exist death rates for initial population year and the next 96 years of projection. Besides, an annual population has to have its death rate, and an annual population is not obliged to exist for me to have a death rate for this year.
Let's say I have the initial population for 2009, I have not yet projected population for 2010, 2011, 2012, etc. until year 2105. Yet, I have death rate projections for all of these years, and population growth is based on these mortality rates to determine what population remain alive, and how many deaths we got, etc.
I thought of putting the PopulationAnnuelle class as the base class for my model, though I feel like StatistiqueAnnuelle is more suitable for the job, then making PopulationAnnuelle inherit from it.
Questions
- What are your thoughts on the about my concerns?
- What is the best design based on what I wish to accomplish?
- Should I use StatistiqueAnnuelle as the base class/interface and make the others like TauxMortalite, PopulationAnnuelle, etc. derive from it, a bit like it is now designed?
Any acceptable thoughts will be upvoted personally by me. The most accurate and helping answer will be accepted as the answer to my question.
Thanks for your kind help and support! =)
Are you able to identify for us the common significant use cases / scenarios? (Adrian K)
A common possible use case/scenario would be to plan the needs for pension plans based upon population growth. After the amount of people has been "predicted", you may calculate th开发者_开发百科e number of persons who will contribute to the pension plan and the people who will retire, then estimate the funding needs the contributors will need to pay so that the pension plan funds will have enough money to pay the pensions for them later when they retire and so forth.
Another possible common scenario would be insurances company. Based on population growth, statistics about the insurance usage would allow the company to predict the needs of their funding sources and establish the monthly payment for a given coverage amount based on accident refunds versus input monthly payments per age, let's say for car insurance for instance.
This exercise is called valuation.
Some initial thoughts:
- You deal with data over time - I'm uneasy about using classes who's purpose and name is tied to the concept of a year, especially if it's the only time-based unit of measure you have.
- Depending on how much data you need to crunch you might want to leverage a reporting package or leveraging your chosen database platform as this will be much more efficient for dealing with data.
- Keep in mind that data will go through a life-cycle: has it been cleaned? Do you need to impute any data? etc.
My reflections are about whether or not to include a Death Rate class instance within a PopulationAnnuelle class.
A death rate seems to me to be a sub-class of a broader concept (rate?) - a modifier or influence on the data; for that reason I would probably not explicitly include it in the PopulationAnnuelle. An alternative view would be to have population data passed into a "rate" modifier rather than embedding it in the population.
Yes - just thinking it through - I think you'd want to keep your concerns as cleanly separated as possible. This is why I asked about the significant scenarios you need to cater for - for example I can see you wanting to do lots of things with the PopulationAnnuelle where the death rate is not needed or even desirable.
Update
If I understand correctly, both the PopulationAnnuelle and MortaliteAnnuelle are derived from let's say a StatistiqueAnnuelle class
Hmmm - why? Two things to consider... Firstly, are you 100% certain that for the life of the application you'll only ever need to deal in units of years? Building the concept of a year so heavily into the code isn't something you'd want to do lightly.
Secondly, I totally get the logical idea that yearly statistics include deaths and a total population - but I'm not sure you'd reflect that in class structure via inheritance (?) (Not saying you can't - you've spent way longer thinking about this than I have). Apart from reflecting a particular mindset what does the inheritance actually give you (vs what will it do to you)?
My idea of grouping them was to simply ask the PopulationAnnuelle class for next year population growth, and that it would have returned it to me as a new instance of PopulationAnnuelle
That sounds dubious: a class is asked to produce a new different instance of itself. I'd probably have a class / component "TrendPredictor" (?) that was passed in all the data it needed (or references to sets of data) and returned some object. If you then wanted to perform more trend prediction on that then I guess it would make sense to pass the same types in and out so it was easy to string operations together in any combination.
Th eonly other commpent I'd make is that I woudl see those input and outputs being pretty dumb (and therefore not needing much (if any) inheritance - they sound more like data structures than classes that offer rich functionality.
加载中,请稍侯......
精彩评论