New GUI Templates and Model View Presenter

Posts   
 
    
KastroNYC
User
Posts: 96
Joined: 23-Jan-2006
# Posted on: 16-Jan-2007 20:00:49   

Just looked at the GUI templates and their really good. Just wondering if you've checked out the MVP pattern from Martin Fowler and if you'd consider giving me some help on altering them enough to make them fit. I've been checking out the Passive View version - http://www.martinfowler.com/eaaDev/PassiveScreen.html and the GUI templates already somewhat resemble them. Probably not much work to get it going. There's a C# implementation of this at http://www.codeproject.com/useritems/ModelViewPresenter.asp.

Using the MVP pattern you can test your views without a UI. Kinda weird check out the links for more details, but really very useful, especially with WPF coming.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39776
Joined: 17-Aug-2003
# Posted on: 17-Jan-2007 00:32:40   

Nice idea. I havent looked at model view presenter, and I heard it's different from MVC so I'll try to get more info on that to see if the templates can be adjusted in that area.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39776
Joined: 17-Aug-2003
# Posted on: 26-Jan-2007 11:03:26   

I haven't looked at any pattern when I created the templates. What my main goal was was creating as less code as possible while still creating a useful gui. One cornerstone was to re-use code, so user controls were a logical solution to that. To keep code low, the datasourcecontrol was a usable solution to make controls almost code-less.

I'm not sure if the current ui templates can be changed in such a way that MVP pattern (or whatever you want to call it, I see mr. Fowler already changed the name of the pattern disappointed ) is easily implemented without a lot of work, as the main reason for that is that the controller here is ... the datasourcecontrol simple_smile .

So i.o.w.: to be able to get a reasonable view up and running, you need asp.net, otherwise the controller can't be used. I also find it rather odd that you can test a view without a UI, as the view(er) IS the UI or am I wrong/not understanding it correctly?

Frans Bouma | Lead developer LLBLGen Pro
KastroNYC
User
Posts: 96
Joined: 23-Jan-2006
# Posted on: 29-Jan-2007 19:09:05   

The MVP pattern can also be used in a WinForms environment and yes, Fowler has moved it to two separate patterns, Passive View and Supervising Controller.

When I mention testing the UI without the UI i meant so using TDD as in using NUnit and Rhino Mocks. You can create a PresenterTest test class and actually ensure that the generic functionality of your UI is intact as in Properties change when expected, events are raised etc. Of course you cannot truly test some things such as ViewState in an asp.net application and this pattern does add complexity and does not play nice with databinding controls either so I do understand why it may not interest you to create these templates.

But... It would be nice to have a template which could generate an assembly such as [ProjectName].Presenters, containing basic interfaces for the views and presenters with constructors accepting these views.

Also is there any chance of having some Manager Templates which ARE instance classes rather than a grouping of static methods?

I guess my lack of Template Studio knowledge is holding me back from making some of these on my own. Any tutorials in the works?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39776
Joined: 17-Aug-2003
# Posted on: 30-Jan-2007 10:32:39   

KastroNYC wrote:

The MVP pattern can also be used in a WinForms environment and yes, Fowler has moved it to two separate patterns, Passive View and Supervising Controller.

As he always does...

When I mention testing the UI without the UI i meant so using TDD as in using NUnit and Rhino Mocks. You can create a PresenterTest test class and actually ensure that the generic functionality of your UI is intact as in Properties change when expected, events are raised etc. Of course you cannot truly test some things such as ViewState in an asp.net application and this pattern does add complexity and does not play nice with databinding controls either so I do understand why it may not interest you to create these templates.

Ah I see. I didn't have any intention to create the templates that way, so if I want to do it that way, I think I have to re-architect some parts of the templates. Now, I focussed on re-using code, so grouped functionality into controls which in turn used the datasourcecontrols a lot to minimize the code to generate.

Also is there any chance of having some Manager Templates which ARE instance classes rather than a grouping of static methods?

You mean more around aggregators/repositories? (DDD - Evans)

I guess my lack of Template Studio knowledge is holding me back from making some of these on my own. Any tutorials in the works?

There's a small tutorial in the manual, but it's pretty small, however that's all there is to learn really. It takes a couple of steps: 1) create your templatebindings or alter an existing one 2) edit the template file from one of the templatebindings files and then you enter the environment of either .lpt templates or TDL templates. I'd go for .lpt templates as these are the most flexible. A key thing to use is the project inspector in the templatestudio ide, together with the reference manual in the SDK. With these, you can browse your complete project's object model in the project, and with the ref. manual you understand what these elements mean. Then, in the template you simply write code to read the data in these objects and control the output, like with the good ol' ASP 3.0 code in the early days.

Frans Bouma | Lead developer LLBLGen Pro