October 2011 - Posts

A while ago I had a conversation with a gentleman who resisted .NET development on the client side reasoning it that in case .NET framework doesn’t exist, installer won’t fail. WiX 3.6 Beta is out and it solved the “problem”. Reminds me of situation when “business code needs to be efficient to take less memory” situation. We’ve all seen that code die slowly and painfully Smile

Asserting arguments is essentially a healthy practice. What I don’t like, is the fact that since day one ArgumentNullException used a string for argument name, and now with .NET 4.5 almost knocking on the door, there’s still only string option.

 if (x == null)
    throw new ArgumentNullException("Value was null", "x");

Code Contracts introduced a while ago, has an implementation for Requires precondition that is good, yet still has the same issue.

Contract.Requires<ArgumentNullException>( x != null, "x" );

Many other frameworks still rely on string as a source of the argument name for assertions these frameworks make (Sitecore as a such that I have recently used).

Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args");

Why not to add an expression support and be done with it? This way, when you refactor code and “accidentally” rename your argument, assertion message is not going to lie. I’ve being using this code with assertions created by 3rd party:

    public static string Get_Name(Expression<Func<object>> func)
    {
      return (func.Body as MemberExpression).Member.Name;
    }

And no worries about re-naming my arguments.

In my last post I have described the move from NAnt to PSake that is based on PowerShell. One missing piece for making the whole experience smooth was Visual Studio support for PowerShell syntax and some Intellisense. Gladly, I have run into PowerGUIVsx, that does just that: syntax highlighting, intellisense, and even debugging. Sweet!

My exploration of automation and CI has started around somewhere in 2007. Back then it was more of a guess and trial, trying to figure out what I don’t know and should learn. Automated build scripts was the first thing I needed to learn. Back then, NAnt seamed to be the best candidate, and quite frankly, it was the first thing that looked solid to me, therefore making it my default. Ironically, I had my first build script working with Visual Source Safe.

NAnt was a good companion for a long period of time. But at some point in time I have started looking for alternatives. MSBuild looked interesting, considering all of the .NET projects and solutions created by Visual Studio were MSBuild. Why not to extend that and have your scripts in MSBuild completely? But then it was same chatty XML, no better than NAnt quite frankly. I looked at PSake and Rake, but unfortunately, there was no time to get serious with those back then.

Recently, I had to build a small side project, and wanted to build it  from scratch with no old bits copied from previous projects (templates are good, but they don’t allow you to experiment). So I looked again at PSake, which matured a lot and got to version 4. I was pleasantly surprised how fluid it felt to use it. Reading a few good examples (including the wiki on the GitHub) and starting a book on PowerShell (if you want to understand better how PSake achieves what it does so well) I’ve decided to adopt PSake as my build scripting tool from now on.

Why did I like about PSake?

  1. It is not chatty as XML scripting tools
  2. It reads easily for developers who are used to C# (or any programming language)
  3. Easily extendable (based on PowerShell, that is taking full advantage of .NET)
  4. Deployment is a piece of cake (this one is really big – PowerShell is on every computer these days, including servers, which means you do not have to worry to set it up, it’s there for you)
  5. Remote executing – being able to execute scripts remotely allows to have that “backdoor” and “visibility” that I was missing sometimes with NAnt

I am sure there’s more that I haven’t discovered yet, but just this makes it enough for myself to make the decision. So NAnt, So long and thank you for all the fish.

PSake, let the work begin.

2012-01-03: IIS7 and Self-Elevating PowerShell script for web application deployment

There’s another kid on the .NET obfuscation block – totally free and plays nicely with command line - Eazfuscator.NET. It also has a NuGet package available for download, though it’s not up-to-date.

I am catching up on NuGet and learning a few good things. A project should be in buildable state once you pull it from the repository. This is always my goal with the projects I work on. Therefore, one of the requirements that I always set was to have “autonomous” project – everything included within the project itself (libraries, tools, etc.). Some exceptions would be things that don’t make sense to commit and rather have them installed on all machines (OS, Server apps, SDKs, etc.).

With NuGet, my initial approach was always to commit the packages. Then why would someone commit a package that is already sitting on NuGet.org and can be easily fetched from there without trashing my company's repository per each project with probably the same libraries used across multiple projects. I needed a way to use NuGet w/o committing packages to source control. And it’s there! NuGetPowerTools does it in a great way. It modifies project files to verify that components brought through NuGet still present, and if they don’t, instructs to fetch them locally.

image

So the next time projects compile, it only checks for packages, but doesn’t pull them down as they already exist.

image 

Since it rely on project files, it doesn’t matter if your first compilation takes place in Visual Studio on command line, both will work. For Visual studio it will fix the missing assemblies referenced in project issue.

Love it!

2011-12-29: Simpler approach is described here.

Windows Phone, Windows Phone 7, Windows Phone 7.5. And still no change. Consumer is not attracted. I hear a lot about cool features and awesome innovations on various .NET podcasts. A lot is written in MSDN magazine and different .NET developer blogs. Yet consumer is not interested. Or maybe is not even aware of all the mighty potential that can be his or her just by trading the iconical iPhone for Windows logo. Heck, let the trends show what consumer is interested in:

image

Looking around, I can’t find a single one in use among my friends and co-workers. Ironically, quite a few of those happened to be developers as well. So where does it hide? Oh, maybe it masks under that apple logo?…

Moral

If you don’t give it to consumer, it doesn’t matter how great it is, it is still a failure.

For somone who has expertise in PHP and not Razor/ASPX views Phalanger might be a great middle ground. This is an integration of PHP and .NET. Always great to see another language join the .NET club Smile

Ok, now that you actually looked at the post, here are the details.

I am looking into bringing Oren Eini to Calgary to teach RavenDB course. The group will not exceed 6-8 people, and we already have two participants willing to take it. This is a great deal, considering you saving almost 50% (flights, hotel, traveling time if not paid by your company). If you are from Calgary or around and willing to take the course, drop me a note at feldman {dot} sean {at} gmail {dot} com.

Ironically, there are too many people predicting the “end of the world”. For Windows 8 Metro style UI doesn’t make sense if you are developing business applications or using a non-touch interface computer. Windows 8 allows to disable Metro UI (and by that also disables applications that are Metro UI applications) and puts UI into the “conventional” Window 7 look and feel. Registry key for explorer can allow you switching between Desktop and Metro UIs as mentioned in this blog post. So end of the world is postponed to some later days folks.

win8dev-2011-10-04-11-16-05

More Posts