Delphi 2007 what use is there for a datamodule

Posted on 2009-12-19
Last Modified: 2013-11-23
My applications starts to become swamped with non visual components, most of them for database access so i looked into the TDataModule form. Great i thought - now i can get some structure. Only problem is there seams to be no way i can group them. I want to also have some comments to what each Query does, or what a group of query does. Am i missing something or should i use a regular form for this?
Question by:Sunsales
    LVL 11

    Assisted Solution

    by:Goodangel Matope
    Well, fortunately it is not compulsory to structure things a certain way when dealing with non visual components.

    A Datamodule is a great way to create a semblance of order, especially when you consider that it is possible to have more than one data module per application. You can therefore create a data module for each of the "groups" of queries you are talking about, for instance, create a datamodule called dmFrontOffice for queries used by the front office module of your application, and dmBackOffice for those queries that are used by your back office module. This way, you will be able to group the queries as you see fit, and have some "structure" going.

    Datamodules can also be used to contain functions and procedures which are non-visual, and are used throughout the application, and hence should be in a "central" place and not on individual forms.

    I have seen pretty interesting application structures in my time, but I have noticed that each developer usually has a reason for doing things a certain way. I guess what you will need to do is come up with a structure that works for you.
    LVL 31

    Accepted Solution

    What I did do for a while when originally getting to grips with separating engine from user interface was to use a regular form and treat it like a Datamodule, but to not show it to the end user.  

    Advantage of this method is that you can put informative comments against each non-visual component on there as a means to document what it does, rather than putting such comments into the underlying code.  Also if you want to diagnose code within this module and want to use quick n dirty techniques such as showmessage, a diagnostic dbgrid, or put test queries into a memo on that form then there's nothing to stop you, whereas datamodule won't like that.  

    As goodangel says, you can have as many datamodules as you want in an app, and that is the intended usage.

    Author Closing Comment

    Yep, think i got it. I go with moorehouse concept. Thanx

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now