what should be the Object model

what should be the Object model

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


vijay posted on Thursday, June 26, 2008

I need some help in deciding the type of objects we should be usign for following scneraio.

 

I have some information that is stored at Country (table t_country) and State (table t_country_state) level. User is allowed to do operation (update or delete) on multiple records at a time and records are displayed in Grid control.

 

To work on records user can select

1. Country or

2. Country and any of the States of that Country.

 

When use selects first option (Country) all operations are done on table t_country. If user selects Country and State only table impacted is t_country_state.

 

Initially I thought of using Editable Root List and Editable Root object for this and pass State as NULL whenever use wants to work at Country. Is that correct way of implementing? Or should we have different set of objects for Country and State? How should we implement State objects so that they are not exposed to the Country directly and only used through the Client.

Let me know if someone need more information about this.

Thanks

Zafar Ullah replied on Monday, July 07, 2008

Vijay,

Go with the 2nd option i.e create different object for both entities. It will stream line your handling and calling both objects based on the selection.

Your code might look like

ddl = dorpdownlist

if(ddl.SelectedValue == "Country")

{

      Country objCountry = Country.GetCountry();

      objCountry..........

}

else

{

      State objState = State.GetState(); // also pass country

}

Hope it helps

vijay replied on Monday, July 07, 2008

Thanks Zafar for your time.

We have decided to go for second approach.

Copyright (c) Marimer LLC