November 2008 Entries
Identify code smells with tags

Visual Studio comes with TODO markers where you can mark sections of code with little comments to indicate that you need to do something. However, TODO sometimes becomes too generic. You start to mark tasks, features, futures, (bugs have their own by default) with the same tag. Fortunately you can add custom ones. If you have Re-sharper installed, you get additional benefits since it allows you to create filters, identify the tags inside comments and highlight them on the right margin.

One tag to add is SMELL. A code smell is a piece of code that works yet it just isn't right, and you know that the longer it's left in there, there worse it can get. It can lead to an unsustainable situation where the whole project can start to smell like a dump site. Other times it's just a small section that is isolated and won't have immediate side-effects, but would be good to get it cleaned up.

Now, I know the purists would probably scream and say that any smell should be eradicated then and there. Snap back to reality. Both you and I know that that's not always viable. Having said that, If it's a bad smell that can lead down a spiral of stink, then yes, it should be, taking into account schedules, etc.. but even in that case, you're not going to do it all at once, so you still need to identify the smells as you go cleaning them up.

Here's some screen shots of smells with Resharper

image

To define them, use Resharper's To-Do item entry

image

You can also see on the To-Do Explorer

image

TechEd Online Interview on ASP.NET MVC

While I was at TechEd in Barcelona last week, I had a chance to sit down with Mark Dunn from .NET Rocks and talk a little bit about ASP.NET MVC and jQuery. They've recorded the interview. You can watch it here

Programmers are not typists first

I've found that many of the things Jeff Atwood posts about, most of us think about. The difference is that some are so blatantly obvious that you would never even consider blogging about it. But each to his own.

However, there are some things that just blow my mind. His latest post about programmers are typists first is one of them. Let me first say that I'm a firm advocate of annihilating the mouse from a developer's toolbox. Ok, that might be a little extreme, but point being, you are more productive if you learn keyboard shortcuts and don't have to reach out so much for the mouse. However, I wouldn't say that developers are cats first, then programmers.

Initially one could understand Jeff's title as expressing that being a fast typist is important. If that were the statement, to a certain degree I would concur, and I say to a certain point because at least on my team, we don't measure productivity in terms of keys pressed per minute.

So Jeff comments:

We are typists first, and programmers second. It's very difficult for me to take another programmer seriously when I see them using the hunt and peck typing techniques. Like Steve, I've seen this far too often.

Well let's think about that for a moment. If you're not a professional typist or never taken courses, the only way to improve is through practice. As a developer, the more you write code, the more you practice your typing skills. People also tend to say that you really can't be a pen and pencil architect unless you've got your hands dirty with code, and that I do believe. So to a certain point, the previous statement makes sense, but I don't think it's black and white thing.

He continues to say:

Steve and I believe there is nothing more fundamental in programming than the ability to efficiently express yourself through typing. Note that I said "efficiently" not "perfectly". This is about reasonable competency at a core programming discipline.

What has the rate of keys per minute (KPM) got to do with efficient expressiveness of code?Efficiency can be an indication of how expressive or clear your code is, or how fast it executes where speed matters, not how fast you type it into a text file. I would say efficiency is more about coding if statements correctly or using LINQ where it makes sense. 

This next comment blows my mind:

What I'm trying to say is this: speed matters. When you're a fast, efficient typist, you spend less time between thinking that thought and expressing it in code. Which means, if you're me at least, that you might actually get some of your ideas committed to screen before you completely lose your train of thought. Again.

I really don't have much to say about this other than it's utter nonsense. In fact he tries to justify it somewhat in the next paragraph:

Yes, you should think about what you're doing, obviously. Don't just type random gibberish as fast as you can on the screen, unless you're a Perl programmer. But all other things being equal -- and they never are -- the touch typist will have an advantage.

Advantage over what? Over thinking faster? Over beating the next guy on the team on expressing his thoughts?

I'm also a self-taught typist, and I've learnt through practice, spending years writing code. My wife is a great typist also. She didn't take courses either, she's worked with computers for many years. She suck at programming, but she's great at Office. Get the point? You become a good typist by practicing and using a computer. The more you use it, the better you become. You don't need to take a course on typing before learning how to program.

Add Comment Filed Under [ Various Productivity ]
SQL Server 2008 Install - MediaInfo.xml missing

I was installing SQL Server 2008 today (x64 bit version) and after the initial checks it does, I got an error about MediaInfo.xml file missing. Looking in the folder where it had unpacked the files, effectively I couldn't find a reference to it. After a very hard session of extensive research, I found that others had run into similar issues. Some of the suggested solutions were to re-install .NET 3.5 SP1. Others said to re-install the complete .NET framework. One guy had re-installed his entire OS and still had issues.

Clearly not being the path I wanted to go down, I decided to try and install the 32 bit version to see if it was a problem with the 64 bit. This one seemed to go ahead with the install. Looking at the decompressed files, I saw that the missing files were there on the 32 bit. I then cancelled the install and ran the 64 bit one again. After decompressing the files, the missing files were also there. I thought maybe I had a bad run and let it continue. However once it did all the checks and I hit Continue, suddenly half of the files were deleted from the folder. So it seems that at some point the installer was deleting the files.

So instead of running the installer bootstrap, I decompressed the files and ran the setup manually. And it worked. So if you get a errors on missing files, decompress the package and run the setup.exe manually and it should work ok.

Add Comment Filed Under [ SQL Server ]
Design Principles event next month in Belgium

I'll be doing a talk in Belgium next month at the Visual Studio User Group, where I'll be covering topics such as Separation of Concerns, Single Responsibility, Interface Segregation, Dependency Injection and Inversion of Control, along with examples of IoC containers. There's limited space (90) and already 55 signed up, so if you're in or around the neighbourhood, got nothing better to do than here my brag, come along. I think they are organizing a geek dinner afterwards so it should be fun. Although the talk will be in C#, the important things to grasp are the concepts, not the language, be it Visual Basic, Delphi or whatever else (obviously it needs to be a OO language).

WCF Book to help Juanma

Everyone knows that unless you're writing about Harry Potter, it's hard to get rich from a book, and even more so a technical one. I wrote the book on WCF mostly as an adventure, being my first in Spanish and sole author. I decided sometime ago that I wanted to give all proceeds from my cut to a charity. After getting in touch with a number of them requesting information (let's just say I don't trust 100% all charities), and never getting a reply back from any, I decided to look for something close by. I'd heard about Juanma from a friend of mine (Guillermo Som) and we've been actively helping (Málaga .NET User Group as well as all other user groups around Spain) by organizing events, raffling prizes, etc. Juanma has an illness called Leukodystrophy also known as Alexander's Syndrome and the family is trying to raise funds to further investigations to find a cure.

Therefore, all proceeds from the author's cut will be destined directly to this cause. Krasis Press, the publisher is aware of this already and everything will be handled directly by them. So if you speak Spanish and need a book on WCF, know that you're also contributing to a good cause by buying a copy. If you don't, but feel you still want to help Juanma, please visit their web site: www.ayudajuanma.es

 

image

Add Comment Filed Under [ Various ]
ASP.NET MVC Practices Session Material

Here's my presentation from my TechEd talk on ASP.NET MVC. I'll be uploading the demos as soon as I get them cleaned up. Any questions, you know how to reach me.

Presentation Tip

If you're doing multiple demos that somehow involve CSS, make sure you rename the default Site.css file ASP.NET MVC creates for you. Otherwise, during a presso you'll go crazy trying to figure out why half of your demos aren't rendering correctly. In other words, make sure each demo has it's unique CSS filename so you don't run into browser cache "issues".

11 Comments Filed Under [ ASP.NET MVC Speaking ]
Skype for iPhone

Finally! A decent Skype client for the iPhone. I've just downloaded it today (yes, it's free) and it seems to work great. The cool thing is that it support multiple protocols so under same interface I now have MSN too. It can also do Google Talk, ICQ, Twitter, etc. It seems (haven't investigated, only tried it quickly) that they've disabled Skype calls over 3G (for obvious political reasons), but I'm more interested in the Chat features.

Nearly forgot: www.fring.com

Add Comment Filed Under [ Various ]
Linq to Sql is dead. Did you abstract well?

Here's an update on the roadmap for Linq2Sql. The post is pretty much confirming that they're killing off the project.

A project we started recently, we had to make a choice of which ORM to use. Since Entity Framework wasn't still up to par (and in certain aspects probably still isn't), and the team had experience with Linq2Sql, we decided to use that. However, from day one, we made a conscientious choice of not leaking anything of L2S into our domain objects.

This meant that we didn't use the L2S objects, but in turn used our own POCO classes. Therefore the sole purpose of L2S was to map data from the DB, what the job of an ORM is. Recently, and before the announcement, we found a lot of shortcomings when working with L2S and aggregate roots (I won't get into the details since Steve is planning a series of posts on the subject and how to handle aggregate roots with the different existing ORM's). We've therefore decided to switch ORMs. The beauty of it is that because of the clear abstraction of L2S, it's going to be very easy to swap out L2S for another ORM.

Now that we have confirmation that L2S isn't going anywhere, if you have issues with the current version and were hoping to get them resolved in a future release, I guess you're out of luck. So the time comes to move on. If you've abstracted well, it shouldn't hurt that much.

Obviously if you don't have issues with L2S and no projections on needing new features, then stick to what you have. "If it ain't broken, don't fix it". But don't start any new projects with it. Even Microsoft don't recommend it anymore.