What's the responsibility of controller?
-
Hi, I have applying MVC pattern in windows forms application, but I got a problem that I am not clearly understand the usage of controller, for the application, I created a controller and fill in lots of functions to control different area of object, now, it became the "god controller"(same as god class with ~150 methods), but it doesn't contain business logic, it just perform the object creation, object flow between DAO and notify events for UI display in about five set of domain in an enterprise. Could anyone provide some guideline / hints to help for clearly understand the responsibility of controller? Thanks.
-
Hi, I have applying MVC pattern in windows forms application, but I got a problem that I am not clearly understand the usage of controller, for the application, I created a controller and fill in lots of functions to control different area of object, now, it became the "god controller"(same as god class with ~150 methods), but it doesn't contain business logic, it just perform the object creation, object flow between DAO and notify events for UI display in about five set of domain in an enterprise. Could anyone provide some guideline / hints to help for clearly understand the responsibility of controller? Thanks.
Model-Having Database codes.insert,retrieve data from database Controller- Get Values from view give it to Model & Get Data from Model Give it to View View - Display value and request controller...
R RajaGuru
-
Model-Having Database codes.insert,retrieve data from database Controller- Get Values from view give it to Model & Get Data from Model Give it to View View - Display value and request controller...
R RajaGuru
Some of that is already applied but the controller is too large, I think it contains a lot of "Get Data from Model and Give it to View" code in the controller. e.g. for payment, the view should load all PaymentMethod, all Branch and all division for user selection and bound the Payment object with Payment details, so the controller for this case contain GetAllPaymentMethod(), GetAllBranch(), GetAllDivision() for user selection Some of other part of the application contain more then three GetXXX() so it become too large, so I want to clarify about it. 1. Should controller handle object creation method? I have already separated a Factory Class for object creation, but should view directly call the factory or call the controller to create object from factory? 2. Should controller handle GetAllXXX() method for user selection? or let view call it directly? 3. Should controller handle flow between object and DAO? e.g. Update(Payment obj) { PaymentDao.Update(obj);} 4. Should controller provide interface for domain model method? e.g. ShipOrder(Order obj) { order.Ship(); orderDao.Update(order);} Thanks