China
November 12th, 2007
I’ve arrived to China after a long journey (~35 hours). I still needs to figure out what’s the time and what should I eat. Shanghai is very nice and it looks like any occidental city plenty of people and lights.
This week I will present in Chengdu about Software Factories and next week will deliver a 2 day workshop. And of course I will go to the Great Wall, the Forbidden City and squeeze every minute I’m here.
Hands on Labs for Web Client and Smart Client
September 6th, 2007
The p&p client team is working hard on getting hands on labs for both Smart Client Software Factory/CAB and Web Client Software Factory out of the door. I've been following the work they've been doing and I must say that the labs are the most insightful labs I ever seen.
Mariano was heavily involved in the creation of the labs and he really knows the technology, so the quality of the labs is pretty good. Now he's asking for feedback on the Smart Client labs since a final release of them is coming that will show how to use the Disconnected Service Agent and the WPF support. He also announced that the labs for Web Client Software Factory are available to download.
Web Client Software Factory is out!
January 13th, 2007
Go get it from http://msdn.microsoft.com/webclientfactory
Lot of stuff shipped:
- PageFlow Application Block: design the navigation process of a web application using a state machine from Windows Workflow Foundation.
- Composite Web Application Block: helps you build web clients composed of independent, yet cooperating, modules and increase productivity and reduce overall development time through consolidating architect and developer efforts. From the wiki:
- Decompose a complex Web site into independent visual and non-visual parts that can be built, assembled, and deployed by independent teams.
- Minimize cross-team dependencies that allows team specialization for areas such as UI design, business logic implementation (business logic development may occur across multiple teams), and infrastructure code development.
- Utilize an architecture that promotes reusability across independent teams.
- Increase the quality of applications by abstracting common services that are available for the independent teams to use.
- Promote proven practices for security without requiring everyone to be a security expert.
- Incrementally deploy new capabilities while minimizing downtime.
- Maximize the coverage of automated tests in the code base.
- Object Container DataSource: this is a web control similar to ASP.Net ObjectDataSource but instead of relying on a class that provides you with data it will raises events when it needs the data or when the data contained changes (insert/update/delete). This design allows the view (Web page) to delegate the responsibility of performing select operations, update operations, delete operations, and insert operations to the presenter.
- Web Client Development Automation: I posted about this already.
- QuickStarts: these are the quickstarts included: View-Presenter (with Application Controller), ObjectContainerDataSource, Modularity, Page Flow, Page Flow with Shopping Cart
- A Reference Implementation: this is a banking application inspired in a real world example to demonstrate the guidance in action.
- Documentation, How-Tos, patterns, etc.: available when you install the factory and soon to be published in the codeplex community
It was 6 months of hard work and it was great working again with the patterns & practices team: Blaine (PM), Eugenio (PDM), Mike (Dev Lead), Ed (Architect), Johnny (Dev), Mariano (Dev), Alan (Dev), Bob(Dev), Dragos (Architect), Tim (Tech writer), Juan Carlos (Dev), Prasad (Test) and Terrence (Test).
Web Client Software Factory Automation
December 12th, 2006
(This post was going to be posted a few weeks ago so the images are a bit outdated but the content is the same that you will see in latest drops)
I’ve been working on the Guidance Packages for the Web Client Software Factory. If you read this blog you probably know what is this all about. If not, in short we are adding functionality to Visual Studio 2005 to make the developer life easier
In the case of the Web Client Software Factory (WCSF from now on), in this first release we are targeting modularity, security and a testable programming model among other things.
In this drop you will see something really close to what we will be shipping.
Let’s deep into what the Guidance Package brings to the table.
First of all we will create a new web application and let’s call it “OrderManager”
Before creating the actual solution the recipe asks for a few things:
- Where do you have the binaries (the new CompositeWeb Application Block and Enterprise Library Jan 2006)? I have compiled them and put them in c:\Lib
- What’s the .net namespace that you will use for this application?
This is what we get after the solution is created:
In a nutshell:
- A Website containing a default page, a default master page a default theme, references to the application blocks and EntLib.
- A Shell module with a ModuleInitializer. This module will be used for pages that lives in the website root and some services initialization (like the SiteMapBuilderService and the EnterpriseLibraryAuthorizationService)
If you run the website at this point you will get this:
Adding a module…
We can add our first module by doing a right-click on the Modules solution folder.
The following feature is part of the “new generation” of guidance packages. Before you commit your module creation you can see what is going to happen to your solution (one project will be created, a folder on the website will be created, etc.)
The options are:
- What’s the website project where you want to plug this module?
- Do you want to have a different name for the folder on the website?
- Finally we have an “Add test project” option that will create a VSTS test project for you with the Test Fixture for the DefaultViewPresenter
If we run the solution again we will see the new module plugged in the website
The cool thing about this is the loosely coupled model to add nodes to the sitemap. The OrdersModuleInitializer has a template method to register the sitemap nodes that the module will provide. Here we register the module site map node:
protected virtual void RegisterSiteMapInformation(ISiteMapBuilderService siteMapBuilderService)
{
SiteMapNodeInfo moduleNode = new SiteMapNodeInfo("Orders", "~/Orders/Default.aspx", "Orders");
siteMapBuilderService.AddNode(moduleNode);
}
(A nice addition to this would be a service that reads from the module web.config file and creates the corresponding nodes)
Adding a web page…
We can create pages for our module by right clicking on the “Orders” module folder on the website
We are leveraging the MVP (Model-View-Presenter) pattern. If you used the Smart Client Software Factory you should be familiar with this, if not you can read more about it here and here.
The view is separated in three parts:
- The OrderListPresenter holds the logic for the view and has access to the view via an interface (IOrderList). This increases the testability of your applications. The idea is to have the view do almost nothing. Its responsibility will be to show stuff that the presenter wants and notify the presenter of user events (clicks, selects, etc.).
- The IOrderList interface is the contract for the Presenter
- Finally the OrderList.aspx + .cs is the actual implementation of the interface that will show things on the webpage.
If we want to show this view in the navigation control (in this case a TreeView) we would add the following code to the RegisterSiteMapInformation:
protected virtual void RegisterSiteMapInformation(ISiteMapBuilderService siteMapBuilderService)
{
SiteMapNodeInfo moduleNode = new SiteMapNodeInfo("Orders", "~/Orders/Default.aspx", "Orders");
siteMapBuilderService.AddNode(moduleNode);
SiteMapNodeInfo orderListNode = new SiteMapNodeInfo("OrderList", "~/Orders/OrderList.aspx", "Order List");
siteMapBuilderService.AddNode(orderListNode, moduleNode);
}
Running the site at this instance will show the following:
Implementing a view and its presenter…
We will implement the basic things to show a list of orders on the web page.
Let’s start from the presenter logic. Note: If we were using TDD we would start from a test that would be called “ShowOrderListOnViewLoaded()”.
public class OrderListPresenter : Presenter<IOrderList>
{
public override void OnViewLoaded()
{
// TODO: Implement code that will be executed every time the view loads
List<Order> orders = new List<Order>();
orders.Add(new Order("Order 1", 12300, DateTime.Now));
orders.Add(new Order("Order 2", 200, DateTime.Now));
orders.Add(new Order("Order 3", 100000, DateTime.Now));
View.Orders = orders;
}
We are setting the Orders of the View property. The View property belongs to the base Presenter class and it provides access to the view via its interface (IOrderList).
That means that we need to add the Orders property on the interface
public interface IOrderList
{
IList<Order> Orders { set; }
}
Finally we will implement it on the OrderList.aspx:
We can use the smart tag on the interface to generate the required interface contract:
Then we add the GridView to the page
And finally implement the interface:
public IList<Order> Orders
{
set
{
GridView1.DataSource = value;
GridView1.DataBind();
}
}
Running the site again…
That’s it. We have a Web application that leverages:
- MVP design pattern
- The best practices for ASP.Net
- Exception handling using Enterprise Library 2006
- Authorization infrastructure also from Enterprise Library
- Dependency Injection
- And a lot of other things that you will discover…
Lastly, if you are wondering about “Why use GridView.DataSource and not some DataSourceControl like ObjectDataSource?”
We are shipping with the factory a DataSourceControl called ObjectContainerDataSource that will work very well in these scenarios. Mariano has an interesting post.
Announcing the patterns & practices Web Client Software Factory
September 25th, 2006
The Client team at patterns and practices released the Smart Client Software
Factory two months ago. I’ve been part of the development of this software
factory and now joined the team again for the new software factory for Web
Clients
Eugenio Pace, Michael Puleio and EdJez already blogged about it. This is an exciting project and hopefully we will make
the life easier for developers to write web projects using proven practices
and patterns with the help of guidance automation, reference implementations, how-tos, hands on labs, workshops, etc.
The window with the community will be opened at the new
CodePlex site. You will
find the first alpha drop!