Wednesday, February 20, 2013

Slow Cheetah to the rescue in .Net application deployments

Managing deployments of .Net components into different environments is not going to be that easy if we are going to rely on manual editing of config files after deployment. Web.config Transformations is an official feature to support this but it's lacking the support for other .Net project types as well as it's not that a developer friendly mechanism.

Recently when I was looking to use config transformations to manage publishing .Net components into different environments (to avoiding the possible mistakes in manual config editing), this nice extension came up  on the search results, which was a life saver with its support for other project types as well as the nice "Preview" feature.

SlowCheetah - XML Transforms

Friday, December 14, 2012

Avoid developers miss using ASP.Net Session

ASP.Net is a powerfull framwork and also it is one of the best in terms of developer friendliness. It has been identified as such developer friendly because of the set of features which are readily available to the developer. Out of the vast collection of such features ASP.Net Session should be one of the leading features that's being miss-used by the developers. Even though the feature is there, one of the guide lines I follow and mentor others to follow is strctly restrict on using the Session object in ASP.Net. Rules of thumb for using a Session variable should be, to ask your self whether it doesn't change through out a users's web session (the variable that you are going to use). If the asnwer is yes it is a better candidate to use as a Session variable, but if not you'll have to seriaously re-consider.

It's not just us miss using the ASP.Net,  even Microsoft too miss use it (although they woud have reason to explain). Here's a post of mine related to one such situation, SQL Server Reporting Services using "our" Session state.

That being said, one of the way's to better manage the ASP.Net Session in a project is to access ASP.Net Session using a facade or an adapter pattern. Here is a nice article on the facade pattern usage for it. Even if we follow this type of a facade pattern to access ASP.Net Session, yet some developpers tend to avoid it and directly access it through the ASP.Net Page classes Session property, and work with magic strings and all sort of bad things. Looking for a simple solution for this lead me to below workarround just to avoid using Session property directly in ASP.Net Pages. I know this is not purly inline with Liskov substitution principle, no stricly avoid usage at compile time, but serves the purpose through the use of a PageBase.

PageBase

Saturday, October 6, 2012

ReviewPal available on Visual Studio 2012 !

It's been months, the Visual Stuio 2012 release was out. But I couldn't get my hands on to it with the busy line of work.

People out there have not only started playing around with it, but have started to really use it with all their plug-ins, extensions. As with everyone, no one want's to leave their dev toys when moving into a new version of the beloved developer IDE, and I'm glad to hear from a few out there asking whether my Visual Stuio exteion on MSDN Gallery, ReviewPal supports the new version of Visual Stuio  and if not when would it be available.

So I had to put some time over the last weekend to make them happy (aka being happy by making others happy), which lead me to play around with the new Visual Studio version too (not to mention how cool the new version of Visual Studio is).The end result, ReviewPal is ready for Visual Studio 2012 in a few hours.

ReviewPal 2012

What's new

  1. Upgrade for Visual Studio 2012.
  2. Fixes for items reported in CodePlex Issue Tracker.
  3. Updates to set more appropriate default values.

Please leave your feedback on MSDN Gallary and I would get back to your requests soon.

Friday, August 10, 2012

Explore assemblies with dotPeek

Time to time we get are required to investigate on .Net assemblies without having their source code with us. Reflector was the ultimate friend for this purpose for a long time among the .Net community, untill it became a commercial product. Then it came the ILSpy from SharpDevelop, which helped us on the same purpose quite nicely.

But now here's our ultimate .Net developer tools provider JetBrains  comming up with yet another cool tool for decompiling and assembly browsing, with all the goodness of what we have experienced in Resharper and best of all for free. Have a sneak peek at it below. 

dotPeek


Tuesday, February 28, 2012

String enumerations for C#

As a language C# has come a long way from the days beginning from version 1.0 beta. But still it's hard to believe that there's no Enumeration support for strings built in. There are several solutions available by several people on the internet, but I thought of putting together my version because it contains a slight additional bit to it (thanks Aravinthan on your thoughts)
The main reason for which I felt it's needed was to give a type safely to methods so that the level of mistakes done in method usage could be reduced through string enumerations rather than being just strings.
Here's an example of what I'm talking about.

As you can see above, the sender email address was just type of string, making it possible to easily make a mistake and pass in any string value into it. Actually in our case the sender email should be one of the configured email addresses in the web.config. So instead of the sender email being string, a string Enumeration was ideal.

With the above Enumeration class the method could be made more type safe and avoid mistakes like below.

And the icing on the cake is , the implicit operator implementation, which makes nice to read when using the same enumeration in places like assignments, without explicit casting.