Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8869991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:36:48+00:00 2026-06-14T17:36:48+00:00

I have a framework that I developed with several classes and components. I would

  • 0

I have a framework that I developed with several classes and components. I would like to create a main object with access to the entire framework so that all developers can access the methods from a single location.

Example:

MyApp.Framework.DataBase
MyApp.Framework.DateUtils
MyApp.Framework.Users
MyApp.Framework.System

The object MyApp maps entire framework and all developers have full access at any time.

The main question is to create a structure that is robust and easy to expand. After a while I would include a structure of functions and methods of the products of our company.

Example:

MyApp.Blog.    (functions about Blog product)
MyApp.WebDocs. (functions WebDocs product)

More example about class:

TMyAppBase = Class
Private
  Function GetDatabase: TDataBaseClass;
  Function GetUsers: TSystemUsersClass;
  Function GetForms: TFormManager;
Public
  Constructor Create; Virtual;
  Destructor Destroy; Override;
  Property Database: TDataBaseClass Read GetDatabase;
  Property Users: TSystemUsersClass Read GetUsuarios;
  Property Forms: TFormManager Read GetForms;
End;

Using this class:

var
  LMyApp: TMyAppBase 

begin
  ShowMessage(LMyApp.Users.ActiveUserName);
end;

Would that be friends, I would like if possible ideas from yours. My intention its create a single and expansive structure.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:36:49+00:00Added an answer on June 14, 2026 at 5:36 pm

    As I’ve already wrote in my comment, I think in this case it is a good idea to use one main Service (main class, singleton) wich can provide you access to other services. All your modules have unique ID (TGUID). At the beginning of program execution they should register themselves in main service.
    for example. main service unit:

    unit AppServices;
    
    interface
    uses generics.collections, rtti;
    type
        // Unique ID Attribute for services
        ServiceIDAttribute = class(TCustomAttribute)
          strict private
            FId : TGUID;
          public
            constructor Create(ServiceID: string);
            property ID : TGUID read FId;
        end;
    
        //Services Base class
        TCustomAppService = class(TObject)
          strict protected
          public
        end;
    
        // Main Service Object
        TAppServices = class(TObject)
          strict private
           class var
            FServices : TObjectDictionary<TGUID, TCustomAppService>;
           var
          public
            class constructor Create();
            class destructor Destroy();
            class procedure RegisterService(aService : TCustomAppService);
            class function QueryService(ServiceID : TGUID):TCustomAppService;
        end;
    

    here class constructor & destructor simply creates and frees FServices Dictionary. QueryService method returns Service by its unique ID:

    class function TAppServices.QueryService(ServiceID: TGUID): TCustomAppService;
    begin
        result := nil;
        if FServices.ContainsKey(ServiceID) then
            result := FServices[ServiceID];
    end;
    

    Method RegisterService extracts RTTI Attribute (ServciceIDAttribute) from parameter’s class name and adds this pair (id-service) to dictionary:

    class procedure TAppServices.RegisterService(aService: TCustomAppService);
    var ctx : TRttiContext;
        st : TRttiType;
        a : TCustomAttribute;
        id : TGUID;
    begin
        ctx := TRttiContext.Create();
        try
            st := ctx.GetType(aService.ClassType);
            for a in st.GetAttributes() do begin
                if not (a is ServiceIDAttribute) then
                    continue;
                id := ServiceIDAttribute(a).ID;
    
                FServices.AddOrSetValue(id, aService);
                break;
            end;
        finally
            ctx.Free();
        end;
    end;
    

    now, about end-services. For example UserManager unit:

    unit UserManager;
    
    interface
    uses AppServices;
    
    const
        SID_UserManager : TGUID = '{D94C9E3A-E645-4749-AB15-02631F21EC4E}';
    type
        [ServiceID('{D94C9E3A-E645-4749-AB15-02631F21EC4E}')]
        TUserManager = class(TCustomAppService)
          strict private
            FActiveUserName: string;
          public
            property ActiveUserName: string read FActiveUserName;
        end;
    
    
    implementation
    
    
    initialization
        TAppServices.RegisterService(TUserManager.Create());
    end.
    

    now we can test our code:

    procedure TestApp();
    var uMgr :TUserManager;
        dbMgr : TDBmanager;
    begin
        dbMgr := TAppServices.QueryService(SID_DBManager) as TDBManager;
        if dbMgr.Connected then
             writeln('connected!')
        else writeln('not connected');
    
        uMgr := TAppServices.QueryService(SID_UserManager) as TUserManager;
        writeln('Active user: ', uMgr.ActiveUserName);
    end;
    

    summary:
    TAppServices is the main object, wich provides access to any service in App. It knows nothing about end-services, so it has no dependencies. you can change its implementation as you wish.
    You may have as many TCustomAppService class descendants as you need. When you add new service to application, you shouldn’t change TAppServices class interface or implementation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a framework that is used by several teams in our organisation.
I have a asp.net web site that was developed on the .Net Framework v2
I have been looking around for a visualization framework that would aid graph visualization
I have a service that was developed in the .NET 2.0 framework. It is
I have developed a .NET solution that consists of several assemblies, most of which
My Google foo is failing me. If I have some framework that can do
We have a pluggable framework that returns ActionResult objects that render things to a
I have a change tracking framework that tracks changed made to domain objects on
I have built an API framework that includes a lot of communication-related options, including
I have a jquery ui framework that is constructing the Date Picker elements. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.