locked
Three tier RRS feed

  • Question

  • The below example demonstrates how i am planning to implement three tier architecture in project. But My doubt is,as we seen in the below example ,if the Presentation layer needs an object of the class CourseManager(that resides  in business layer) the presentation layer must know the interface IContentManager and the static class BussinessCoreFactory , Is this a proper method ? or is there any other method to get the object of the CourseManager((that resides  in business layer) ) in Presentation layer?

    Business Layer

    -----------------------------------------------------------------

       interface IContentManager
            {
                int Create(IContent content);
            }
            public class CourseManager : IContentManager
            {
                public int Create(IContent content)
                {
                    //Call DataAccess functions
                    return 0;
                }
            }

            public static class BussinessCoreFactory
            {
                public static IContentManager CreateCourseManager()
                {
                    return new CourseManager();
                }
            }


            public  static class BusinessEntityFactory
            {
                public static IContent CreateCourse()
                {
                    return new Course();
                }
            }

            interface IContent
            {
                string Name { get; set; }
            }

            public class Course : IContent
            {
                string name = "";
                public string Name
                {
                    get { return name; }
                    set { name = value; }
                }

            }
    Presentation Layer

    -----------------------------------------

            class CreateCoursePage : System.Web.UI.Page
            {
                void uxSubmit_Click(object sender, EventArgs e)
                {
                    IContent course = BusinessEntityFactory.CreateCourse();
                    course.Name = "CourseName";
                    IContentManager courseManager = BussinessCoreFactory.CreateCourseManager();

                    courseManager.Create(course);
                }
            }

    Tuesday, July 31, 2012 6:05 AM

Answers

  • It seem to be proper way you do it.

    A common setup I work with is that I have database and a front-end, mostly ASP.NET but can be a windows application too. In between I put a data access layer and the business logic.

    1. ASP.NET Web application
    2. Business logic
    3. Data access layer
    4. Database

    Each layer can only know about the one immediately below. The front-end will never know what database or data access layer, only the business layer. 

    This seem to be what you are doing.

    • Proposed as answer by Mike Feng Wednesday, August 1, 2012 10:10 AM
    • Marked as answer by Mike Feng Thursday, August 9, 2012 3:21 PM
    Tuesday, July 31, 2012 7:12 AM