Good Morning guys,
This week, I had decided I will be writing my C# Practicals in Model View Controller style (which probably is a bit overkill because the programs they require us to write are not too complex or big enough). My issue is with implementing, or rather, coding MVC.
From what I understand, the Model contains your database class(es), as well your "data" classes like Student, or Employee, or User, etc. The View contains all the screens (user interfaces) that the program will use. The Controller is the "brains" behind the program, which will use and process the needed models and push data to the needed view(s) and display to the user.
With this, I thought of creating a Controller Class, A DatabaseOperations Class, My Product Class, and My Category Class. My problem is with the controller class, I thought the controller must be accessible throughout the runtime of the program... my first thought would be in using static methods but that is bad (I heard). Another method I thought of is making each of my views have a Controller object instatiated in them - but then this would mean each form will have a different instance of the Controller class.
How would you guys implement the Model View Controller pattern in programming? I really thought it would be great if I get started with MVC and eventually get comfortable using it.
Thanks.
This week, I had decided I will be writing my C# Practicals in Model View Controller style (which probably is a bit overkill because the programs they require us to write are not too complex or big enough). My issue is with implementing, or rather, coding MVC.
From what I understand, the Model contains your database class(es), as well your "data" classes like Student, or Employee, or User, etc. The View contains all the screens (user interfaces) that the program will use. The Controller is the "brains" behind the program, which will use and process the needed models and push data to the needed view(s) and display to the user.
With this, I thought of creating a Controller Class, A DatabaseOperations Class, My Product Class, and My Category Class. My problem is with the controller class, I thought the controller must be accessible throughout the runtime of the program... my first thought would be in using static methods but that is bad (I heard). Another method I thought of is making each of my views have a Controller object instatiated in them - but then this would mean each form will have a different instance of the Controller class.
How would you guys implement the Model View Controller pattern in programming? I really thought it would be great if I get started with MVC and eventually get comfortable using it.
Thanks.