From: Friedrich Dominicus Date: 2002-09-17T14:32:45+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. That is not true. the view does know nothing about the Model the only one which knows of it is the Controller. But you have to provide all the access functions a Controller may need in both the View and the Model. I'll try to show a simple example (not Ruby) Modell a number a a number b model work is add a b View a textfield a_number a textfield b_number a output field c_number accessors to a_number b_number setter for c_number Controller Model class View class Controller get data from View query the content of the view my_a = View.get_textfield_a_content my_b = View.get_textfield_b_content ask the model do it's work out the work my_sum = Model.add(a, b); update the view View.set_c_number(my_sum) ..... You can write that example down nearly one-to-one in Ruby. You just have to to know the Ruby GUI classes. But you see it fit's perfectly into the OO model. Controller does not know about the inners of both it just uses the official available interface provided by Model, but the view and the Model do not know anything from each other. All this knowledge is bundeled in the Controller. I hope this clarifies it. Regards Friedrich