By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,963 Members | 1,994 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,963 IT Pros & Developers. It's quick & easy.

Planning Web Applications

P: 24
I am wondering what is the best way to develop a web application.

I am currently learning PHP and javascript at the moment.

I have been looking around and I have come across a layered method of application. Where there are 3 layers. User layer or layer that the user interacts with. The business where all the processing is done and finally the database layer where the application connects to all the information in the site.

So when you experts have a large project to do, would you break up your task into smaller tasks and into layers for different functions.

Also would most of you use classes when using this application model as they are reusable and easy to implement.
Aug 3 '07 #1
Share this Question
Share on Google+
4 Replies


P: 6
I am wondering what is the best way to develop a web application.

So when you experts have a large project to do, would you break up your task into smaller tasks and into layers for different functions.

Also would most of you use classes when using this application model as they are reusable and easy to implement.
If you are building a small application, you can get away with one/two tiers, i.e. the presentation layer, and the data layer. It's not best practice, but can be useful for an intranet application. However, you will be limiting future extensibility and ease of maintenance.

The n-tier (where typically n = 3) is a time-tested and valid way to develop web applications. The bottom tier, or data layer, would be your database, and the middle tier would be your business layer. Your classes would reside in the middle tier, and would handle all communication with the data layer. The presentation layer is the top tier, and handles all user interfaces, and communicates only with the middle tier. By abstracting the tiers this way, it becomes easy to drop in a new presentation layer - for say, mobile devices, IVR, etc.

A common way of doing this these days is to use a model-view-controller framework, especially in PHP (as I see it anyway, being a newbie to PHP). Your views are the presentation layer, and your models are the business layer (roughly).

And yes, you are right - this way leads to better reuse.

-Jay
Aug 3 '07 #2

kovik
Expert 100+
P: 1,044
Re-usability is all about flexibility. When you write your application, if you want it to be re-usable, you'll need to think in terms of what else your classes could be used for. The beauty of OOP is that you can extend multiple classes from another class, giving them all the same functionality, plus some. You'll want to build a framework that can be extended to fit any of your projects.

As Jay mentioned, the MVC is a very good layered application format. Model-View-Controller basically means that you have the program, then the display, and then the user input.

The Controller is the user input, as everything that your application does is in response to a user action. The controller takes the input and turns it into a request, and serves data based on that request. The View is the actual display. The hardest part of a pure MVC format is making the View it's own element, as so many PHP programmers are accustomed to procedural programming and inserting <?php tags into HTML documents. The best way (that I've found) to separate View from the rest is with templates (though I've written my own template engine as the others were too robust). Finally, the Model is the meat of the program. The model is every module that your program includes. From an internal search engine to a navigation menu, each module handles itself.


The way the application flow operates is that the controller takes user input and deciphers the request. It gathers up all necessary modules based on the request, thus forming the model. Then, it loads the model into the view which inserts the modules into the template. Then, the final product is displayed on-screen. Ideally, you'll only need one call to echo/print in per page request.
Aug 4 '07 #3

P: 24
Thank you for you replies. It may seem straight forward to you, it probably is not too difficult to implement but for a better understanding I think I would need examples. Do you know where I can get examples (easy to understand examples) of such a model.

Also I only at the beginning of my OOP learning experience and I am only starting to understand the power and ease of use classes are.

So if you could help me thanks
Aug 5 '07 #4

kovik
Expert 100+
P: 1,044
Thank you for you replies. It may seem straight forward to you, it probably is not too difficult to implement but for a better understanding I think I would need examples. Do you know where I can get examples (easy to understand examples) of such a model.

Also I only at the beginning of my OOP learning experience and I am only starting to understand the power and ease of use classes are.

So if you could help me thanks
Well, following design patterns such as these pretty much require OOP. The 'layers' must communicate with one another, somehow.

If you're new to OOP, tackling something like a framework is not recommended, as even if you do complete it, you'll likely end up having to completely rewrite it, which is no fun. What you'll want to do is create something basic, and slowly break it down into objects to understand how they must communicate and handle the separation of duties.
Aug 5 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.