Monday, December 26, 2011

Visual Studio 11 Developer Preview

MSDN subscribers can download the previews today as well as the new release of .NET Framework 4.5 Developer Preview; general availability is on Friday, September 16.
Some exciting announcements are being made here at BUILD.  Visual Studio 11 provides an integrated development experience that spans the entire lifecycle of software creation from architecture to code creation, testing and beyond. This release adds support for Windows 8 and HTML 5, enabling you to target platforms across devices, services and the cloud.  Integration with Team Foundation Server enables the entire team to collaborate throughout the development cycle to create quality applications.
.NET 4.5 has focused on top developer requests across all our key technologies, and includes new features for Asynchronous programming in C# and Visual Basic, support for state machines in Windows Workflow, and increased investments in HTML5 and CSS3 in ASP.NET.
We’ve shared a lot at BUILD already, for more on the future of Windows development I suggest you take a look at Steven Sinofsky and S. Somasegar’s blogs. More details on Team Foundation Server including the new service announced at BUILD and how we’re helping teams be more productive can be found on Brian Harry’s blog.
Quick Tour around Visual Studio 11 Features
Visual Studio 11 has several new features, all designed to provide an integrated set of tools for delivering great user and application experiences; whether working individually or as part of a team. Let me highlight a few:
Develop Metro style Apps for Windows 8
Visual Studio 11 includes a set of templates that get you started quickly developing Metro style applications with JavaScript, C#, VB or C++. The blank Application template provides the simplest starting point with a default project structure that includes sample resources and images. The Grid View, Split View, and Navigation templates are designed to provide a starting point for more complex user interfaces.

From Visual Studio 11, seamlessly open up your Metro style app with JavaScript in Expression Blend to add the style and structure of your application.

Due to the dynamic nature of HTML it is often difficult to see how a web page is going to look unless it is running.  Blend’s innovative interactive design mode enables you to run your app on the design surface as a live app instead of a static visual layout.

Enhancements for Game Development
We have added Visual Studio Graphics tools to help game developers become more productive, making it easier to build innovative games. Visual Studio 11 provides access to a number of resource editing, visual design, and visual debugging tools for writing 2D / 3D games and Metro style applications. Specifically, Visual Studio Graphics includes tools for:
Viewing and basic editing of 3D models in Visual Studio 11.

Viewing and editing of images and textures with support for alpha channels and transparency.

Visually designing shader programs and effect files.

Debugging and diagnostics of DirectX based output.

Code Clone Analysis
Visual Studio has historically provided tools that enable a developer to improve code quality by refactoring code. However this process depends on the developer to determine where such reusable code is likely to occur. The Code-Clone Analysis tool in Visual Studio 11 examines your solution looking for logic that is duplicated, enabling you to factor this code out into one or more common methods. The tool does this very intelligently; it does not just search for identical blocks of code, rather it searches for semantically similar constructs using heuristics developed by Microsoft Research.
This technique is useful if you are correcting a bug in a piece of code and you want to find out whether the same bug resulting from the same programmatic idiom occurs elsewhere in the project.
Code Review Workflow with Team Explorer
Visual Studio 11 Preview works hand in hand with Team Foundation Server 11 to provide best in class application lifecycle management. Visual Studio 11 facilities collaboration is by enabling developers to request and perform code reviews through using Team Explorer. This feature defines a workflow in Team Foundation Server that saves project state and routes review requests as work items to team members. These workflows are independent of any specific process or methodology, so you can incorporate code reviews at any convenient point in the project lifecycle.
The Request Review link in the My Work pane enables you to create a new code review task and assign it to one or more other developers.

The reviewer can accept or decline the review, and respond to any messages or queries associated with the code review, add annotations and more. Visual Studio 11 displays the code by using a “Diff” format, showing the original code and the changes made by the developer requesting the review. This feature enables the reviewer to quickly understand the scope of the changes and work more efficiently.

Exploratory Testing and Enhanced Unit Testing
As development teams become more flexible and agile, they demand adaptive tools that still ensure a high commitment to quality. The Exploratory Testing feature is an adaptive tool for agile testing that enables you to test without performing formal test planning. You can now directly start testing the product without spending time writing test cases or composing test suites. When you start a new testing session, the tool generates a full log of your interaction with the application under test. You can annotate your session with notes, and you can capture the screen at any point and add the resulting screen shot to your notes. You can also attach a file providing any additional information if required. With the exploratory testing tool you can also:
  • File actionable bugs fast. The Exploratory Testing tool enables you to generate a bug report, and the steps that you performed to cause unexpected behavior are automatically included in the bug report.
  • Create test cases. You can generate test cases based on the steps that caused the bugs to appear.
  • Manage exploratory testing sessions. When testing is complete, you can return to Microsoft Test Manager, which saves the details of the testing session and includes information such as the duration, which new bugs were filed, and which test cases were created.
What’s New in .NET 4.5
.NET 4.5 has focused on our top developer requests.  Across ASP.NET, the BCL, MEF, WCF, WPF, Windows Workflow, and other key technologies, we’ve listened to developers and added functionality in .NET 4.5.  Important examples include state machine support in Windows Workflow, and improved support for SQL Server and Windows Azure in ADO.NET.  ASP.NET has increased investments in HTML5, CSS3, device detection, page optimization, and the NuGet package system, as well as introduces new functionality with MVC4.  Learn more at Scott Guthrie’s blog.
.NET 4.5 also helps developers write faster code.  Support for Asynchronous programming in C# and Visual Basic enables developers to easily write client UI code that doesn’t block, and server code that scales more efficiently.  The new server garbage collector reduces pause times, and new features in the Parallel Computing Platform enable Dataflow programming and other improvements.
Start Coding
Visual Studio 11 includes several new features which will help developers collaborate more effectively while creating exciting experiences for their users.  Here are some are some resources to help you get started.
Enjoy!

ASP.Net MVC vs. MVP

Lately I’ve been thinking a lot about MVC frameworks. I know that a lot of programmers are not 100% concerned with how clean their generated code is, as long as the back-end code is clean and the program produces predictable results. With that said, I’ll try to be fair about this.
What is MVC?
I started getting interested in MVC frameworks in the last year. I really enjoyed the separation of layers, and found it easy to follow. I really enjoyed the idea of separating my view layer out. This would make it less vulnerable to destruction (aka inline styles) by the programmers. This would also mean many reusable parts, so less work for me.
MVC stands for Model, View, and Controller. Basically your Model is your data access layer, your Controller is your business-logic layer, and your View is your interface layer (how things are going to display to the end user). This separation means that you can assign different parts to different people, and they don’t necessarily have to interfere with each other’s code. In all practicality, this will never be the case, but it is possible.
Keep in mind that MVC is not a framework (didn’t I just say that I was experimenting with MVC frameworks?), it is a pattern that many frameworks are based on. For example, Rails, ASP.Net MVC, ASP.Net MVP, and CodeIgniter (php) are all frameworks based on the MVC programming pattern.
Web Forms
I feel that I should explain where all of this stemmed from. In the early days, before the web was widely used as a platform for software (because of the limitations of the media), Microsoft developed a method of developing software interfaces with WinForms. WinForms are still used today for developing desktop applications (we use them all the time), but as the web started to mature as a platform Microsoft decided to create a port of WinForms to the web. This would allow software developers to easily port their desktop applications to the web using the tools that they already knew. Good job, Microsoft! This is known today as Web Forms, or ASP.Net.
ASP.Net is not going to be replaced by ASP.Net MVC or MVP (at least not anytime soon), as it is a very mature platform, and very powerful. The “problem” with ASP.Net is that it’s really flexible. This makes it difficult to automate testing. Also, ASP.Net controls output some bloated code that is often difficult to work with for designers (though Microsoft is promising to fix this, more on that in the coming weeks). However, the speed and power of Web Forms for heavily data-driven applications is not to be matched by ASP.Net MVC or MVP. Enter ASP.Net MVC to address these “issues”.
ASP.Net MVC
ASP.Net MVC is a fair departure from the original ASP.Net Web Forms concepts. MVC comes with a completely different set of tags, and is heavily reliant on a pre-determined file structure. I’m not going to get into building an actual application, as that’s not the point of this entry, but if you’re interested in getting started with ASP.Net MVC, you can get a free chapter from the “Professional ASP.NET MVC 1.0” book on Scott Gu’s blog.
Basically, your project is split among three different folders: “Models”, “Views”, and “Controllers” (you don’t say!). This degree of separation allows for a separation of tasks, as well as a distinct structure for what code goes where. That’s not to say that you couldn’t access data directly from the controller folder, but this defeats the purpose of the MVC. It follows the basic principles of any other MVC framework, and your view layer is formed more in the manner of php or ruby, than in traditional ASP.Net WebForms. Here is a brief diagram of how your data flows through an MVC based application.

The major “problem” with ASP.Net MVC is that it performs poorly for applications that handle a lot of data. Not so much poorly as more inefficiently than a traditional ASP.Net application. The reason being that ASP.Net MVC is a framework built on top of the .Net framework (framework built on top of a framework). This tends to slow things down, as you are executing commands through 2 frameworks, essentially. However, I’m sure that a well-designed ASP.Net MVC application will perform better than a poorly-designed traditional ASP.Net application.
The Major plus, in my mind, is that MVC appeases the web standards activist in me. Front-end coders have much more control over the output code (like when you develop an application with php). There is also the fact that you have a standardized programming structure and an increase in reusable code. I’m sure that these benefits far out-weight the inherent performance blow for many web application developers (even me!). I don’t have any exact numbers on what sort of performance hit you will take, but I haven’t seen the numbers in any of the articles and writings that I have read thus-far. On top of all of these benefits, MVC also increases testability. Visual Studio allows you to run automated tests to assist you in increasing your application’s performance, and minimizing the amount of errors that the end user will encounter.
ASP.Net MVP
ASP.Net MVP is derived from MVC. When I first heard of it, I thought that it was basically MVC for people who refuse to give up on WebForms. To a degree, it is just that. However, if you utilize the framework to its full potential, it’s so much more. My eyes have been opened by this article on MVP by the writers at dot net slackers. They do a good job at explaining the more detailed intricacies between MVC and MVP (I also derived my diagrams from theirs). The idea is that the presenter takes on logic, like a traditional ASP.Net application. Thus this Presenter layer may be interchangeable. For example, you can swap out your WebForms Presenter for a WinForms Presenter, or a SilverLight Presenter. This allows you to easily convert your web-based application to a desktop application. The structure of data flow differs from that in an MVC application:

On top of that, you also have the added bonus of testability (just like in MVC). However, you also run into the limitation of an inherent performance blow, due to the fact that MVP is also a framework built on top of another framework. Also, it produces the same bad front-end code as WebForms (as your Presenter is built with WebForms), though Microsoft is promising to address this issue in .Net 4.0. I’ll hold my breath until then…
My final obvious benefit is that MVP uses WebForms. Yes, I know I just said that I don’t like the code that is produced, but all of our programmers already know how to use them. Not only that, but this also means that we can utilize the endless number of controls that are already built and ready to use for ASP.Net applications. AKA, we can hit the ground running, and have the benefits of an MVC design pattern!
I hope that this overview of my understanding of the technologies was helpful. Obviously I can’t make the decision on which technology to use for you. I’ve tried not to get too technical, as when I set out to find out the differences, I was thrown into a world of code, while still not knowing what either of the technologies was intended to do. Please leave a comment if you want me to clarify. If I can’t answer directly, I’m pretty good at researching.