My Resume | Contact Me | RSS Feed | Follow Me on Twitter

Code Capers

The Ninja Coding Dojo
RSS Feed Twitter Email

Preview 1 of ASP.NET MVC 2 Released

clock July 31, 2009 by author Michael Ceranski

In my humble opinion, MVC for ASP.NET was a very important addition to the ASP.NET stack. WebForms was a bad model that only led people to develop poorly performing web applications. The was largely attributed to the Post-back paradigm that was utilized by most WebForm controls. In any case, MVC tends to be a better pattern because when you PostBack, you are generally going to be more aware of it (because you will probably have to implement some code in the controller). It is not a transparent operation like it tended to be in WebForms.

Anyway, getting back to the matter at hand, ASP.NET MVC 2 Preview 1 has been released. According the ASP.NET MVC Roadmap, the theme for ASP.NET MVC 2 is "Improved Productivity and Enterprise Ready."

Here are a list of features that will be available in preview ASP.NET MVC 2 Preview 1

  • Templated Helpers - allow you to automatically associate edit and display elements with data types. For example, a date picker UI element can be automatically rendered every time data of type System.DateTime is used. This is similar to Field Templates in ASP.NET Dynamic Data.
  • Areas - provide a means of dividing a large web application into multiple projects, each of which can be developed in relative isolation. This helps developers manage the complexity of building a large application by providing a way to group related controllers and views.

  • Support for Data Annotations - Data Annotations enable attaching validation logic in a central location via metadata attributes applied directly to a model class. First introduced in ASP.NET Dynamic Data, these attributes are now integrated into the default model binder and provide a metadata driven means to validating user input.

And for Preview 2:

  • Client Validation - builds on top of the Templated Helpers and Data Annotations work done in Preview 1 to provide client-side validation based on the model's validation attributes. This provides for a more responsive experience for users filling out a form with validation.

  • Strongly-typed input helpers - allow generating form input fields using code expressions against the model. This allows the helpers to take advantage of Data Annotations attributes applied to the model and reduces errors caused by lack of strong typing such as typos.

  • Strongly-typed link helpers - allow developers to take advantage of Intellisense support (due to the strong typing) to discover which controllers and actions are available for linking.

  • Asynchronous Controller Actions - provides a programming model for writing actions that can call external resources without blocking a thread. This can increase the scalability of a site that needs to interact with web services and other external services.

  • Areas - continued refining of the Areas feature, enabling a single project approach for developers who wish to organize their application without requiring multiple projects.

  • Other Improvements - continue to fix known issues carried over from ASP.NET MVC 1.0 as well as ASP.NET MVC 2 Preview 1. Also including API improvements based on user feedback along with minor new features.

I am really excited about ASP.NET MVC! I am so happy that the ASP.NET development team finally gave us an alternative for WebForms. I started using MVC about 3-4 years ago in J2EE and I was always disappointed that there was not an equivalent technology for ASP.NET. Now that I have MVC and LINQ I feel like the boundaries have been lifted.

Related Articles:
Hanselminutes on 9 - ASP.NET MVC 2 Preview 1 Released

ScottGu's post on ASP.NET MVC 2
Download Page for ASP.NET MVC 2 Preview 1



Microsoft to Power Yahoo Search

clock July 29, 2009 by author Michael Ceranski

It was announced today that Microsoft will now power Yahoo! search while Yahoo! will become the exclusive worldwide relationship sales force for both companies' premium search advertisers.

The transaction will have to go under regulatory review before it can be made official. Therefore it will probably be early 2010 before we actually see this deal come to fruition. In the mean time the Microsoft and Yahoo! have established a website at http://www.choicevalueinnovation.com to provide consumers, advertisers and publishers with additional information about the benefits of the agreement.

This "merger" is a step in the right direction for Microsoft Bing if they want to compete with the search giant Google. If you look at the graph below you can see that Google has a large lead on the competition but second and third place belong to Yahoo and Microsoft. Combining the two together could finally put some competitive pressure on Google.

Read the full article here: http://yhoo.client.shareholder.com/press/releasedetail.cfm?ReleaseID=399702



A Free SCOM Alternative for SQL Monitoring

clock July 28, 2009 by author Michael Ceranski

Every once in a while I will hop on Codeplex and search for new tools. As a SQL DBA I have found a lot of great/free tools on Codeplex such as OpenDBDiff and PAL for SQL Server. Today, I discovered the SqlMonitoring tool. The project description is as follows:

The SqlMonitoring tool makes it possible to monitor SQL 2000, 2005, 2008 environments and send alerts to a central database (SQL 2008). A client can be used to view the alerts en perform actions on them. This tool is a good alternative if you do not have the budget or infrastructure for tools like SCOM.

The application is still and beta so I would not risk your reputation trying to sell this to your CEO as your default monitoring tool. In any case, if you are working at a small shop with limited funding then this application would probably be worth a look. If nothing else, you can take the existing source code and get a head start on developing your own monitoring tool.

At my current company, we use a combination of SCOM, HP OpenView and Host Monitor. Having three separate systems is a little confusing at times but the Operations and Infrastructure group claim that they need all three because they each serve a unique purpose. Apparently, the new directive is that SCOM is for application layer monitoring, HP OpenView is for hardware level monitoring and Host Monitor is for availability monitoring. What do you use at your company and why?



Hey Developers! Tune your SQL!

clock July 27, 2009 by author Michael Ceranski

I have been a DBA for about 2 years now. Of course, most people who know me think I am an application developer because I still spend a lot of time writing .NET code. Anyway, over the course of the last 2 years I have really been focusing on how to performance tune SQL Server. This process has really changed my outlook as a developer. As a result, I am no longer happy with my code unless it performs well at the application and the database layer.

The best way to learn about SQL performance tuning is to learn how to read an execution plan. This is the easiest and most rudimentary way to find out what your query is doing under the covers. Most poorly performing queries are a result of a table scan or clustered index scan. A scan means that you are basically looking at the table row by row in order to find the results. A properly tuned SQL statement will typically use a index seek. I like to use the analogy of someone trying to find a phone number in a phone book.

An index scan would mean that I am going to flip through each page to find someone's phone number. Perhaps I only know the person's street address and first name and because the phone book is organized by last name I can not easily find a good starting point for my search. Therefore I will have to resort to flipping through each page, one by one. This is very inefficient and time consuming.

An index seek would come into play if you know the person's last name. If I am looking for "Joe Smith" then I know that I should look in the "S" section. Since the phone book is ordered by last name I can use the table of contents (index) to find their information.

I put together this short list which ranks the items seen in a typical execution plan from worst to best. The basic idea behind this list is to try to turn a table scan into something better such as an index seek. This could be accomplished by creating an index or modifying your query to properly use the index of maybe even updating your statistics.

  1. Table Scans (Worst)
  2. Clustered Index Scan
  3. Index Scan
  4. Index Seek (Best)

So by now you probably came up with the rule that we should turn always try to convert scans into seeks, right? Well not necessarily. If you are are searching a table with only 100 records in it then you probably do not need to waste your time optimizing the query. The entire table can probably be fit into a single page and adding an index to the table is just going to waste storage space. Also, when you do a “select *” without a where clause you are most likely going to do a scan. 90% of the time you should avoid “select *” but there are occasions when you may need to use it. For example, I have a application that stores configuration values in a table. When my app starts up I issue a “select * from configuration” and then I cache the values.

If you get stuck trying to tune a query then do not give up. SQL 2005 and SQL 2008 ship with the Database Engine Tuning Advisor (DETA). The DETA will run your query through several different scenarios and it will make suggestions on how you can improve the performance. Some of the possible solutions will be to add/drop indexes, update statistics or re-write your SQL to take advantage of the existing indexes. In SQL management studio you can right click on your query and send it to DETA for analysis.

In addition to DETA, SQL 2005 and above also have Dynamic Management Views. One of my favorite DMV queries is the “missing index query”. This query will tell you which queries could be improved by adding an index and it will even give you the DDL to create the index!

   1:  SELECT 
   2:      CONVERT (decimal(38,1), 
   3:      migs.avg_total_user_cost * (migs.avg_user_impact / 100.0) * (migs.user_seeks + migs.user_scans)) AS improvement_measure, 
   4:      'CREATE INDEX [missing_index_' + CONVERT (varchar, mig.index_group_handle) + '_' + CONVERT (varchar, mid.index_handle) 
   5:      + '_' + LEFT (PARSENAME(mid.statement, 1), 32) + ']'
   6:      + ' ON ' + mid.statement 
   7:      + ' (' + ISNULL (mid.equality_columns,'') 
   8:      + CASE WHEN mid.equality_columns IS NOT NULL AND mid.inequality_columns IS NOT NULL THEN ',' ELSE '' END 
   9:      + ISNULL (mid.inequality_columns, '')
  10:      + ')' 
  11:      + ISNULL (' INCLUDE (' + mid.included_columns + ')', '') AS create_index_statement, 
  12:      migs.*, 
  13:      mid.database_id, 
  14:      mid.[object_id]
  15:  FROM 
  16:      sys.dm_db_missing_index_groups mig
  17:      INNER JOIN sys.dm_db_missing_index_group_stats migs ON migs.group_handle = mig.index_group_handle
  18:      INNER JOIN sys.dm_db_missing_index_details mid ON mig.index_handle = mid.index_handle
  19:  WHERE 
  20:      CONVERT (decimal(38,1), migs.avg_total_user_cost * migs.avg_user_impact * (migs.user_seeks + migs.user_scans)) > 10
  21:  ORDER BY 
  22:      migs.avg_total_user_cost * migs.avg_user_impact * (migs.user_seeks + migs.user_scans) DESC

Of course, you need to remember that DMVs are only useful when your instance has been running for a while. DMVs only have information about your SQL environment since the last startup. If your instance has only been running for a few minutes then chances are that your DMV data is useless. If you want to check how long your SQL server has been running then just look at the creation date of your tempdb database (it is recreated every time you restart SQL).



Update: How to Get Windows 7 Early

clock July 23, 2009 by author Michael Ceranski

A few weeks ago it was rumored that Windows 7 was going to be released in late July. Unfortunately, the release was delayed and now we should expect to see the RTM version be made available on MSDN on August 6th.

Disclamer: This version is not guaranteed to be exactly the same as the version shipped on the official October 22nd release date. If a major bug is discovered before the official release date then Microsoft will certainly make adjustments to the code. The August 6th date is RTM which means it is typically the final build that we will see before Windows 7 hits the shelves later this year. RTM is generally released to manufacturers so they can work out any bugs the software may encounter with hardware devices. GA or General Availability is the final release that will be shipped out to all major retailers on October 22nd.

Related Articles:
Windows Team Blog - When Will You Get Windows 7 RTM
Win7 RTM begins rollout Aug 6th, OEMs and some beta testers to get early headstart
My Original Post: How to Get Windows 7 Early, on July 13th



About the author

MikeMy name is Michael Ceranski. I am a software developer from Buffalo NY. I have been writing code for over 10 years starting with Borland Delphi and later migrating to the .NET stack. I enjoy blogging about .NET, MVC and jQuery and I hope to spread my enthusiasm for technology by sharing my thoughts and ideas with you.

View my resume

Cumulus

This will be shown to users with no Flash or Javascript.

Sign in