Defaults / Design / ReadOnlyBase

Defaults / Design / ReadOnlyBase

Old forum URL: forums.lhotka.net/forums/t/3731.aspx


juddaman posted on Wednesday, October 17, 2007

Hi all

Just after some feedback on some design decisions I've made.

All my defaults that affect the way the app works are stored in the db. These can be modified through a form bound to a Config object.

I have a class, InsertDefaultBreaks (subclasses ReadOnlyBase), which modifies a TimeSheet object, this retrives the users default breaks value
for the day of week for which the time sheet represents.

This kind of thing:

if (!dr.GetBoolean("UseDefaultBreaks")
{
 return;
}

switch (criteria.Date.DayOfWeek)
                    {
                        case DayOfWeek.Monday:
                            if (dr.GetBoolean("MonSpecific"))
                            {
                                defaultBreaks = dr.GetInt32("MonBreaks");
                            }
                            break;
                        case DayOfWeek.Tuesday:
                            if (dr.GetBoolean("TueSpecific"))
                            {
                                default......

 

Any general feedback on this would be great. Particularly is loading the defaults into the objects as they need them the best method.
It seams the most proper.

Also I'm calling the static method in InsertDefaultBreak when an event (a list changing) fires in my TimeSheet object, the time sheet object is passed
to the static method called in InsertDefaultBreak. Is this the system starting a use case?
Or just a sub-use-case of the user choosing to modify the timesheet?

George

richardb replied on Wednesday, October 17, 2007

If I have understood correctly, you could set the defaults in the DataPortal_Create method of your timesheet object, going to the database to get them. 

In your factory method for creating a timesheet you could supply the UseDefaults parameter (and any others that might help to get your defaults)

e.g. (Psuedo Code) 

Dim UseDefaults as Boolean = True
Dim myTimesheet as TimeSheet = TimeSheet.NewTimeSheet(UseDefaults)

Copyright (c) Marimer LLC