From: Syver Enstad Date: 2002-09-17T20:53:23+09:00 Subject: Re: MVC and OO Design? jcb@iteris.com (MetalOne) writes: > Thanks to all for your help. > > I was really thinking very abstractly about a problem in my head that > MVC kind of demonstrated. I was in search of deep answers in regards > to when to include a function in a class and when not too. The common > > wisdom states that when a function needs access to the classes data, > it should be included with the class. MVC strays from this notion > because the View needs access to the Models data and yet the View > functions are not placed in the class. Yes, that is true. This is because, you might have multiple views on the model, so the functionality has to be separated in to differnet classes. > > The responses above brought me back to a more concrete reality. MVC is > > there to separate out user interface code. It is also true, that I > did not understand the roll of the controller. Thinking of a passive > Model and a passive View has also helped me with my current problem. > > Perhaps it is wise to pull functions out of a class along functional > lines that require specialized developer skills such as GUI, Database > Access, Encryption, etc. Or maybe it only makes sense for GUI, > because, of the need to easily change the GUI. What I personally go by is to keep functions to the class that has the data. That is until this becomes troublesome. Troublesomeness might come from the class being difficult to test becuase it paints on the screen, accesses a relational database and similar things. The class in other words becomes difficult to work with because it does too many things. This leads to layering where you move the methods that access f.ex the database to a class that deals with the database, move gui methods to views and so on. -- Vennlig hilsen Syver Enstad