Metric design question

C

cbmeeks

Man, I realize I've been asking a lot of questions lately.

I appreciate you guys helping me in my thought process.

This time, I have a design question I want opinions on.

I'm building a business framework for tracking trending data. I have
a class like:

class Metric
{
public double Value {....property for a calc...}
public DateTime StartDate;
public DateTIme EndDate;
public bool IgnorePeriodDates;
public List<Metric> ChildMetrics;
}


Now, I can:

Metric m = new Metric;
m.StartDate = "04/01/2008";
m.EndDate = "04/10/2008";
m.Value; // returns all values from StartDate - EndDate

That's not exactly like I have the class but you should get the idea.
You will notice that Value returns a calculation based on the Start/
EndDate. Also, note there is a list of children metrics. The Value
property will return (recursively) all child values. So when you call
a m.Value, you get that metric's values + all children's values.

Now, all child metrics can have their own Start/End dates.

So, if you set "IgnorePeriodDates" to true (default false), you get
back ALL values ignoring the dates and ignoring the children's dates
from the metric down.

Now, if all child metrics had their IgnorePeriodDates set to false
(the default) and you got back the Value of a parent metric (who's
IgnorePeriodDate is true), then all children's IgnorePeriodDate would
be ignored.

Hope this makes sense.....LOL!!

Now, my question:

IF I were to get the value of a child metric who's IgnorePeriodDates
value is false (the default), SHOULD I run UP the tree and see if the
child's parent's IgnorePeriodDate is set to true? In other words,
should children ALWAYS have to respect their parent's properties?

I promise to keep these long-winded questions to a minimum! hahaha

Thanks
 
C

cbmeeks

[...]
IF I were to get the value of a child metric who's IgnorePeriodDates
value is false (the default), SHOULD I run UP the tree and see if the
child's parent's IgnorePeriodDate is set to true? In other words,
should children ALWAYS have to respect their parent's properties?

Only you can answer that question. You can do it either way, and which
way is correct depends on your business design goals.

I'm a little confused by the example, as it appears to use properties to
define filtering criteria, which in your previous question seemed to be
something you really wanted to avoid.

But regardless...if you want children instances to respect the parent
values, that's certainly easy enough to implement and would work fine. If
that's how your design needs to work, you can do it. If not, you can do
it the other way. You could even make it configurable per-child (add a
property that tells the child whether to inherit the parent properties or
not).

Pete

Yeah, I've decided to use properties. I actually like the syntax now
that I've made some examples. My business framework will hopefully be
a commercial product one day so I am trying to keep flexibility in
mind.

I am hope my "nicheness" will be in that my framework will offer
infinite metric recursion with custom calculations. Uh oh...I just
gave away my secret. lol

Seriously, I like the idea about the "Inherit From Parent" property.
I might look into that as well.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top