Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.pascal.delphi.misc > #318
| From | Hans-Peter Diettrich <DrDiettrich1@aol.com> |
|---|---|
| Newsgroups | comp.lang.pascal.delphi.misc |
| Subject | Re: What is best ? |
| Date | 2012-06-08 11:00 +0200 |
| Message-ID | <a3dptpFupqU1@mid.individual.net> (permalink) |
| References | <4fcf960a$0$1374$4fafbaef@reader1.news.tin.it> <4fd065b9$0$6961$e4fe514c@news2.news.xs4all.nl> <4fd0c1ae$0$1387$4fafbaef@reader2.news.tin.it> |
Stark schrieb: > Thank you for all of your comments. But I am still unclear on whether it > is reasonable to use an obiect oriented approach (my oo approach rather..). > I try to explain better what I am doing. I have a working program that > does basically the following: > - A function (GetBudgetProposals) accesses a dataset where each record > represents one account and has 12 fields with the budgets amounts and > retrieves the needed data which are retuned in a StringList. > - As many StringLists as many accounts are filled from the dataset. Each > StringList has the account number and 12 amounts. > - These data that are presented on the screen for the user to examine > and change. > - When done, all the data are written back on the budget dataset. Since a stringlist *is* a class, question is whether this class is appropriate for solving your problem. > I am using this program to learn object orientation, which I know on > theory. My idea of using an oo approach was to create two class objects: > the first, for storing each single account data. The second for storing > all of the first object. > I am stuck at the first, which is the one I gave an example code of. I > though I had two alternatives: > -Use the above function to retrieve the data and then copy those into my > object when creating it, or > -Give the object itself this task thorough a similar function. You can do that as you like, or as is easier to implement for you. > Just let me know if there is any sense in all this. I am sure I will > learn more from you, then reading bunch of books (which I am also doing..). > > PS: As far as your suggestion to use TObjectLis, let me understand your > comment. What I am planning to store in this object is a serie of 12 > amounts (100, 150, .... 120). I thought I would need a StringList for > this. Is this wrong ? A StringList holds strings. If you are happy with your amounts *being* strings, then a StringList is a reasonable choice. Then you can store all the StringList objects in an TObjectList. But you can store them also in another StringList, using its Objects[] property for the lists, and the Strings[] property for descriptive names. When you have a database, then a DBGrid might be a better solution for processing your data, because it already loads and stores the values itself, and also manages the display and editing of the values. > PS: You say: >> You are using the stringlist as a container for objects... > The stringList will contaim amounts. Are they objects? The StringList contains strings. Whether these strings denote amounts is up to the reader. If you e.g. want numeric values only, then the strings only can be *representations* for numeric amounts, and the user should be restricted to enter only strings which represent *valid* amounts. When you separate the display and editing from the internal representation of your data, then storing amounts *as* strings may not be the right decision, even if it simplifies the transportation of the amounts into GUI elements. Instead your classes should contain amounts as numeric values, which are converted into strings when needed for display/editing purposes, and back again after the user has edited an item. I'd suggest that you rewrite your code, and replace the TStringLists by something else, that better represents your data. You also didn't tell us the database (table...) structure behind the DataSet, perhaps you should change that, too, to contain numerical values instead of strings. Then come back and ask again what's unclear to you. DoDi
Back to comp.lang.pascal.delphi.misc | Previous | Next — Previous in thread | Next in thread | Find similar
What is best ? "Stark" <franco.jommi@tin.it> - 2012-06-06 19:41 +0200
Re: What is best ? "Maarten Wiltink" <maarten@kittensandcats.net> - 2012-06-07 10:26 +0200
Re: What is best ? "Stark" <franco.jommi@tin.it> - 2012-06-07 16:58 +0200
Re: What is best ? "Maarten Wiltink" <maarten@kittensandcats.net> - 2012-06-07 17:49 +0200
Re: What is best ? "Stark" <franco.jommi@tin.it> - 2012-06-08 14:59 +0200
Re: What is best ? "Maarten Wiltink" <maarten@kittensandcats.net> - 2012-06-08 16:33 +0200
Re: What is best ? "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2012-06-07 22:28 +0200
Re: What is best ? "S.G" <S.G@none.special.ch> - 2012-06-08 01:07 +0300
Re: What is best ? Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2012-06-08 11:00 +0200
Re: What is best ? "Stark" <franco.jommi@tin.it> - 2012-06-08 15:17 +0200
Re: What is best ? "S.G" <S.G@none.special.ch> - 2012-06-13 09:16 +0200
Re: What is best ? "Maarten Wiltink" <maarten@kittensandcats.net> - 2012-06-14 00:06 +0200
Re: What is best ? "S.G" <S.G@none.special.ch> - 2012-06-14 09:08 +0200
Re: What is best ? "Stark" <franco.jommi@tin.it> - 2012-06-15 16:47 +0200
Re: What is best ? "Maarten Wiltink" <maarten@kittensandcats.net> - 2012-06-15 22:41 +0200
Re: What is best ? "Maarten Wiltink" <maarten@kittensandcats.net> - 2012-06-16 07:27 +0200
Re: What is best ? "Stark" <franco.jommi@tin.it> - 2012-06-16 14:50 +0200
csiph-web