Designing a web project

Hello, my question is: Why do we have separate layers of classes when developing a web application. For example a DAO layer, DTO layer, business services layer etc.I mean why do we follow this approach. What's the purpose of having DTO layer, if its just transfer ot data we can do it through ArrayList etc. Why a separate layer for database access, If we combine the business service layer and DAO layer functionality what are the disadvantages. I think that using these separate layer to some extent increase the work to make the application, and we should design our classes as is appropriate according to the problem at hand instead of having these three layers for every problem. Please give suggestions.

[717 byte] By [BitsLovera] at [2007-11-27 10:06:58]
# 1
Its a basic software architecture: http://en.wikipedia.org/wiki/Architectural_pattern_%28computer_science%29 http://en.wikipedia.org/wiki/Three-tier_%28computing%29 http://en.wikipedia.org/wiki/Model-view-controller
evnafetsa at 2007-7-13 0:43:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
It's all about reuseability and maintainability.
BalusCa at 2007-7-13 0:43:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Imagine you would directly connect to your database in your jsp files, bean classes, and servlets. Imagine you have more then 200 files in your application.

Now imagine the database location changes... good luck changing all your files

It is all about maintainability

When an application gets bigger, its hard to find bugs and make changes if your code is not arranged nicely.

jposthuma at 2007-7-13 0:43:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...