Monday, March 14, 2011

MVC Architecture

මේ design pattern එකෙන් කරන්නේ web application එකක ඇති components කොටස් තුනකට වෙන් කිරීමයි.
Model, View සහ Controller යනුවෙන්.

මේ component එක එකට පැවරුනු වගකීම් තියෙනවා.මේවා එකිනෙකින් ස්වායත්තයි. එක component එකක වෙනස් කිරීමකින් අනිත් component එකට බලපෑමක් නැත.(ඇත්නම් ඒ ඉතා සුළු වශයෙනි.)

මේ එක එක component වලට පැවරෙන වගකීම් මොනවාද?

Model

මෙය වගකියනු ලබන්නේ database එකෙන් data ලබාදීමට සහ database එකට data, save කිරීමටයි. සියළු business logic implement කරන්නේ මෙය තුලයි.

.User විසින් View එක හරහා ඇහුල් කරන data,db එකට save කිරීමට පෙර Model කොටසේදී check කිරීම කරනු ලබයි.Model එකට අයිති කොටස් වන්නේ

Data access,
Data Validation සහ
Data saving logic

යන ඒවායි.

View

application එකේ user ට පෙනෙන කොටස නිරූපනය කරන්නේ view මඟිනි.

-user ගෙන් input ලබාගැනීම
-controller එක වෙත requests, send කිරීම
-controller එක මඟින් responses ලබාගැනීම
-user ට output එක display කිරීම

මෙහි කාර්ය භාරය වෙයි.

View Component එකට අයිති වෙන්නේ..

-HTML
-JSP
-Custom tag libraries සහ
-Resourse files ආදියයි.

Controller


Model සහ View අතර අතරමැදියා ලෙස කටයුතු කරන්නේ Controller එකයි.

Client ගෙන් request එක view එක හරහා ලැබුනු විට, model එකේ අදාල business logic එක execute කරවා, ලැබෙන output එක view හරහා user ට ලබාදීමේ වගකීම පැවරෙන්නේ controller එකටයි.


Controller component එකට අයිති වන්නේ
-Action
-Action Servlet
-Action Form සහ
-Struts-config.xml

ආදියයි.

No comments:

Post a Comment