The most popular way to develop a web application with OOD / OOP is to use the Model-View-Controller template. To summarize the 3 main participants:
Model . I work in a problem area that you are manipulating.
View . I am responsible for drawing and managing what you see in the browser. In web applications, this often means setting up the html template and pushing a name-value pair into it.
Controller I am responsible for processing requests coming from the Internet, and figuring out what to do with them, and organizing with other objects to perform this work.
Start with the controller ...
Views and controllers often fall in pairs. The controller accepts the HTTP request, does what needs to be done - and it either does it (if the work is trivial), or delegates the work to another object. Usually it finds a view to be used and passes it to an object that does the actual work of writing the output.
What I described here matches what you expect to find in something like Ruby on Rails.
Creating multiple objects that you use once is certainly a concern, but I would not worry about this aspect of performance. Own virtual machines know how to manage short-term objects. There are many things you can do to speed up your web application - and I would start to sacrifice the benefits of a clear organization for speed, which might not even be the most important optimization ...
MVC is not the only way, there are other patterns like Model-View-Presenter and some really unusual approaches like continuation servers (like Seaside) - which reuse the same objects between HTTP requests ...
source share