PDA

View Full Version : Creating Views – The right way



tomerb78
25 Mar 2012, 5:17 AM
We’re often dealing with the question what exactly is a View in our application.

Do we have to distinguish between View and “custom control” – a custom component that can be used by different views?

Can View hold another View?

When a View needs to popup a modal dialog (a complex one, maybe a form), is this dialog is a View by itself? Or should it all be part of the same view?

If the modal dialog is a View by itself, who should create a show it? The parent view? Or maybe its controller? Or the application itself that naturally should hold all the views…?

So we’re thinking to adopt the following approach:
View is a logical slice of the application that has common purpose.
View part that can be commonly used (for example, special context menu) will be created as a “custom component” and will be used by the View.
In order to reduce complexity on complex Views, part of the view can also be refactored to “view part components” and it will be used by specific view.
If view should be created dynamically, then the application itself should create it and manage its existence. Meaning that Views should never be created by other views or controllers.
We didn’t start yet to test this approach practically, so we will really appreciate your comments, insights and opinions about this.

mitchellsimoens
25 Mar 2012, 6:39 AM
A view is anything that displays. A custom component is a view. A plain grid is a view. A form is a view.

The application is just some glue to bootstrap the application. Controllers are where the logic for the application is and is the only "smart" portion of the app.