Efficiently access either of two Delphi datamodules with same dataobject names -


I have an ugly situation where I need two data modules (TDMA, TDMB) in a Delphi app. Each data model has the same data object name (queries, tables, etc.), but from a different component set (TZQuery, TADOQuery). I need this because I want to support many databases, but not all databases are supported by my component suite. Whatever datamade I need to access is determined by the DBFlag boolean variable. Even though there is almost the same code segment for each data access, is there a more efficient way?

If I can set a DMA or DMB based on DMAG or DMFLAG like a global Datum module of DMF, then my code would be ideal rather than DMG DMA or DMB and very few code modifications would be required. Impossible to know as much as I know.

My suggestion is to skip creation of your DataModules based on specific datasets Use them only by using TClientDataSet and type all your code or link all your DataSources to these datasets, then to capture your specific datasets, and for examples of CDs To use your selection method to answer as a data provider, other Create DataModule The idea of ​​using an interface to do this is really good.

This approach will remove all your duplicate code and you will strongly separate the business logic (code that handles the data inside the CDS) (the code that transports data lines from data servers).


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -