Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Can OOP use TDBControls?

Posted on 1997-05-05
4
Medium Priority
?
273 Views
Last Modified: 2013-11-23
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.
0
Comment
Question by:ricker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
miv earned 200 total points
ID: 1335923
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
 

Author Comment

by:ricker
ID: 1335924
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
 
LVL 1

Expert Comment

by:miv
ID: 1335925
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
 

Author Comment

by:ricker
ID: 1335926
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question