Can OOP use TDBControls?

Hello Experts:

I am fairly new to (real) OOD and OOP.  My background has been mostly Clipper projects (yeah, yeah, we all know Clipper is passe).  Nonetheless, I used all the power in Clipper (code blocks etc) to write code which was somewhat object oriented.  The apps I write are mid size multi-user financial, sales entry, inventory control and reporting systems for vertical markets.  To give an idea of size, some of our clients achieve 1,000,000 plus GL transaction records in a two year span.

I've gained a fairly good grasp of Delphi (2.0) but now I have an OOP question.

In the past, I would never think of placing database fields into a user interface, as the DBControls in Delphi suggest... i.e. To edit a customer, I would assign database fields to memory variables, then exchange upon an explicit post.  With Delphi, it seems one would place the TDBEdits (or the like), directly attached to database fields, onto the editing form, and then use the events from an implicit or explicit post to check validity.  This however, seems to skate away from OOP.

To wit, if you create a TCustomer class (which descends from a TAccount class), you would want the TAccount methods to take care of main account data, and TCustomer to handle customer specific attributes and tasks.  This implies that the form on which a customer gets edited should retrieve field values from a TCustomer object, using TCustomer AND TAccount methods, and likewise post back changes.

Using DBControls, however, seems to bypass such a object based hierarchy, unless I am missing something.  Hence my question.

To maintain an Object Oriented Design, should I be using DBControls for editing objects such as Customers?  If so, would this preclude the use of a TCustomer class while editing the account?  Alternatively, am I better using TEdits, where the form retrieves initial TEdit values from a TCustomer object, which in turn handles all data access, validity, etc.

I have given this question 100 points.  If a truly comprehensive response is in order (as I expect), I will raise the points so I might learn, through your wisdom, the correct methodology.

Thanks in advance.
rickerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mivCommented:
I would NOT use Delphi´s DB Controls.

Make your objects and use a procedure to transfer to and from your user interface.

Let each object have a virtual putdata and getdata function which handles the DB part of the transaction.

I have done this a lot of times, and it just works. You have full control over data, validation and can maintain the OOP idea in your objects.

Hope this helps,
  Michael
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rickerAuthor Commented:
I graded miv's answer as a 'C'.  Reason: I did get an opinion, but  I also only got a regurgitation of what I already know can be done.  I posed my question in a way which I hoped would have elicited a response which clearly states the pros and cons of the alternatives.  I still have the question in my mind...  Why did Delphi spend so much time developing all those DBControls?  And why is spending the time building "getdata" and "putdata" methods worth the effort?
0
mivCommented:
If you´re making "small" programs or using prototyping, the DB controls are very easy and fast to use.
They fits perfectly with the RAPID application development concept of Delphi.

BUT, if you developing a big (>30-50000 lines of code) application, you WILL run into some MAJOR problems along the way.
It will be very difficult to correct errors, re-use code or make a good object oriented program. It´s also very complicated to make team development, if you´re using DB controls or visual design (DFM files).

It´s my experience that visual design (drag and drop) is good for prototyping or very small programs, but if you serious about your program you have to use "hand-coding". It will benefit you in the long run.


0
rickerAuthor Commented:
Thanks for your comments miv....
It still disturbs me, now that I have invested so much time in learning Delhi, that it appears all the RAPID tools are really no good for REAL development.
And that being the case, I don't know why I just shouldn't be switching to C++.


0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.