When you develop second web project, what function that you reuse?

Dear all,

Second web project doesn’t mean the second one only,
but all the web project after the first.
My experience. when the second web project come,
I only can reuse database function.
The other function I code from beginning again
:frowning: how pity.
And I want to change this bad habit.

So I want to know,
what is the possible function that can reuse(form,validation,css,menu)
so you doesn’t have to code from beginning again like the first one?
And, how you organize it?



An awful lot I re-use each time - its a good idea to either use a framework that exists, or build your own up with the libraries you develop (this is the solution I took) and now I have a complete framework that I use on virtually any site I make.

I found the DIY job suited my needs better and was much more lightweight than an off the shelf framework.

^^ Agreed … building your own libraries of reusable objects and functions is the way to go. After years of doing this you will have an object for just about anything you can think of, then application development becomes so much easier.

And yes, stay away from the frameworks … too much weight to ‘drag around’

Building your own libraries and objects that you re-use from project to project works great until you have to share your code with someone else so they can work on the project too. Then you run into all sorts of issues with knowledge transfer. There is likely no documentation for all your own code, nothing is written down, no setup instructions, no flow diagrams or guides to follow, etc. Adding just one more programmer to an all custom codebase significantly increases the cost of development with added communication and explanation time. Using a known and documented framework eliminates this obstacle with the added bonus of using other people’s published code like plugins and modules, etc.

Yeah. Also, most custom toolkits evolve into psuedo frameworks anyway.


I favor building objects best served for composition. Focusing them on solving singular purposes and then combining them together to get what you want.

For example I have a group of authentication classes: Salt, Hash, Session, Redirect, Permissions, Identity, auth… I can reuse Session, Redirect, Hash, Salt and Identity in other ways.

For widgets I have a generic forms creation class, and base validation classes that can be combined in any number of different ways.

All the code in my apps have fairly complete testing code - I have been attempting to perfect unit driven development and have come to like it quite a bit, but my point about the tests, is when run a suite they give you confidence that everything works as expected. They also serve as much better documentation than exclusive in-line comments – they show other developers exactly how to use the code you have developed.

After a while you can take your rolled components, zends, pears or whomever’s code and compose much of an application without specifically having to use a framework but working with trusted code. It is a matter of choice, but this type of reuse works for my projects. I don’t often have to work with other developers, but when I have, they have succeeded in using my code after reviewing the tests.

Don’t know if this helps but I hope it does!


According to my question before, “what function that you reuse”
I hope the answer about function that you build yourselves.
Coz, in framework, almost all function can be reuse, is it right?

Hi sihar,

Generally the term that describes a reusable collection of functions is a Library and not a framework.

A framework goes beyond a library as it allows developers access to a scaffolding that includes a methodology of organization, for example MVC, and most times a wide number of classes with methods that can be reused.

A library of functions is one way to re-use code; however generally more complex projects can benefit from a framework as the scaffolding and known methodologies of the framework help a developer communicate the work to others and to not have to implement many classes, methods or functions as they are already created for them.

Many people learning more complex development find that frameworks don’t allow them to learn as well as coding for yourself. You have to decide if a framework is the right approach for you; if not then learning about code patterns, testing, and refactoring will be a big step forward in creating more reusable code.


Thanks for all.
Big thanks for clear explanation especially to ServerStorm

I recommend http://codeigniter.com/. Very handy and you can easily add your own functions or extend their functions.