Page 1 of 2

How to design a Framework ?

Posted: Thu Apr 27, 2006 2:51 am
by waqas_punjabian
Hi everybody,

i am a mid level programer of PHP, i 've also used a couple of already built frameworks, like NUCLEUS and MAMBO,

i am really impressed with them, but the problem is :

"Can i make my own Framework ? and if it is Yes! then How can i do that ?" Please tell me i don't know how to start to get the Framework Building Concepts,

Furthermore, i am involved in making E-commerce based websites, Someone told me if i 'll build a common Framework that can be used in most of E-commerce websites. is it possible ?

"Please refer me some website or some helping material and the coding tips in this regard"

thanks in advance

regards
Waqas

Re: How to design a Framework ?

Posted: Thu Apr 27, 2006 10:20 am
by alex.barylski
waqas_punjabian wrote:Hi everybody,

i am a mid level programer of PHP, i 've also used a couple of already built frameworks, like NUCLEUS and MAMBO,

i am really impressed with them, but the problem is :

"Can i make my own Framework ? and if it is Yes! then How can i do that ?" Please tell me i don't know how to start to get the Framework Building Concepts,

Furthermore, i am involved in making E-commerce based websites, Someone told me if i 'll build a common Framework that can be used in most of E-commerce websites. is it possible ?

"Please refer me some website or some helping material and the coding tips in this regard"

thanks in advance

regards
Waqas
Yes. By studying existing frameworks and coming to your own conclusions. Yes.

If you have to ask this question, your probably not ready to begin designing a framework especially for use in production code...

There is a big difference between using a framework and how one works conceptually...

Cheers :)

Posted: Thu Apr 27, 2006 11:35 am
by timvw
Yes you can, will it be useful? probably not... I think you'll learn more from using a couple of already existing frameworks and trying to change a couple of things in them... Once you've discovered which parts you don't like you can start thinking about how this could be improved and then apply the patches to the existing frameworks.. or start your own... Untill then i really don't see the need...

Posted: Thu Apr 27, 2006 11:42 am
by Christopher
First, "NUCLEUS and MAMBO" are not frameworks -- the are applications (CMSs specifically). They may or may not be build on top of a framework.

A frameworks is really just a set of libraries designed to work together. You can certainly build one or use an existing one. With an existing frameworks you do not have to maintain the code. And in my opinion, code produced by a team is better than code produced by an individual.

Posted: Sat Apr 29, 2006 12:56 am
by waqas_punjabian
Yes exactly,

thanks a lot u all got my point,

now please tell me some already built framework or some cms which could be helpful in Ecommerce based websites.

But again the thing is, i didn't find any way to start working on my own Framwork, so please tell me from where to start ?

thanks n regards

WAQAS

Re: How to design a Framework ?

Posted: Sat Apr 29, 2006 2:39 am
by alvinphp
waqas_punjabian wrote:Hi everybody,

i am a mid level programer of PHP, i 've also used a couple of already built frameworks, like NUCLEUS and MAMBO,

i am really impressed with them, but the problem is :

"Can i make my own Framework ? and if it is Yes! then How can i do that ?" Please tell me i don't know how to start to get the Framework Building Concepts,

Furthermore, i am involved in making E-commerce based websites, Someone told me if i 'll build a common Framework that can be used in most of E-commerce websites. is it possible ?

"Please refer me some website or some helping material and the coding tips in this regard"

thanks in advance

regards
Waqas
Yes it is possible and I personally prefer to have my own. The extra work (IMHO) is minor and there is much less wasted code (assuming you code correctly) as all your methods are used. I start with a very very simple framework and then add to it as needed.

Posted: Sat Apr 29, 2006 6:19 am
by timvw
Given the following definition:
arborint wrote:A frameworks is really just a set of libraries designed to work together.
The best start for a framework would be to look at your already existing applications, to identify the code/mechanism that occur quite often in them and try to generalize this code/mechanism so that it can be used in all possible situations that you will encounter... Bundle all these mechanisms and you've got yourself a framework..

If you have a good look at all those existing frameworks you'll see that they did try to solve the same problems (sometimes your approach will be better, usually you'll be amazed by their solution)

Posted: Sat Apr 29, 2006 8:38 am
by Buddha443556
A frameworks is really just a set of libraries designed to work together.
I would disagree with that definition.
The framework provides a context for the components in the library to be reused.
- Ralph Johnson
If you look at a framework as just a set of libraries then that's what you'll get which isn't a framework. The "extra work" to go from code/class library to an actual framework is major.

Posted: Sat Apr 29, 2006 11:33 am
by Christopher
Buddha443556 wrote:I would disagree with that definition.
The framework provides a context for the components in the library to be reused.
- Ralph Johnson
If you look at a framework as just a set of libraries then that's what you'll get which isn't a framework. The "extra work" to go from code/class library to an actual framework is major.
I believe we are saying the same thing as didn't say that a framework is "just a set of libraries." I was specific that they were "designed to work together" which is a non-fancy way of saying "provides a context for the components in the library to be reused." I am assuming that "work together" means that the libraries can make use of each other, whether as componenets or distinct classes/functions.

Posted: Sat Apr 29, 2006 12:43 pm
by alex.barylski
Buddha443556 wrote:
A frameworks is really just a set of libraries designed to work together.
I would disagree with that definition.
The framework provides a context for the components in the library to be reused.
- Ralph Johnson
If you look at a framework as just a set of libraries then that's what you'll get which isn't a framework. The "extra work" to go from code/class library to an actual framework is major.
I agree...

http://www.marcclifton.com/Articles/Des ... fault.aspx

Explains what a framework is and isn't quite nicely...at least from his perspective :P

Posted: Sat Apr 29, 2006 12:53 pm
by Buddha443556
arborint wrote:I believe we are saying the same thing as didn't say that a framework is "just a set of libraries." I was specific that they were "designed to work together" which is a non-fancy way of saying "provides a context for the components in the library to be reused." I am assuming that "work together" means that the libraries can make use of each other, whether as componenets or distinct classes/functions.
Maybe we are saying the same thing. I'm not sure everyone appreciates the distinction though. :oops:

Posted: Sat Apr 29, 2006 12:54 pm
by alex.barylski
arborint wrote:
Buddha443556 wrote:I would disagree with that definition.
The framework provides a context for the components in the library to be reused.
- Ralph Johnson
If you look at a framework as just a set of libraries then that's what you'll get which isn't a framework. The "extra work" to go from code/class library to an actual framework is major.
I believe we are saying the same thing as didn't say that a framework is "just a set of libraries." I was specific that they were "designed to work together" which is a non-fancy way of saying "provides a context for the components in the library to be reused." I am assuming that "work together" means that the libraries can make use of each other, whether as componenets or distinct classes/functions.
I know what your saying...and don't discount the fact that you very well likely understand and know what a framework is, but...

Just because classes/libraries have knowledge of each other and can work with each other doesn't make it a framework...it makes the libraries dependant on each other...

A framework offers a context for which those libararies and functions/classes can work togather but not directly, but rather this communication of components, etc is handled by the framework...hence the context part...

Thats, IMHO what a framework is and how it's different from just a couple of libraries, etc which have dependencies with each other...

Its like...if you had phpMailer is one directory and associated email functions, etc...you'd have a email library, which by itself is not dependant on anything...

Then you might have Smarty, which is a library in it's own right...but smarty might be extended to use the phpMailer class to email admin when something chokes...

Smarty thus becomes dependant on phpMailer and the 2 libraries work togather - or atleast the communication lines would become two way, if phpMailer used Smarty to display errors to screen...

In this sense, they are communicating and working togather by no means a framework...whereas if you had an index.php which used the generic phpMailer (didn't depend Smarty and visa-versa) and Smarty togather in index.php...

This would serve as a *very crude* example of a framework, although not a framework, because it's not very reusable...

It does however, exemplify the point and difference I am trying to make...

Libraries can work togather and be dependant on each other, but that doesn't mean their a framework...look at PEAR...it's a library...collection of classes with heavy dependancies on each other (thus the reason I try and not use it).

Just my two cents to add to the subject :)

Posted: Sat Apr 29, 2006 3:41 pm
by Christopher
Buddha443556 wrote:Maybe we are saying the same thing. I'm not sure everyone appreciates the distinction though. :oops:
I am positive that they don't, but I also don't think many (myself included) appreciate what "provides a context for the components in the library to be reused" means.

Say that "the components in the library" are the classes/functions. And say that "a context" really means the same thing as "a framework." And that "resued" really just means "used." So what Mr. Johnson is saying is that "A framework provides a framework for classes/functions to be used" which is not saying much. I fully acknowledge that I am twisting his words -- but unfortunately not by much.

Maybe because "work together" sounds simple people think it is simple -- but in fact the more I think about it -- the more I think that a framework is a group of libraries made to work together. One of the hardest things to do is to make libraries "work together," just ask any framework designer.

If you want to say that once those libraries "work together" they provide a "context for reuse" then I would agree with that.

Posted: Sat Apr 29, 2006 5:44 pm
by Buddha443556
arborint wrote:If you want to say that once those libraries "work together" they provide a "context for reuse" then I would agree with that.
A framework not only provides for code reuse but more importantly (imho) design reuse. Frameworks are basically generalization of group of applications. An abstraction of a problem domain. A reusable design of an (a type/kind of) application. I think we're just emphasizing different aspects of a framework here.
One of the hardest things to do is to make libraries "work together," just ask any framework designer.
Don't even have to ask the designers, just look at all the php frameworks that have failed. It's not an easy task.

Explaining the concept of a framework is probably right up there with explaining the concept of an object either one can make my head hurt.
First Rule of Framework Design: Don't.
Don't do it if you don't have too. Don't do it one already exists. Don't forget the aspirin if you do it.

Posted: Sat Apr 29, 2006 6:50 pm
by Christopher
Agreed, agreed, agreed.
Buddha443556 wrote:A framework not only provides for code reuse but more importantly (imho) design reuse. Frameworks are basically generalization of group of applications. An abstraction of a problem domain. A reusable design of an (a type/kind of) application. I think we're just emphasizing different aspects of a framework here.
This is the part that my glibness glossed over. ;)

It is the design reuse that is probably the most important thing. A good framework makes best practices the path of least resistance. A great framework has you implementing best practices you've never heard of without even knowing it.