Tips need for building an application framework

Hi,

Can some of you give me some tips about how to build an application framework?

What I have done is;

(1) Define a base class with some virtual functions (abstract class)
(2) Derive a class from base and implement all the functions
(3) Build implementation into a static library

(3) Provide a header file which include only base class & library to client application (I want to hide all the impelmentation details from client application.
(4) in client application, declare a void pointer
(5) in client app, try to downcast pointer to derived class in library (no compiling error)
(6) make a call to functions (e.g ptr->method1, compilig error ?)

I know some wrong, but don't know where problem is? Is it the right way to build an application framework?

Please help,

Thanks in advance,
[879 byte] By [D002199] at [2007-11-18 1:36:11]
# 1 Re: Tips need for building an application framework
There is no need to derive a class from a virtual base class to hide implementation details -- "implementation" being the code behind member functions. If you want to hide structure details, then you can do something like:

// Definition of _MyClassPrvtData in some C/C++ file.
typedef struct _MyClassPrvtData* MyClassPrvtData;

class MyClass
{
MyClassPrvtData data;

public:
// ...
};


That being said, don't worry about this in practice (unless you have a really, really good reason to). The fact that you declare data in your private section of a class tells the users of your library to not rely on anything in it because you may change how you implement that part.

- Kevin
KevinHall at 2007-11-8 1:16:52 >
# 2 Re: Tips need for building an application framework
Here are some points that I would suggest:

You don't necessarily need a base object for the hierarchy of your entire framework. Some frameworks (MFC, Qt, etc.) do this, but these often become restricting due to the coupling (particularly if the framework is to grow and change), and flatter code is often desirable.
Implementation hiding does not mean hiding all derived headers. I doubt your contention that this compiles, as the syntactic analysis phase could not complete without declarations. Often, implementation hiding is done with a Bridge pattern or pimpl (similar ideologies of using a compiled implementation class contained and used in the interface class).
Get rid of the void pointer. Your framework has just lost all type safety and might as well be assembly. Use true polymorphism.
galathaea at 2007-11-8 1:17:58 >
# 3 Re: Tips need for building an application framework
Thank you very much for your suggestion!

I will do some practices to really digest what you have suggest,

By the way, where can I find some articles regarding "Bridge Patten" ?

Thanks again,
D002199 at 2007-11-8 1:19:02 >
# 4 Re: Tips need for building an application framework
Here ( http://selab.korea.ac.kr/selab/courses/GoF-patterns/bridge.htm) is one source of information. But I just did a google search on:
"hiding implementation" bridge
to find it, and alot of other good sources popped up as well!
galathaea at 2007-11-8 1:19:56 >