Click here to Skip to main content
15,891,864 members
Home / Discussions / C#
   

C#

 
GeneralRe: System.Diagnostics.Design? Pin
Colin Angus Mackay9-Apr-07 7:37
Colin Angus Mackay9-Apr-07 7:37 
GeneralRe: System.Diagnostics.Design? Pin
Vodstok9-Apr-07 7:43
Vodstok9-Apr-07 7:43 
AnswerRe: System.Diagnostics.Design? Pin
Dan Neely9-Apr-07 7:11
Dan Neely9-Apr-07 7:11 
QuestionWhere is my memory? [modified] Pin
lak-b9-Apr-07 5:17
lak-b9-Apr-07 5:17 
AnswerRe: Where is my memory? Pin
S. Senthil Kumar9-Apr-07 6:36
S. Senthil Kumar9-Apr-07 6:36 
GeneralRe: Where is my memory? Pin
lak-b9-Apr-07 7:49
lak-b9-Apr-07 7:49 
GeneralRe: Where is my memory? Pin
S. Senthil Kumar9-Apr-07 9:28
S. Senthil Kumar9-Apr-07 9:28 
QuestionDecorator Pattern Related Question Pin
jubilanttiger9-Apr-07 4:31
jubilanttiger9-Apr-07 4:31 
Hi,

I am building a class library for a reporting application. The following is the scenario and would like to know what type of pattern is appropriate for this kind of implementation:

To give a little bit of context, we are trying to determine the current status of various metric of a project. The status would be red, green or yellow based on the output value in an Metric. You can think of metrics are like Performance%, Security%, number of Bugs etc.

I have a class called as MetricReport which would produce one output number. This number would be compared to various targets to track the progress of the metric in question to produce status colors like Red, Yellow or Green.

Some scenarios of comparisons are:

1. MetricReport output number would be compared to Target values. The target values would be two numbers. Let’s assume that the target values for Performance Percentage are 90% and 70%. So, if the MetricReport value number is 80% then the metric is considered to be on Yellow status. If it is 95%, then considered as green. If it less 70% then it is considered as Red.
2. Baseline Scenario – Here MetricReport output number is compared to another report - BaseLineReport. Threshold values(which again is 2 numbers) are then applied on the BaseLineReport. So for example if Baseline Report produces a value of 70% as the Perf %, then threshold values of +5%(upper threshold) and 10%(lower threshold) are applied. Now, if our MetricReport produces a value greater than 70% + 5%(BaselineReport output plus the upperThreshold) then the metric turns green. If the MetricReport output value is lesser than 70% - 10%(BaselineReport output minus the lowerThreshold), then the metric turns red. Any values in between 75% and 60% is yellow.
3. Trend scenario – Here MetricReport output number is compared to a Trend. A Trend is something where you setup the start value, end value, start date and end date. The slope of the line is determined based on the start value and end value and the number of days between start date and end date. Threshold values(which again is 2 numbers) are then applied on the Trend. So for example if Trend produces a value of 70% as the Perf % (for a particular day), then threshold values of +5%(upper threshold) and 10%(lower threshold) are applied. Now, if our MetricReport produces a value greater than 70% + 5%(Trend output plus the upperThreshold) then the metric turns green. If the MetricReport output value is lesser than 70% - 10%(Trend output minus the lowerThreshold), then the metric turns red. Any values in between 75% and 60% is yellow.

So, you can summarize the above scenarios like:

MetricOutputValue + TargetValues – determines the color of the Metric
MetricOutputValue + BaselineReport + Threshold – determines the color of the Metric
MetricOutputValue + Trend + Threshold – determines the color of the Metric

The question is how to put this information into classes. I want this to be flexible so that in the future I would be expand it into new scenarios.


Currently I have the following classes:
1. MetricReport – produces one output number as a result
2. SimpleMetric – (supports scenario 1 above) This class takes a MetricReport as a child in the class, accepts TargetValues and does the calculations to determine the color.
3. BaselineMetric - (supports scenario 2 above) This class takes a MetricReport class and BaseLineReport class as children, accepts ThresholdValues and does the calculations to determine the color.
4. TrendMetric - (supports scenario 3 above) This class takes a MetricReport as a child in the class, accepts Trend information and ThresholdValues. With this data it does the calculations to determine the color.


I am thinking that this design is not that expandable, since Threshold is like a wrapper which is applied to classes and needs to be extracted to a separate class. Initially Decorator pattern looked like may suit this scenario. But all the examples I looked up for this pattern does not seem to suit this scenario perfectly. I thought of a scenario where I decorate a MetricReport with BaseLineReport and then decorate again on top with Threshold to support Scenario 2 above. But since the Threshold would need that the component be decorated with a BaseLineReport/Trend before it can be decorated with Threshold. I don’t know how to enforce this with the decorator.

Can you suggest what would be appropriate design for this situation..


Thanks a lot Smile | :) .
AnswerRe: Decorator Pattern Related Question Pin
Leslie Sanford9-Apr-07 6:14
Leslie Sanford9-Apr-07 6:14 
QuestionThread Aorting Pin
HexaDeveloper9-Apr-07 3:37
HexaDeveloper9-Apr-07 3:37 
AnswerRe: Thread Aorting Pin
Leslie Sanford9-Apr-07 5:32
Leslie Sanford9-Apr-07 5:32 
GeneralRe: Thread Aorting [modified] Pin
HexaDeveloper10-Apr-07 14:01
HexaDeveloper10-Apr-07 14:01 
Questioncombobox database value Pin
msogun9-Apr-07 3:36
msogun9-Apr-07 3:36 
AnswerRe: combobox database value Pin
Colin Angus Mackay9-Apr-07 3:42
Colin Angus Mackay9-Apr-07 3:42 
QuestionWhich is better C# or VC++.NET Pin
BlrBoy9-Apr-07 2:33
BlrBoy9-Apr-07 2:33 
AnswerRe: Which is better C# or VC++.NET Pin
Colin Angus Mackay9-Apr-07 3:41
Colin Angus Mackay9-Apr-07 3:41 
QuestionBetter to save locally? Pin
Aaron VanWieren9-Apr-07 2:27
Aaron VanWieren9-Apr-07 2:27 
AnswerRe: Better to save locally? Pin
Colin Angus Mackay9-Apr-07 3:40
Colin Angus Mackay9-Apr-07 3:40 
GeneralRe: Better to save locally? Pin
Aaron VanWieren9-Apr-07 5:47
Aaron VanWieren9-Apr-07 5:47 
GeneralRe: Better to save locally? Pin
Colin Angus Mackay9-Apr-07 6:22
Colin Angus Mackay9-Apr-07 6:22 
GeneralRe: Better to save locally? Pin
Aaron VanWieren9-Apr-07 6:33
Aaron VanWieren9-Apr-07 6:33 
QuestionHow to invoke web service method in C#.Net Pin
shanthivasan9-Apr-07 2:25
shanthivasan9-Apr-07 2:25 
AnswerRe: How to invoke web service method in C#.Net Pin
WillemM9-Apr-07 7:01
WillemM9-Apr-07 7:01 
QuestionReport Viewer Pin
vinayak baddi9-Apr-07 2:07
vinayak baddi9-Apr-07 2:07 
QuestionHow to create Poker Game!!! Pin
DukeKing9-Apr-07 1:41
DukeKing9-Apr-07 1:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.