Translation
Event
health and safety
IT Related
Marketing
Equipment
Printing
Recruitment
a team building idea
Related Articles
IBM Rational head: We're transforming
16 November 2007
When Danny Sabbah became general manager of IBM's Rational division in 2005, he set out to make changes in the organization. Sabbah said Friday that this transformation is well under way."I think you will see a lot more reality to that vision in the second half of 2008," he said. "By 2009, you won't recognize Rational."A key Rational project is Jazz. "What we're doing now is starting to create the IDE (integrated development environment) of the year 2010," Sabbah said. One of the first Jazz products is Rational Team Concert, a real-time collaboration portal, which is now in beta.The Jazz project symbolizes the shift in focus at Rational, Sabbah said. At different points, the company focused on developing "best of breed" developer tools, and then on process and methodology, he said. Jazz doesn't negate that work but aims to "treat the application life cycle as an entity in and of itself," Sabbah said. "It's a very different perspective from, 'How am I the best coder, or the best tester, or change management expert?'""I talk about Rational being the ERP (enterprise resource planning) vendor for the business process of software development," he added.Overall, Sabbah's leadership of Rational has indeed invoked change, said analyst Judith Hurwitz, a longtime IBM watcher."Historically, they've had a lot of tools that didn't really work together all that well," she said of the company, which IBM bought in 2003. "From the outside, it looks like they're building much more of a platform than a series of disconnected tools."IBM bought Watchfire, a Web application security company, earlier this year. Sabbah said IBM is going to use Watchfire's technology to embed the notion of security early in the software development process. "The way you encourage developers to understand those types of rules is to inject those design patterns into their tools," he said.As Rational undergoes change, competitor Microsoft has in turn been evolving its own development products, such as the Visual Studio IDE.Sabbah said IBM will make sure Rational continues to play well with its rival because of the mixed environments many IBM customers have. Either IBM or its partners will create Jazz plug-ins for the Visual Studio stack, he said.However, Sabbah is unimpressed by Microsoft's roadmap for application development beyond Visual Studio 2008. The project, codenamed "Oslo," is based around using model-driven design to build and manage composite applications. But the vision is still hazy, as Microsoft has set no release dates."I have a hard time dealing with announcements from Microsoft that are nothing but paper," Sabbah said. "I can write vision documents too. It's just hard to make judgments on things that aren't real.... All I can tell you is, the stuff we're doing with Jazz, it's running code."Sabbah also said he has little use for a recent trend: Tools and platforms that supposedly make it easy for business users to do some development."I don't believe any of that stuff," he said. "I've never met a business user that can use any type of professional development tool. Period." Business users are better off working within more familiar environments, such as spreadsheets and word processing programs, he said.IBM is instead working on how to better connect coders with the needs of business. "The whole idea is to improve the communication between the developers and the business analysts who are trying to convey the requirements," he said.
ASP.NET MVC Framework (Part 1)
13 November 2007
Two weeks ago I blogged about a new MVC (Model View Controller) framework for ASP.NET that we are going to be supporting as an optional feature soon. It provides a structured model that enforces a clear separation of concerns within applications, and makes it easier to unit test your code and support a TDD workflow. It also helps provide more control over the URLs you publish in your applications, and can optionally provide more control over the HTML that is emitted from them. Since then I've been answering a lot of questions from people eager to learn more about it. Given the level of interest I thought it might make sense to put together a few blog posts that describe how to use it in more detail. This first post is one of several I'll be doing in the weeks ahead. A Simple E-Commerce Storefront Application I'm going to use a simple e-commerce store application to help illustrate how the ASP.NET MVC Framework works. For today's post I'll be implementing a product listing/browsing scenario in it. Specifically, we are going to build a store-front that enables end-users to browse a list of product categories when they visit the /Products/Categories URL on the site: When a user clicks on a product category hyperlink on the above page, they'll navigate to a product category listing URL - /Products/List/CategoryName - that lists the active products within the specific category: When a user clicks an individual product, they'll navigate to a product details URL - /Products/Detail/ProductID - that displays more details about the specific product they selected: We'll build all of the above functionality using the new ASP.NET MVC Framework. This will enable us to maintain a "clean separation of concerns" amongst the different components of the application, and enable us to more easily integrate unit testing and test driven development. Creating A New ASP.NET MVC Application The ASP.NET MVC Framework includes Visual Studio Project Templates that make it easy to create a new web application with it. Simply select the File->New Project menu item and choose the "ASP.NET MVC Web Application" template to create a new web application using it. By default when you create a new application using this option, Visual Studio will create a new solution for you and add two projects into it. The first project is a web project where you'll implement your application. The second is a testing project that you can use to write unit tests against it: You can use any unit testing framework (including NUnit, MBUnit, MSTest, XUnit, and others) with the ASP.NET MVC Framework. VS 2008 Professional now includes built-in testing project support for MSTest (previously in VS 2005 this required a Visual Studio Team System SKU), and our default ASP.NET MVC project template automatically creates one of these projects when you use VS 2008. We'll also be shipping project template downloads for NUnit, MBUnit and other unit test frameworks as well, so if you prefer to use those instead you'll also have an easy one click way to create your application and have a test project immediately ready to use with it. Understanding the Folder Structure of a Project The default directory structure of an ASP.NET MVC Application has 3 top-level directories: /Controllers /Models /Views As you can probably guess, we recommend putting your Controller classes underneath the /Controllers directory, your data model classes underneath your /Models directory, and your view templates underneath your /Views directory. While the ASP.NET MVC framework doesn't force you to always use this structure, the default project templates use this pattern and we recommend it as an easy way to structure your application. Unless you have a good reason to use an alternative file layout, I'd recommend using this default pattern. Mapping URLs to Controller Classes In most web frameworks (ASP, PHP, JSP, ASP.NET WebForms, etc), incoming URLs typically map to template files stored on disk. For example, a "/Products.aspx" or "/Products.php" URL typically has an underlying Products.aspx or Products.php template file on disk that handles processing it. When a http request for a web application comes into the web server, the web framework runs code specified by the template file on disk, and this code then owns handling the processing of the request. Often this code uses the HTML markup within the Products.aspx or Products.php file to help with generating the response sent back to the client. MVC frameworks typically map URLs to server code in a different way. Instead of mapping URLs to template files on disk, they instead map URLs directly to classes. These classes are called "Controllers" and they own processing incoming requests, handling user input and interactions, and executing appropriate application and data logic based on them. A Controller class will then typically call a separate "View" component that owns generating the actual HTML output for the request. The ASP.NET MVC Framework includes a very powerful URL mapping engine that provides a lot of flexibility in how you map URLs to Controller classes. You can use it to easily setup routing rules that ASP.NET will then use to evaluate incoming URLs and pick a Controller to execute. You can also then have the routing engine automatically parse out variables that you define within the URL and have ASP.NET automatically pass these to your Controller as parameter arguments. I'll be covering more advanced scenarios involving the URL routing engine in a future blog post in this series. Default ASP.NET MVC URL Routing to Controller Classes By default ASP.NET MVC projects have a preconfigured set of URL routing rules that enable you to easily get started on an application without needing to explicitly configure anything. Instead you can start coding using a default set of name-based URL mapping conventions that are declared within the ASP.NET Application class of the Global.asax file created by the new ASP.NET MVC project template in Visual Studio. The default naming convention is to map the leading URL path of an incoming HTTP request (for example: /Products/) to a class whose name follows the pattern UrlPathController (for example: by default a URL leading with /Products/ would map to a class named ProductsController). To build our e-commerce product browsing functionality, we'll add a new "ProductsController" class to our project (you can use the "Add New Item" menu in Visual Studio to easily create a Controller class from a template): Our ProductsController class will derive from the System.Web.MVC.Controller base class. Deriving from this base class isn't required - but it contains some useful helper methods and functionality that we'll want to take advantage of later: Once we define this ProductsController class within our project, the ASP.NET MVC framework will by default use it to process all incoming application URLs that start under the "/Products/" URL namespace. This means it will be automatically called to process the "/Products/Categories", "/Products/List/Beverages", and "/Products/Detail/3" URLs that we are going to want to enable within our store-front application. In a future blog post we'll also add a ShoppingCartController (to enable end users to manage their shopping carts) and an AccountController (to enable end users to create new membership accounts on the site and login/logout of it). Once we add these two new controller classes to our project, URLs that start with /ShoppingCart/ and /Account/ will automatically be routed to them for processing. Note: The ASP.NET MVC framework does not require that you always use this naming convention pattern. The only reason our application uses this by default is because there is a mapping rule that configures this that was automatically added to our ASP.NET Application Class when we created the new ASP.NET MVC Project using Visual Studio. If you don't like this rule, or want to customize it to use a different URL mapping pattern, just go into the ASP.NET Application Class (in Global.asax) and change it. I'll cover how to-do this in a future blog post (when I'll also show some of the cool scenarios the URL routing engine enables). Understanding Controller Action Methods Now that we have a created a ProductsController class in our project we can start adding logic to handle the processing of incoming "/Products/" URLs to the application. When defining our e-commerce storefront use cases at the beginning of this blog post, I said we were going to implement three scenarios on the site: 1) Browsing all of the Product Categories, 2) Listing Products within a specific Category, and 3) Showing Details about a Specific Product. We are going to use the following SEO-friendly URLs to handle each of these scenarios: URL Format Behavior URL Example /Products/Categories Browse all Product Categories /Products/Categories /Products/List/Category List Products within a Category /Products/List/Beverages /Products/Detail/ProductID Show Details about a Specific Product /Products/Detail/34 There are a couple of ways we could write code within our ProductsController class to process these three types of incoming URLs. One way would be to override the "Execute" method on the Controller base class and write our own manual if/else/switching logic to look at the incoming URL being requested and then execute the appropriate logic to process it. A much easier approach, though, is to use a built-in feature of the MVC framework that enables us to define "action methods" on our controller, and then have the Controller base class automatically invoke the appropriate action method to execute based on the URL routing rules in use for our application. For example, we could add the below three controller action methods to our ProductsController class to handle our three e-commerce URL scenarios above: The URL routing rules that are configured by default when a new project is created treat the URL sub-path that follows the controller name as the action name of the request. So if we receive a URL request of /Products/Categories, the routing rule will treat "Categories" as the name of the action, and the Categories() method will be invoked to process the request. If we receive a URL request of /Products/Detail/5, the routing rule will treat "Detail" as the name of the action, and the Detail() method will be invoked to process the request, etc. Note: The ASP.NET MVC framework does not require that yo