tags:

views:

48

answers:

1

I have to implement an Form View, or in other words: A class that is used to put a complex input form on the screen.

The Form is built up of FormComponents. There is an addFormComponent() Method to compose the form with these. And then, the form has an isValid() Method which will go through all the FormComponents and check their associated FormValidators.

For sure this thing has a lot of "intelligence", but most of this is just a call to some other class. For example the isValid() method does cool stuff, but it really only calls the isValid() methods of the FormComponents which are registered in an array. Nothing too fancy.

Well, that beeing said, must I make a fat FormViewController for this, or is an View just fine?

My understanding of these is, that a ViewController is used when there's some big logic involved. In this case, the Form View has a template which will simply iterate over the FormComponents and include them. Each FormComponent has it's own template in turn and does it's own stuff.

I've always been struggling with ViewController and View and I think I'll keep on doing that until I get a nice R.I.P. brick... but maybe someone can clear this up a little bit ;-)

+1  A: 

The purist in me is saying that this belongs in a ViewController. I guess maybe it would depend on the framework you are using. For example, this type of setup would be very easily implemented in a Spring Controller object. It sounds like creating a controller in your case would be a lot of extra work.

Nothing is ever set in stone. You can implement in the View for now and if this turns out to be a huge burdon, move it to a Controller class. Knowing when to refactor is the difficult part.

darren