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);
}
}