H
hufel
Hi,
I'm doing my first big project in C# and I'm stuck with a problem that
I believe has a simple and efficient solution for it (I just haven't
bumped into it yet...). The concept is the following:
//Users manage clients. When the system creates the client it must
fetch the information from the DB and allow some modifications:
Client client = new Client("test");
MasterAccount ma = new MasterAccount(1324651);
client.MasterAccount = ma;
PurchaseItems pi = client.MasterAccount.GetPurchasedItems();
FillListview(pi);
// when a user selects a line in the listview, he must have the
possibility to split each line into two or more lines:
pi[0].Subitem[0..n]
// Each Subitem contains in turn two variables that will in turn be
instanced into two new classes:
Subitem si = pi[0].Subitem[0];
si.TypeA = new Type();
si.TypeB = new Type();
//TypeA and TypeB are of the same type. But in turn contain more class
variables inside
si.TypeA.SubType0
si.TypeA.SubType1
si.TypeA.SubType2
si.TypeA.SubType3
//The SubTypes contain only bool variables and a method.
My problem is that this is a representation in a "object oriented way"
(I think) of what the user sees on screen, but in terms of
calculations and memory comsumption it is not efficient, although it
is flexible enough to make future modification easy.
The problem is that now I'm stuck with this concept, and although I'm
trying to model other solutions in UML, I am not getting anywhere in
order to improve this. A friend suggested storing the values in arrays
and looping through it in order to calculate the values but I dislike
the idea due to (in my opinion) complicated implementation and the
fact that the code becomes much more difficult to understand and
modify in the future.
Please correct me if I'm wrong, through ideas in, whatever...
I welcome all suggestions.
PS. I thought about using patterns, like the singleton pattern or the
flyweight pattern, however I haven't seen real live examples and so I
don't understand how I could use them in my application.
Thank in advance
Hugo
I'm doing my first big project in C# and I'm stuck with a problem that
I believe has a simple and efficient solution for it (I just haven't
bumped into it yet...). The concept is the following:
//Users manage clients. When the system creates the client it must
fetch the information from the DB and allow some modifications:
Client client = new Client("test");
MasterAccount ma = new MasterAccount(1324651);
client.MasterAccount = ma;
PurchaseItems pi = client.MasterAccount.GetPurchasedItems();
FillListview(pi);
// when a user selects a line in the listview, he must have the
possibility to split each line into two or more lines:
pi[0].Subitem[0..n]
// Each Subitem contains in turn two variables that will in turn be
instanced into two new classes:
Subitem si = pi[0].Subitem[0];
si.TypeA = new Type();
si.TypeB = new Type();
//TypeA and TypeB are of the same type. But in turn contain more class
variables inside
si.TypeA.SubType0
si.TypeA.SubType1
si.TypeA.SubType2
si.TypeA.SubType3
//The SubTypes contain only bool variables and a method.
My problem is that this is a representation in a "object oriented way"
(I think) of what the user sees on screen, but in terms of
calculations and memory comsumption it is not efficient, although it
is flexible enough to make future modification easy.
The problem is that now I'm stuck with this concept, and although I'm
trying to model other solutions in UML, I am not getting anywhere in
order to improve this. A friend suggested storing the values in arrays
and looping through it in order to calculate the values but I dislike
the idea due to (in my opinion) complicated implementation and the
fact that the code becomes much more difficult to understand and
modify in the future.
Please correct me if I'm wrong, through ideas in, whatever...
I welcome all suggestions.
PS. I thought about using patterns, like the singleton pattern or the
flyweight pattern, however I haven't seen real live examples and so I
don't understand how I could use them in my application.
Thank in advance
Hugo