[fpc-pascal] Adding method dynamically to a class

kyan alfasud.ti at gmail.com
Wed Jun 20 10:38:44 CEST 2012

I suggest that you implement this using interfaces. You place the
interface declaration in a common file, use the interfaces from the
main exe but implement them in separate dlls. This gives you all the
flexibility you want, e.g. group your methods into bundles and place
them on different interfaces. You will only need a class identifying
system (i.e. a "class id" string) that will be known to the exe and
implementing dlls and a "factory" exported function in each dll that
creates the implementing object of a known "class id". You can have
many alternate implementations of an interface with different class
ids and you can even replace an implementing dll with another version
of it with bug fixes or even different functionality.

In my mind it is always <Plugin System> ==> Interfaces.


On Wed, Jun 20, 2012 at 11:14 AM, ik <idokan at gmail.com> wrote:
> The idea of implementing it like so, came to me after few years now of
> having the need to recreate the whole logic based of the code for every new
> demand from the client (both as human, and as software). The main code
> almost never changes, but so many additions, that I'm starting to use the
> dynamic execution of methods, and now I realize, that if I'll extract it to
> a shard library, it will be much easier to change, add etc... only the
> actual need, and not to touch other stuff, and that requires me to design an
> engine instead.

More information about the fpc-pascal mailing list