Book review: C# in Depth

December 29th, 2009 § 0

image Its been a while since I’ve read a book that’s almost purely about a programming language and C# in Depth does not disappoint.  Even though I’ve recently done a couple of Microsoft certification exams and read the relevant preparation materials, those were more about the .NET framework and the .NET libraries more than any particular programming language.  This book is all C# though, cover to cover, and Jon Skeet lives up to the hype…

Fear not! There is none of the boring “Chapter 1: What is a class” type of material here.  It is assumed that you are already familiar with programming in C# and the material serves more to highlight how the language has evolved from C# 1.1, through C# 2.0 to C# 3.0 and explains how the language version numbers are not the same as the framework version numbers.  The book dives right into a preview of the most modern C# trends, before going back to explain how it all got to be that way.  Some of it was really mind-blowing stuff to me, and it really shouldn’t have been because that was only the C# 2.0 parts. There is so much potential in the C# 2.0 language and .NET 2.0 framework and they are really under-utilised, possibly due to being overshadowed by the emergence of .NET 3.0 and quickly followed by .NET 3.5 with LINQ.

For those LINQ enthusiasts out there, you really should read this book if you want to understand the fundamentals of LINQ and where it evolved from (a LOT of it is based in C# 2.0 generics and anonymous methods/delegates).  If you’re like most of us developers, you’re probably only just moving on to using .NET 3.5 at work and possibly don’t even realise some of the power you’ve been missing out on.  Having worked on several corporate projects in 2009, it appears that many larger organisations are still sticking using .NET Framework 2.0. By the way, you can get away with using a lot of the C# 3.0 features on the .NET framework 2.0, since many of the additions are language based or are based on compiler “tricks”. If ever there was a code magician / illusionist – Jon Skeet could be him!

Manning (publishers) are releasing an Early Access Preview of the second edition of this book in electronic form now (the soft-cover is due Summer 2010, according to the Manning C# in Depth website).  I’d still recommend the first edition, having most of the same material except for the last few chapters, and its in paperback form so you can read on the run

Developers and DBA’s

October 20th, 2009 § 0

How well do you know your database server?  And no!, I’m not talking about favourite colours, favourite things to do, or other first date questions here… I mean how well do you know the technology behind your database server and what makes it tick?  Many developers out there focus on the web and application layers and only look to the database layer as a persistence medium.  At least until they need to get a LOT of data in or out in a hurry that is…

More often than not, small companies can’t afford to have a dedicated database administrator (DBA). So it often falls to the technical operations guy/gal and the developers to manage the company database(s).  I’ve been in the position of one of those developers, where looking after databases was more of an add-on task than any official duty, and that experience has taught me that a good DBA is worth their weight in gold.

Every developer should get to know at least one database technology intimately because your database can do a lot more for you than just persist data.  Get to know the engine of your database server: how it works; how it makes decisions on query plans; different algorithms for joining and grouping data and how it all evolved.

As an example, have you ever written a program that processes data on-the-fly and batching bulk-inserts?  Assuming all that bulk-inserted data goes into a set of tables that will later be processed for rollups, you’ll have some indexes on those tables, so that the rollups run faster… right?  Well those indexes will have a dramatic performance impact on your bulk-insert operation… I’ve learned that when processing large amounts of data for crunching rollups later on… only create the indexes just before you need them and then drop the indexes again afterwards.  The reason is that the bulk-insert is probably going to be the long-running operation and writing to a table with 3 indexes across columns can take 2-3 times longer than writing to a table with no indexes.

My database of preference is SQL Server because I’ve worked with Microsoft technologies all my working life and found the tool-sets generally hit the mark on best compromise between functionality and easy learning curve.  SQL Server 2000 was the top dog around the time I was finding my feet and an invaluable resource was Kalen Delaney’s book Inside Microsoft SQL Server 2000.  I have *huge* respect for the team that created one of the first databases that was capable of running on desktop computer hardware, whilst having a .dll/.exe footprint in the order of 10’s of Megabytes and, to this day, is capable of managing databases in the order of Terabytes!

A standard PC more expensive than a high-spec PC?

August 11th, 2009 § 1

A couple of weeks ago, I wrote about how developer’s need faster hard disks.  Now I’ll try to expand on that and build a case for how much it might be costing you to continue using that standard build corporate development PC.  You’re probably like many other developers out there and using a standard-build office PC, possibly with a little boost of RAM to allow you to run some local databases along with your development environment.  Of course, this is all assuming that you are like most developers out there that use a PC purchased and supplied by your company.

If you’re like me and work with .NET for most of your day and spend time developing with Visual Studio, you should start paying attention to how much time you end up waiting for your PC to complete any operation that makes you wait.  (This also applies to PHP or Java developers, using Eclipse or any other Java-driven development environment.)  For example, switching between Code and Design view can cause long waits on complex projects.  What about cleaning, compiling and debugging your code?  Starting up your browser? Hitting an exception and switching to debug in Visual Studio?  All these little waits add up and 10-15 cumulative minutes of your day spent waiting is not an unrealistic figure.

So what is a Developer’s time worth? 

Here are some assumptions, based on the UK market average salary for a “.NET developer” (avg. salary taken from itjobswatch.co.uk) UK average .NET developer salary is £34,000

If we take our worst case estimate of 15 minutes spent “waiting” each day, then we can extrapolate the following based on a 37.5 hour week: 15 minutes per day equates to £1,133.29 per year

The best case estimate of “waiting” 10 minutes each day:10 minutes per day equates to £755.53 per year

Now looking at the Dell website (I’m not biased towards Dell in any way and I’m only using them to provide a quick comparative cost), an Optiplex 960 with the following specification:

  • Intel Core 2 Duo E8400 (3GHz, 1333MHz, 6MB)
  • 4GB 800Mhz Non-ECC DDRII Memory
  • Drive 1: 74GB 2.5 inch Serial ATA (10,000rpm)
  • Drive 2: 160GB 2.5 inch Serial ATA (7,200rpm)
  • Intel Graphics Media Accelerator 3100 with a maximum 256MB of shared video memory
  • 16x DVD-ROM
  • Vista Ultimate SP1 32-bit (free upgrade to Windows 7, or add £5 to downgrade to XP pro SP3)
  • 3yr warranty next business day

This costs £873.00 excl. VAT (and businesses would claim back VAT anyway) at today’s prices – 11 August 2009.  This desktop spec is targeted at a typical web-developer.  If you’re going to be doing any serious graphics or .NET WPF, consider adding the “ATI Radeon HD 3470 256MB DDR2 full height DVI/VGA Output” for an extra £97.00.  I’ve left out the monitor, keyboard and mouse because you should have those on your current machine.  We’re pricing an upgrade here, with the aim of passing your standard-build back into the office pc-pool.

No matter how high-spec the new PC, its never going to perform operations instantly, so we’re never going to save ALL of that 15 minutes per day.  Even if we could reduce it to half the time, or less, then this exercise is probably worthwhile.  Most IT business cases that I have seen, want to pay themselves back within 3 years, and as long as we can shave at least a third off that “waiting” time, then we’re in business!

There’s also an additional benefit that is harder to attach a price to.  When typical developers end up waiting for a long-running task to complete, they probably context-switch themselves onto another task to try and keep up efficiency.  I firmly believe that any serious development should be done without distractions (I’ll save the detail for another post), and this “context-switching” could be considered a distraction.  What if you forget to go back and finish some task after switching over to reading an email, for example?  Maybe you’ve just inadvertently introduced a bug…?  How much time and money does that cost, since it might affect you, as well as anyone else involved in checking or using your software.

So development team managers:

Take another look at the equipment your team is using and ask yourself “how much are those standard-build PC’s really saving me by being cheaper than a higher-spec version?”