views:

69

answers:

3

Are there any resources on how to design frameworks, i.e. tips and tricks, best practices, etc..

+4  A: 

For .NET there's

Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries
http://www.amazon.com/Framework-Design-Guidelines-Conventions-Libraries/dp/0321545613

You can also study frameworks like Spring.

Robert Harvey
+1 I have this book, very good book to use as reference when designing a framework on .NET.
Carlos Loth
+1  A: 

In regards to PHP ehre are some Tips from me:

Use MVC as your framework type.

MVC (Model-View-Controller) is the best way to create a framework, keeping your Logic and Models separate to your Views etc is the best way to accomplish a fresh clean application.

I believe thatStack Overflow uses a MVC pattern, Not sure if its PHP / ASP tho.

Make your code as open as possible.

Meaning that practically any object is accessible throughout the application.

A way i achive this is by creating a static class that as a global scope to overcome the problem, for example:

class Registry{....}

Registry::add('Database',New Database);
Registry::add('Input',New Input);
Registry::add('Output',New Output);

then anywhere throughout the application you can easily get objects like so:

Regsitry::get('Database')->query('Select .... LIMI 10')->fetchObject();

Do not use template engines

In my eyes template engines are not the best as PHP is itself a template engine, there's no need to create a lot of code to parse your templates and then have PHP parse it again, its logical.

Instead create an system where the user will tell the View what template file to output and check the catch for that, if its not in the cache then that object will transfer it to another object called lets say ViewLoader, Witch within the __Construct it includes the php template file, but also has other methods like url() and escape() etc so in tempalte fiels you can then use

$this->url('controller','method',$this->params);

Hope this helps you!

RobertPitt
I'm sorry but... does this answer the question (which is about how to design an framework, not how to implement a web application in PHP)?
Pascal Thivent
He asked for tips,tricks and best practices, He never stated what language or what use the application will be, i just gave some comments on some basics in a web application framework in PHP. If this was no help what so ever then fair enough but im sure it will help in some way!
RobertPitt
+2  A: 

The google tech talk lecture How To Design A Good API and Why it Matters provides many insights on how to design a good API.

Carlos Loth