Re: General EXE/DLL architecture question

Discussion in 'C++' started by Rayiner Hashem, Aug 11, 2003.

  1. > I would like to create an application that uses DLLs and abstraction
    > layers as much as possible.


    I'm sorry, but that phrase really throws up a warning flag.
    Abstractions are a means to an end, not ends in and of themselves. In
    particular, splitting an app into multiple DLLs is usually only a good
    idea when parts of the app need to be dynamically loaded. Other
    reasons (such as minimizing binary size or making it easy to replace
    only parts of an existing installation) are almost always not a good
    idea. Modern operating systems will dynamically page in needed parts
    of an executable, so a 20MB executable is not really a problem. And
    when you change a single module in an app, its usually a better idea
    to retest and replace the whole installation than to replace only a
    single DLL.

    Now if you really need to load code dynamically, consider two ways of
    doing it: if you want to have a plug-in architecture, you want to do
    something like the following:

    Each DLL defines an entry function that creates and returns instance
    of a concrete class that implements the plugin interface (exposed as
    an abstract base class). The main application can then (for example)
    iterate over all the files in a plug-in directory and load the ones it
    needs. In Linux, this would be accomplished via dlopen() to load the
    library and dlsym() to get a pointer to the entry function. I think
    the Windows equivilent is LoadLibrary() and GetProcAddress(). Now,
    each plugin can link to the main executable, which can expose any
    utility functions (like a Log) that the plugins need to use.

    Now if you want plugins that depend on other plugins, you can
    generalize the above mechanism to handle those cases.
     
    Rayiner Hashem, Aug 11, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Muhammad Khan
    Replies:
    4
    Views:
    1,259
    Mike Treseler
    Jul 10, 2003
  2. prem
    Replies:
    1
    Views:
    1,636
    Shankara Narayanan
    Nov 3, 2004
  3. Bren
    Replies:
    1
    Views:
    451
    Gianni Mariani
    Aug 11, 2003
  4. davidb
    Replies:
    2
    Views:
    1,086
    davidb
    Aug 30, 2006
  5. pbd22

    General Question About Web Service Architecture

    pbd22, Jul 24, 2009, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    1,150
    Mr. Arnold
    Jul 29, 2009
Loading...

Share This Page