Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I know that N-Tier intended to separate layers on different network

but I would like to have the same code separation in codeigniter

I got this idea to have Model : for database CRUD - > Data layer REST API : for business logic—> Business layer that calls CRUD method from models

Controller & View are going as before

and flow will be

View<—>Controller <—> API(with Business classes) <—>Model

I wanna know what kind of drawbacks it can be such architecture

share|improve this question

closed as too broad by gnat, MichaelT, GlenH7, Ozz, Kilian Foth Sep 24 '13 at 8:50

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

1 Answer

N-Tier is not necessarily on different networks. Each tier is in a separate process, it could all be on one machine.

3 tier is somewhat out of fashion due to the out of process marshaling it requires.

Any extra tier, read: process boundary or worst communication across a network transport, is expensive.

In a 3-tier system the second tier is usually the business logic. A two tier system is most popular these days, since business logic is really difficult to divorce from user data.

A typical web application is two tier; user data and business logic are one tier and a DBMS is the other tier.

The biggest drawback is having to marshal/serialize everything multiple times as you bounce across tiers. The less tiers you have the less bouncing you need to do. All work you can do directly without jumping through hoops is massively more efficient. The difference between passing your data by (in-process memory) reference or through a transport is huge.

API code or a business logic in the form of application code is easily replicated and thus efficient to run in-process. A business logic tier offers little scaling opportunities since it depends on transactions against the data tier. You don't need tiers for reuse, you can reuse layers just fine.

I'd stick to layering for as long as possible. For what you call 'API' in your 'flow': look into application service layer pattern (which is a layer, not a tier) as an alternative.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.