layers and classes

orengolan

New member
layers and classes

my application consist of 4 layres- GUI, BL, DAL and DB (is DB is considers as a layer?) BL - my business objects (objects that moves from GUI to DB and visa versa). DAL - usualy static objects that have static methods that take BL objects and moves them to DB or visa versa. here is an example of a class in my DAL- public static class ProductsDAL { //bring all products of specific location public static BL.Products GetAllProducts(BL.Location myLocation) { BL.Products myProducts; WebService.POS_WS service = new WebService.POS_WS(); myProducts = service.GetAllProducts(myLocation); return myProducts; } } I have another class - Barcode. this class responsible for all kind of Barcodes activities - creating Barcodes number, printing Barcodes and more. what layer is this class belongs to? is it part of the BL? i thought that BL is for classes that moves between layers, and not calculation or processing stuff. Maybe i should add another layer - Utilities, and add this class to the new layer. what do you suggest?​
 

עידו פ

New member
במקרה של הארכיט' שלנו

שהיא בעקרונה די דומה, החלטנו ששכבת ה-GUI שלנו גם מחולקת לכמה חלקים: UI - הדפים (ASPX/win forms) שמוצגים למשתמש UtilUi - רכיבים כגון שדות קלט, יומן וכו' Util - רכיבי תשתית המשמשים את ה-UI אך הם נטולי ממשק משתמש (כגון controller-ים לישויות המידע, מחלקות סטטיות לעטיפת WS וכו'). בשכבה זו הייתי נוטה לשים את רכיב הברקוד (גם אני באותה סירה - כשאני אשים אותו עוד מספר חודשים אני אהיה יותר חכם). במידה ורכיב זה אינו רכיב UI בלבד (לדוגמה - אם אתה מחולל ברקוד בשרת ומדפיס אותו ברקע למדפסת ארגונית), ניתן לשקול שכבה נוספת של Common Util שהיא משרתת גם את ה-BL וגם את ה-UI (אצלנו קראנו לזה בקיצור Common ובינתיים הכנסו לשם את רכיב ההרשאות שלנו שמשמש אותנו גם ב-UI וגם ב-BL). חשוב כמובן שאם רכיב זה יושב בשכבה משותפת אז אסור שיהיה לו שום פן גרפי (UI)
 

orengolan

New member
architecture diagram

I don't understand what do you have in your BL. my BL consist of entity objects- objects that encapsulate data that moves between the layers. You said that Common Util serves the BL and the UI. why does the BL uses aother layer? in my architectue the BL is used by the GUI and the DAL, and not it is not using them. another issue i have - i need to deploy the BL both in the server and in the client. i wonder if you are doing the same. take a look at the dieagram and tell me if it makes sense. thanks​
 

עידו פ

New member
קצת לא ברורה לי הדיאגרמה

איך הגעת למצב שה-GUI נמצא גם ב-client וגם ב-Server ? בארכיט' אצלנו, ישנה הפרדה בין ה-logic ל-State. ה-state של כל יישות מיוצג ע"י מופע של מחלקת ישות. כל מחלקות הישויות מאורגנות אצלנו בשכבה לה אנו קוראים שכבת ה-model (מודל הישויות). שכבת ה-BL ייעודה לייצר מופעי מודל (טעינתם מה-DB וממקורות אחרים באמצעות ה-DAL) ולקבל מופעי מודל על-מנת לשמור אותם. שכבת ה-BL אחראית על בדיקות לוגיות בין הישויות (אסור להכניס ישות א' אם קיימת ישות ב'). לגבי בדיקות לוגיות על הישות עצמה (מה שמכונה self validation), אנחנו עדין בשלבי ארכיט' בשביל לקבוע האם זה יהיה ב-BL או במודל (ההכנסה למודל תאפשר להתייחס לאותן בדיקות עצמאיות עוד בשכבת ה-UI מבלי להזדקק ל-server side עבור הרצת הבדיקה - דבר שיגרום ל-round trips). ה-common util יכיל רכיבים שאינם business oriented אלא system oriented כמו כתיבה ללוג, בדיקת הרשאות ושאר רכיבי תשתית שאינם מוגדרים אצלנו בתור Application Blocks. מצאתי אצלי איזה שרטוט קצת ישן של הארכיט' שלנו, אולי זה יעזור להבין (בעקרון זה מאוד מבוסס על הארכי' המוצעת של מיקרוסופט לפיתוח בדוט נט)
 

עידו פ

New member
לגבי השאלה על ה-DB

לרוב לא מסתכלים על ה-DB כעל שכבה כי לרוב הוא רק מקום בו הנתונים נשמרים. במצב שבו את "מעבה" את ה-DB ומוסיף לו אחריות (בין אם עיבוד מידע או אפילו לוגיקה עסקית), כדאי להתייחס אליו בתור שכבה. אם נסתכל לדוגמה על העתיד של sql server 2005 שבו אפשר לכתוב רכיבי דוט נט שירוצו תחת ה-sql server, אפשר לראות שהגבול בין ה-DB לאפליקציה מטשטש מרגע לרגע (ואז הדילמה של bring the data to the process לעומת bring the process to the data הולכת ונעלמת).
 

arnonrgo

New member
לא כל כך מבין

קצת קשה להבין ארכיטקטורה מהסבר קצר ודיאגרמה אחת - אבל (ויכול להיות שאני מתרשם לא נכון בגלל הזוית ראיה הצרה) הרושם שלי שיש כאן בלגן די גדול למשל: אני חייב להודות שאני לא כל כך מבין את החלוקה שלך לשכבות מה בדיוק המטרה של הBL (למה אותו DLL רץ בשרת ובלקוח - למה לך להריץ את אותה לוגיקה פעמיים) בנוסף (לפי ההודעות בהמשך) מה המוטיבציה לשימוש בWeb services לעומת (למשל) remoting - מה אתה מרוויח אם אתה משתף types בין הUI לשרת? כמו כן לפי דוגמת הקוד שכתבת - למה הDAL מתעסק עם web-services - לא כדאי להפריד מימוש טכנולוגי לגישה לשרת (web service) משכבה שתפקידה לגשת לDB ולהחזיר נתונים? מה אם תרצה להחליף? מה אם תרצה לעשות משהו יוצר משמעותי עם השרת (כמו לבצע לוגיקה עסקית ולא רק לשתמש בתור נקודה מרכזית לשמירה לDB) מה הbenefit של להחזיק שרת אם הוא רק משמש לדחיפה והוצאה של נתונים מהDB - בדקת האם הDB יכול לעשות את זה טוב יותר? במיוחד לאור העובדה ש(כמו שזה נראה גם מהדיאגרמה בהמשך) השרת ממילא עובד במהירות של הDB שכבת GUI של מופרדת לשכבות משנה לא אומרת הרבה האם כל הלוגישקה מרוכזת בforms? מה קורה אם יש תצוגה של אותה ישות על כמה forms (כדאי לך לקרוא על patterns כמו MVC, MVP וPAC שמקובלים בUI) למה יש (מהדיאגרמה) רכיבי GUI בצד שרת - איפה ההפרדה לשכבות? ארנון
 

orengolan

New member
ok, i'll try to explain myself

I have two separate applications: (take a look at the new drawing) 1.Winform, smart client app that communicate via web service with the server, And should be able to work witn no connectivity (cache the data until connection is available) 2. web application. In my first drawing I thought of deployment so I draw the GUI of the web application in the server…(physically the aspx pages sites on the server) Here is my layers functionality: BL – only business entities (model) for example – Product class and Products class (contain array of Product) Client DAL - classes that move the business classes of the BL back and forth to the server. For example – I have a class called ProductsDAL that responsible for bringing Products back to the GUI. ClientDAL.ProductsDAL.GetProducts() Server DAL – classes that gets requests from the webservice or directly from an aspx page and brings back data from the DB (it returns business entities) (the ServerDAL must have a reference to BL.dll because he uses the same business entities). Is there any way to pass business entities without sharing them between my GUI, ClientDAL, Webservice and ServerDAL? I am not sharing functionality here because my BL only has classes that holds data. Ido, can you please tell me about the DEPLOYMENT of your application? In the diagram you sent me, I don't understand what components sites on the client machine and what no the server. Are we talking about web app or windows app? Ido and arnon – thanks for the feedback, I nees to digest a few of the things you mentioned in your answers..​
 

Justin Angel

New member
הבנתי על מה הוא מדבר...

ה-BL הם ה-Busniss objects שמייצגים את השכבה התחתונה באפליקציה. בחלוקת ה-BO בין השרת ללקוח נוצרת שפה אחידה באובייקטים ששניהם מדברים. ה-DAL בלקוח עובד בלבד מול WS, כלומר אין DB לוקאלי. כל המידע מגיע מ-WS ולכן ה-DAL עצמו הוא רובד ה-WS בתוך ה-DAL. באפליקציה שולחנית מרוחקת לא הייתי חושף את הלקוח לעבוד ישר מול ה-DB. העבודה מול WS (או Remoting) באמת יותר הגיונית. אני מסכים (מאוד) על MVP ו-MVC, ובכלל על הפרדת שכבת התצוגה לרבדים יותר ריאלים.
 
למעלה