I am creating a framework (for internal use only), which has a common code among 3 4 applications of delphi CRD applications.
A common object in the mi framework is TContext,
TContext = class (IContext) function DB: IDatabase; function CurrentSettings: ISettings; .. end;
which is passed to the initialization method for many other objects .. example (this will be the application code):
TCustomer.Initialize(Context: IContext) TProjectList.Initialize(Context: IContext) ..
Each application has some specific contextual functions (which will be called only from the application code):
IApp1Context = interface (IContext) procedure DoSomethingSpecificToApp1; procedure DoOtherThing; .. end;
Therefore, when I create a context, Im creates an IApp1Context and sends it to the initialization methods .. everything is fine from the structure code, the problem is that from the application code I constantly transfer from IContext to IApp1Context to access specific App1 it works .. so that the whole my application code looks like (and its a lot of code like this):
(FContext as IApp1Context).DoSomethingSpecificToApp1 (FContext as IApp1Context).DoOtherThing; ..
The thing is clearly applicable, but, in my opinion, it does not read well. Maybe I'm exaggerating; Is there a clever technique for this situation that I donβt know about?
pragmatic_programmer
source share