best practice in designing asp.net

orengolan

New member
best practice in designing asp.net

The attached drawing describes 2 design options for an asp.net application: The first one is my current design. The GUI calls the DAL which retrieves info from the DB through BL objects. The second design is a famous sample application. The GUI call a façade, which calls the DAL. The DAL retrieves info from the DB, create an object (simple object!), return it back to the façade. The façade is casting the object into typed object (from the business layer) and return it to the GUI. I think of redesign my app so it will be similar to the second option. If you think the second option is good design can you give me scenarios that demonstrate the advantages? I have heard about decoupling but I need a real-life explanation to understand the concept. Final remark: please Ignore the fact that the DAL is creates by Nhibernate. I am not going to do it in the beginning anyway.​
 

עידו פ

New member
-->

1. בתצורה הראשונה, נראה שהלוגיקה העסקית יושבת בתוך ה-GUI (בהנחה וה-DAL רק מבצע persistence), מה שעלול להוות בעיה אם היית רוצה לחשוף את הלוגיקה בצורה כזו או אחרת למערכות אחרות. בתצורה השנייה, ה-facade יכול לחשוף את הלוגיקה (נניח כאסמבלי או כ-web service) למערכות אחרות. 2. הפניה הישירה של ה-gui ל-DAL יכולה להוות בעיה במערכות asp.net בהן מפרידים בין שרת הדפים (web server) לשרת הלוגיקה העסקית (application server), כאשר מטרת ההפרדה היא במרבית המקרים בגלל אבטחה. חסימה שכזו עלולה למנוע מה-GUI שלך לגשת ישירות לשרת ה-DB (אם נניח ה-DAL יושב יחד עם ה-GUI על אותו שרת) . אלא דוגמאות כלליות לגבי 2 הארכיט' הנ"ל, אני מניח שאם נדע יותר על המערכת, על הממשקים שלה, על המגבלות הטכנולוגיות, הטופולוגיות וכו' נוכל לתת חוות דעת יותר לעניין
 

orengolan

New member
thanks Ido

I understand all the issues you raised and it helps me understand the design. another question - I have been told to use interfaces. I am not really sure how exactly should I use them. where would you use them in the (second) design? A small source code, similar to the one you already wrote would be helpful. thanks again​
 

עידו פ

New member
אני אעשה משהו יותר טוב

ב-ArchitectJournal האחרון של מיקרוסופט היתה כתבה נחמדה ותמציתית על איך ניגשים למידול Services, ובין השאר דיברנו על נושא ה-interfaces : http://www.architecturejournal.net/2006/issue8/F8_Service
 
למעלה