0

I have the following problem:

A report is composed by 3 different metrics and each metric can be obtain from different place. Example:

  • A Report is composed by 3 Metrics: Metric1, Metric2, Metric3.
  • Each metric is obtain from different C. for example Metric1 is obtain from C1 and C2, and Metric2 is obtain from C1, Metric3 is obtain from C2 .

I made this 2 solutions to the problem I wonder which one is more correct if any or if is there another solution:

enter image description here

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
Sneijky
  • 11
  • 2
  • What would `C` be? Counters? – qwerty_so Aug 04 '18 at 16:12
  • you could say that C is the place where you extract the counters from. for example: Metric1 = (counter obtain from C2) / (counter obtain from C1) and Metric3 = counter obtain from C2 (different from the counter used in Metric1) – Sneijky Aug 04 '18 at 16:42
  • That's too wishy-washy. If you model something you need to be aware of the semantics. Why would you have a C(ounters) class? A counter is a number. Metrics are something that do calculations on numbers. – qwerty_so Aug 04 '18 at 17:53
  • Cs are not counter class. – Sneijky Aug 04 '18 at 17:57
  • What i'm trying to figure out is the connection between report and metrics but for better understanding let's say C is a component. And that you have always only this 2 components (C1 and C2). Each component has tests and each test has a result. Metric1 = Number of tests with success in C1 + Number of tests with success in C2. Metric3 = Number of tests failed in C2. – Sneijky Aug 04 '18 at 18:08
  • To me it looks like you are mixing classes and objects in your diagram. A metric is designed to get numbers, do calculation and return another (set of) number(s). It does not need to be connected to a specific component. It just needs an interface to receive the numbers. Those components just seem superfluous. – qwerty_so Aug 04 '18 at 18:15
  • It is also unclear what the different metrics mean. Why are there 3 metrics in the report and what makes these metrics different from each other? – qwerty_so Aug 04 '18 at 18:24
  • There are essentially two solutions to this conceptually, with any specific design being derived from one or other. These are inheritance (top model in your diagram) and composition. The textbooks tend to argue to favour composition over inheritance these days (for good reasons). I suggest reading up on this and related patterns for implementation. – muszeo Aug 05 '18 at 21:25

0 Answers0