views:

251

answers:

3

I am refactoring a project and I want to make it conform to the MVC pattern (model view control). There are three objects:

  1. a ServerList (maintains a list of servers that are active) - this guy will be the controller

  2. a Form - this is your standard .NET GUI

  3. a DatabaseThingy - wrapper class that reads/writes to database. (don't ask me what it does, I can't touch or change this class)

my question is: to follow proper MVC design, it seems that the ServerList should hold references to Form and DatabaseThingy. But when creating a .NET app, it seems that we are forced to make the Form (the view of MVC) the owner of ServerList and DatabaseThingy. How would I properly break this down into an MVC design and who should "own" what?

A: 

Your Form interacts with the controller, something that has access to the ServerList, which in turns knows how to interact with the DatabaseThingy.

In your case, you could implement a service (or services) that interact with the ServerList. Your Form would call the methods in those services which would execute the required tasks.

GoodEnough
+1  A: 

Check out this StackOverflow question.

urini
A: 

ahh, the untapped power of the search button :-)

urini -- I tried to click "accept answer" for you but it won't let me...

eviljack