Designing Problem -- Confuse In Design --

Designing Problem -- Confuse In Design --

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


st3fanus posted on Tuesday, January 19, 2010

Hi all..
I'm sorry if my post is too long.. because I don't have another friends to discuss CSLA in my city..

I want to share about my scenario :
Use Case :
"I want to create a lot of Table once using one Form to generate several table object(in memory) and then save them all once to DB..
But I want to edit each Table later using one Form that Bind to one Table object to save it indiviually
And the last, I want to delete a table one by one from selected it
from a list of readonly tables object as the user requested"

From This Scenario I have created :
1. TableInfo inherit from ReadOnlyBase act as Read Only Child
2. TableInfoList inherit from ReadOnlyListBase act as Read Only Root Collection
3. Table inherit from BusinessBase
4. TableList inherit from BusinessListBase

both of no 1 and 2 object is used to display in listview for example.
But to accomplish requirements at blue and red sentences i got a confuse on design Table Class.
To accomplish Blue Sentence I design :

INSIDE table class
        private void DataPortal_Create(SingleCriteria<Table, int> criteria)
        {
            LoadProperty(NoProperty, criteria.Value);
            LoadProperty(NameProperty, "Table " + criteria.Value.ToString());
        }

that code will be called initially from :
INSIDE TableList
private void DataPortal_Create(SingleCriteria<TableList,int> criteria)
        {
            RaiseListChangedEvents = false;
           
            int max_no = 0;
            using (var ctx = ConnectionManager<SqlConnection>.GetManager("Resto_DB"))
            {
                using (TableListDal dal = new TableListDal(ctx))
                {
                    max_no = dal.GetSizeOfTable();
                }
            }

            if (criteria.Value > 0)
            {
                for (int i = 0; i < criteria.Value; i++)
                {
                    max_no += 1;
                    this.Add(Table.NewTable(max_no));
                }
            }

            RaiseListChangedEvents = true;
        }


After several NEW Table object is created in memory , and already manipulated, there is a requirement to save them all once, So I design :
INSIDE Table Class
private void Child_Insert()
        {
            int _noT = ReadProperty(NoProperty);
            string _nameT = ReadProperty(NameProperty);
            short _floorT = ReadProperty(FloorProperty);
            using (var ctx = ConnectionManager<SqlConnection>.GetManager("Resto_DB"))
            {
                using (TableDal dal = new TableDal(ctx))
                {
                    dal.InsertTable(new TableDTO(_noT, _nameT, _floorT));
                }
            }
        }

that code will be called from :
INSIDE TableList class
[Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_Update()
        {
            base.Child_Update();
        }


All above have saved create new and save them to DB successfully.

AND THEN for Brown requirement :
I design :
DataPortal_Fetch() method inside TABLE class because that object will be act as Root in individual form which is bound to that Table Object. And then will save that object directly using DataPortal_Update() method inside Table class And DataPortal_Delete() to delete that object indivually


Because of my design above I confuse what is the stereotype of my class that my design take to accomplish this requirement ??, Is it called with Switchable Objects ?
Is there any another better solution or design to accomplish this requirement ?
OR Am I must design indivual class for it's role in each use case task that is not confusing ?(Create another class for Table as Child, and another Table class that act as Root )..?

Thanks a lot

Stefanus

st3fanus replied on Friday, January 22, 2010

Hi All..
Thanks to read my posting..

I wish any feed back from everyone about my posting..

Thanks a lot


Stefanus

Copyright (c) Marimer LLC