Layer and Tier Architecture

January 6, 2010
Software Application တစ္ခုကို Layer နဲ႕ Tier သံုးျပီး ဘယ္လိုတည္ေဆာက္မလဲ

Layer နဲ႕ Tier ဆိုတဲ့ စကားလံုးေတြဟာ ယေန႕ programming ေလာက မွာ အသံုးမ်ားတဲ့ ေ၀ါဟာရေတြျဖစ္လာပါျပီ။ ဒီနည္းပညာ ေတြဟာ application တစ္ခုကို develop လုပ္မယ့္ developer ေတြကို သူတို႕ရဲ႕ လုပ္ေဆာင္မွူေတြမွာ အဆင္ေျပလြယ္ကူမွူေတြကို ေဆာင္ၾကဥ္းေပးလာတာ ကို ေတြ႕ေနရပါတယ္။ဒါေၾကာင့္ ဒီသေဘာတရားကို Application Developer ေတြ အားလံုးသိသင့္တယ္ လို႕ ယူဆတဲ့ အတြက္ ဒီ Article ေလးနဲ႕ မွ်ေ၀တာပါ။

Real World Apllication တစ္ခုအတြက္ Layer ေကာ Tier ပါ အသံုးျပဳရမယ့္သေဘာတရားေတြပဲျဖစ္ပါတယ္။

Software system တစ္ခုကို develope လုပ္မယ္ဆိုရင္ code maintenance ပိုင္းဟာ
အေရးၾကီးလွတာေၾကာင့္ ဘယ္လို Architectural နဲ႕ သြားမယ္ဆိုတာ အစကတည္းက
ၾကိဳတင္စဥ္းစားရပါတယ္။ တကယ္လို႕ သင့္ system က ေအာက္ပါအခ်က္မ်ားနဲ႕  ကိုက္ညီေနတယ္ဆိုရင္ေတာ့
 layered architecture style ကို သံုးသင့္ပါတယ္။

• Your application is complex, and you want to mitigate(reduce) that complexity by grouping
functionality into different areas of concern.
(ရွူပ္ေထြးတဲ့စနစ္ေတြကို သက္ဆိုင္ရာ လုပ္ငန္းတာ၀န္ေပၚမူတည္ျပီး စုစည္းဖို႕လိုတဲ့အခါ)
• You want to improve the maintainability and extensibility of the application, by minimizing
dependencies.
 (class တစ္ခုနဲ႕တစ္ခု အလြန္အကြ်န္မွီခိုေနတဲ့အခါ၊ တစ္နည္းအားျဖင့္ အပိုင္းတစ္ပိုင္းကို ျပင္တဲ့ အခါ
ေနာက္တစ္ပိုင္း ကပါ ျပင္ဖို႕လိုလာတဲ့အခါ)
• You want to implement complex and/or configurable business rules and processes.
(ရွူပ္ေထြးတဲ့ စီးပြားေရးဆိုင္ရာ အတြက္အခ်က္ ေတြကို သီးသန္႕ခြဲထုတ္ခ်င္တဲ့အခါ)

 Layered architecture style ကို အဓိကသံုးရတယ့္ ရည္ရြယ္ခ်က္ကေတာ့

- သူ႕ အလုပ္နဲ႕သူ ရွင္းရွင္းလင္းလင္း ခြဲထားၿခင္း(Separtion of Concern )ေၾကာင့္
- Strong Cohesion (သက္ဆိုင္ရာအစုမွာ အခ်င္းခ်င္း ခ်ိတ္ဆက္မိဖို႕)
- and Loose dependence (ဒါက cohesion ရဲ႕အက်ိဳးဆက္ပါ ... ကိုယ့္အပိုင္းမွာ ကိုယ္ခ်ိတ္ဆက္မိရင္ တျခားအပိုင္းေတြကို တအားမွီခိုစရာမလိုေတာ့ဘူး)ဒါေတြေၾကာင့္ ၿပဳၿပင္ထိန္းသိမ္းရတာ အဆင္ေၿပ လြယ္ကူပါတယ္။

Layer အေၾကာင္းမေၿပာခင္ က်ေနာ္တို႕ဟာ Tier နဲ႕ Layer အေၾကာင္း ခြဲၿခားၿပီး သိရပါမယ္။

1. Tier vs. Layer

1.1 Tier: (Physically- အမ်ားအားျဖင့္ ေနရာ ၊အေကာင္အထည္ပါကြဲျခင္း)
Tier indicates a physical separation of components,
 which may mean different assemblies such as DLL, EXE, etc. on the same server or multiple servers.
တကယ့္ application တစ္ခုတည္ေဆာက္တဲ့ အခါ Database ကို Tier တစ္ခုအေနနဲ႕ ခြဲထုတ္ပစ္ႏိုင္ပါတယ္။

1.2 Layer: (Logically- ရည္ရြယ္ခ်က္တစ္ခုအတြက္ လုပ္ေဆာင္ခ်က္မ်ားသာ ခြဲထားျခင္း)
Layer indicates logical separation of components, such as having distinct namespaces and classes
for the Database Access Layer, Business Logic Layer and User Interface Layer.

Although both layers and tiers use the same set of names (presentation, business, service, and data),
remember that only tiers imply a physical separation. It is quite common to locate more than
one layer on the same physical machine.

layer ဆိုတာ logicအားၿဖင့္ (တနည္းေၿပာ၇၇င္  module အားၿဖင့္) ခြဲၿခားထားၿခင္းၿဖစ္ၿပီး
tier ဆိုတာကေတာ့ physical အားၿဖင့္( database, server,client အားၿဖင့္) ခြဲၿခားထားၿခင္း ၿဖစ္ပါတယ္။

Tier မွာ presentation tier,business tier,data tier ဆိုၿပီး ၃ မ်ိဴးရွိပါတယ္။
Tier မွာ 2 tier,3 tier,N tier ဆိုၿပိး အဆင့္ဆင့္ ခြဲလို႕ရ့ပါတယ္။
2 tier ဆုိတာ ကေတာ့ က်ေနာ္တို႕ ေတြ႕ေနၾက server/client သေဘာပါပဲ။
client tier က persentation tier ၿဖစ္ၿပီးေတာ့ server ကေတာ့ business and database tier ပါ။
3 tier ကေတာ့ client ကအရင္အတိုင္းၿဖစ္ၿပီး server ကိုေတာ့ business tier သက္သက္
database အတြက္ သက္သက္  ၂မ်ိဴးခြဲခ်လိုက္တာပါပဲ။server ကစက္၂လံုးအေနနဲ႕ေပါ့။

Layer မွာလည္း presentation layer,business logic layer,data access layer ဆိုၿပီး  ၃မ်ိဴးရွိပါတယ္။

Presentation layer မွာ user ရဲဲ႕ input ေတြကို လက္ခံမယ္။မွန္မမွန္ စစ္မယ္။
output ၿပန္ၿပမယ္။ အဲဒီအပိုင္းေတြနဲ႕ ပတ္သတ္တဲ့ coding ေတြကိုပဲေရးပါတယ္။
က်န္တဲ့  domain အရ တြက္တာခ်က္တာေတြ၊ database အပိုင္းနဲ႕ပတ္သတ္တာေတြ
မေရးပါဘူး။Persentation Layer မွာ စဥ္းစားရမယ့္ အခ်က္ေတြကေတာ့
Caching,Composition,Exception Management,Input,Layout,Navigation,Request Processing,User Experience,Input Validation,etc...
အစရွိသည္တို႕ပဲ ၿဖစ္ပါတယ္။
Persentation layer ဟာ Business layer နဲ႕ ဆက္သြယ္ၿပီး အလုပ္လုပ္ပါတယ္။

Business Layer မွာေတာ့ ကိုယ့္ application domain နဲ႕ပတ္သတ္တဲ့
အတြက္အခ်က္ေတြ၊ rules ေတြ၊ formula ေတြ,သက္ဆိုင္ရာ     D layer ေတြကို သြားၿပီး
လိုအပ္သလို ေပါငး္စပ္ ေပးရပါတယ္။ အစရွိတဲ့ business နဲ႕
ပတ္သတ္တာေတြအၿပင္ Data layer နဲ႕ Presentation layer ၾကားခံ အေနနဲ႕
ေဆာင္ရြက္ေပးပါတယ္။Business  layer မွာ စဥၤးစားရမယ့္ အခ်က္ေတြကေတာ့
Authentication,Authorization,Business Components,Business Entities,Caching,Coupling and Cohesion,
Concurrency and Transactions,Data Access,Exception Management,Logging and Instrumentation,
Service Interface,Business Validation,Workflows,etc...
အစရွိသည္တို႕ပဲၿဖစ္ပါတယ္။


DataAcess Layer ကေတာ့ Business  layer ကေပးလိုက္တဲ့ parameter ေတြအေပၚမွာ
မူတည္ၿပိး database နဲ႕ connection ယူတယ္။ insert,update,select command ေတြေရးတယ္။
လိုအပ္တဲ့ stored procedure ေတြေခၚတယ္။အစရွိတယ့္ DB နဲ႕ပတ္သတ္ၿပီး အလုပ္လုပ္ရတဲ့
အပိုင္းကို ဒီ layer ကပဲ တာ၀န္ယူလုပ္ေပးရပါမယ္။
Business layer မွာ စဥၤးစားရမယ့္ အခ်က္ေတြကေတာ့
BLOB,Batching,Connections,Data Format,Exception Management,Queries,
Stored Procedures,Transactions,Validation,XML,etc...
အစရွိတာေတြနဲ႕ ပတ္သတ္တာေတြ လုပ္ရပါမယ္။
ဒီအပိုင္းဟာ Database Tier သာ ခြဲထုတ္ထားခဲ့ရင္ အဲဒီအပိုင္းနဲ႕ ေပါင္းစဥ္းစားရမယ့္အပိုင္းျဖစ္ပါတယ္။
Client ေတြအားလံုးမွ်အလုပ္လုပ္ခ်င္ရင္ေတာ့ ရုိးရုိး Query နဲ႕ပဲ DataAccess Layer က တာ၀န္ယူလုပ္ေဆာင္ႏုိင္ပါလိမ့္မယ္။


layer archi သံုးရတယ့္ အက်ိဴးေက်းဇူးကေတာ့ ၿပဳၿပင္ထိန္းသိမ္းရတာလြယ္ကူတယ္။
Coding ရွင္းလင္းတယ္။Windows ကေန Web ေၿပာင္းခ်င္လည္း
Presentation Layer တခုထဲကို ေၿပာင္းလိုက္ရံုပါပဲ။

Layer Architecture အတြက္ကေတာ့ အေပၚကအခ်က္အလက္ ေတြကလံုေလာက္ေပမယ့္ application တစ္ခုစာ ျပီးသြားေအာင္ Database Tier ကို ဆက္ေျပာၾကည့္ပါမယ္။

ဒီ Database Tier ကေတာ့ Data Access ကေခၚမယ့္ Table Valued Functions ေတြ, View Table ေတြ ၊ CRUD Operation အတြက္ StoreProcedure ေတြ စတာေတြကို ဒီ Tier မွာထားရပါမယ္။ တစ္ခါတစ္ရံမွာ Database Tier မွာ Business Rules ေတြ လည္း ထည့္ထားႏိုင္ပါတယ္။
တစ္ခ်ိဳ႕ Report ေတြကို လည္း ဒီ Tier မွာတင္ ျပီးေအာင္ ထုတ္ယူလုိ႕ရပါမယ္။
Heavy Server ေတြသံုးမယ္ ဆိုရင္ ဒီနည္း ဟာ client ေတြ ရဲ႕ Performance မေကာင္းေပမယ့္ Server တစ္လံုးေကာင္းေကာင္းနဲ႕တင္ အလုပ္အမ်ားၾကီး လုပ္ႏုိင္ပါလိမ့္မယ္။

နမူနာ source code ၾကည္႕ခ်င္ရင္ေတာ့
Source:http://www.codeproject.com/KB/cs/Three_Layer_Architecture.aspx
မွာ ၾကည္႕ႏိုင္ပါတယ္။
အေသးစိတ္ဖတ္ခ်င္ရင္ ဒီမွာ ယူႏိုင္ပါတယ္။
 

Best Practices For Software Developement Seminor

November 17, 2009
November 13 ရက္ေန႕က MCPA ကလုပ္ေပးတဲ့ Best Practices For Software Developement Seminor မွာ Speaker ေၿပာသြားတဲ့
အခ်က္ေလးတစ္ခုပါ။မလိုအပ္ပဲ resources ေတြကို မသံုးဖုိ႕နဲ႕ သံုးခဲ့ရင္လည္း တတ္ႏိုင္သမွ် အခ်ိန္နည္းေအာင္ coding မွာဂရုစိုက္စဥ္းစ...
Continue reading...
 

Project Management

October 12, 2009
MCPA က october 11 ရက္ေန႕ကလုပ္ခဲ့တဲ့ Project Managemaent Seminor က Software Project ေတြ fail ၿဖစ္ရတယ့္
အခ်က္ေလးေတြပါ။

4 major issues of IT project failed

1.Bad Communication between relevant parties
(Project မွာအတူတူအလုပ္လုပ္ၾကသူေတြ တစ္ေယာက္နဲ႕တစ္ေယာက္
မရင္းႏွီးတာ၊မတည္႕တာ၊ၿပိဳ...
Continue reading...
 
Make a Free Website with Yola.