Thursday, May 10, 2012

Book Review: .NET 4.0 Generics Beginner’s Guide

I am definitely no kind of expert in .NET software development.  This is probably not a surprise to any of you who’ve read this blog before, but in the case of this book review, it’s an important fact to keep in mind, as this makes me the ideal target audience for the subject of this article.

 

Packt Publishing’s “.NET 4.0 Generics – Beginner’s Guide” by Sudipta Mukherjee is an excellent resource for any newcomer to the .NET development arena.  Mukherjee’s writing style is approachable and not prone to the kind of dense technobabble that is a common feature in many modern computing texts.

Rather than talking at length about underlying principles, Mukherjee sketches out an outline of the topics and approaches relevant to each section, then walks through the application of those principles with the added context of detailed examples.  These walkthroughs contain several “Have A Go Hero” points where the reader is encouraged to try the example out for themselves, and rather than saying “This is what the example will do”, the analysis of the examples happens after the user has attempted to try the code for themselves.  As a kinaesthetic learner I found this to be particularly helpful.  This approach drives the reader towards implementation, not just explanation – and actually having used the code patterns exposed in this text means I’m less likely to forget them after I’ve set the book aside for more than a week.

In terms of topic coverage, I have to say I found this book to be quite comprehensive.  Early chapters explain the history of the problems addressed by generics and outline the interfaces common to most .NET generics (i.e IEnumerable, IComparable) and then jump straight into seeing simple generic types and collections in action. 

This text also contains an excellent introduction to C# Extension

Methods and LINQ.  I have to admit that my understanding of LINQ is only basic at best, and the explanation of the various LINQ clauses along with the use of anonymous funcs, actions and delegates made more sense to me upon reading this text than after attempting to grind through others that have covered the same ground.

As the book progresses, more complex usage patterns are unfolded before the reader, and more complex types that use or are composed of more primitive generic types are explained in the context of the primitive types used.  Multithreading in .NET Generics is described with some especially clear examples, and given my background in scripting, seeing just how powerful the eventing model in .NET 4.0 generics is was - quite frankly – astonishing!  Additional third-party libraries are also described (again, with great examples) and the book is rounded out by a couple of great chapters on best practices and performance tuning – again in a way that takes great pains to show, not tell.

Some of the examples are quite amusing as they occasionally contain quirky references to well known internet and software brands.  Between the easy reading, the great examples and the humour I have little choice but to give this book a 5-star rating, and to offer Mukherjee and the editing team at Packt Publishing a resounding pat on the back!

[tweetmeme source="Ozziemedes" only_single="false"]

Monday, May 7, 2012

Where I’ve been and What I’ve been doing

Wow… it’s been too long since I posted here.  I guess that means it’s time I offered a brief explanation.

In September 2010 I tendered my resignation from HP and hung out a shingle as a SQL Server consultant/architect/developer.  During the following 20 months or so I’ve been pretty busy actually working on client projects.  Since I’m in the process of ramping up into a new piece of work I actually have the luxury of a few minutes to do some blogging.

So… what have I been doing?  Well… the first project was for an agricultural services company doing some data modelling for a customer data warehouse and the SSIS development to populate said warehouse.  In that project I was using SQL Server 2008 R2, Pragmatic Works BI Documenter, BIDS 2008 R2 and Visual Studio 2010 Data Tools for the database development and source control.

The second project was much more code-intensive – I was building a database and corresponding client-side data entry application (and a bolt-on ASP.NET web site) to handle cross-institutional status credit assessments for a local university.  For that project I used Visual Studio LightSwitch on the client-side to build the forms solution.

Some of you might be asking “What the hell is Visual Studio LightSwitch?” – and I’m glad you asked.  VSLS is a model-driven framework for rapidly building business data applications using some of the best practice features in the .NET framework.  Amongst other things, it uses:

  • ADO.NET Entity Framework (to abstract underlying data stores as objects that can be interrogated and updated via LINQ to Entities)
  • Microsoft Extensibility Framework (to provide a plugin model for various kinds of functionality, including themes, custom controls, application shells, business object templates, screen templates and so on)
  • Model-View-View Model N-tier architecture (which enforces separation of concerns and imposes good coding practices regarding the separation of UI logic from business logic and data logic)
  • Microsoft’s QuickLaunch framework (for deployment of client-side and mid-tier binaries)
  • Native Azure integration (both for the presentation/business tiers (deploys as Azure hosted apps) and data tier (deploys as SQL Azure database))
  • Visual Studio’s data tools (to manage the enumeration and deployment of database changes – although this is hidden from the developer)
  • Claims-based security model using the ASP.NET authentication and session management database (to allow pluggable authentication models (none/forms based/windows authentication) and a relatively simple claims-based security model to be implemented within applications)
  • Choice of C# and VB for code-behind

Microsoft promotes LightSwitch as a “No-Code” framework, although in its version 1.0 form, the degree to which that claim is valid is limited to the simplest of data entry and search forms.

The solution I built in LightSwitch does a lot of custom data presentation, complex validation logic, compiles/sends emails from templates stored in SQL Server, allows the upload, download, preview and printing of documents and has a lot of term-based search functionality.  Navigation is relatively intuitive, and the solution is now deployed into production.  I also built a simple ASP.NET form for processing approvals from lecturers.

Once I got the hang of some of the quirks of the LightSwitch 2011 (i.e. v1.0) platform and learnt how to recover quickly from some infrastructure issues (within LightSwitch) that cropped up a few times, I was able to be quite productive within the framework.  Given that as coders go, I make a great data architect this is quite an achievement.  However, I’d warn any business developers who are looking to invest heavily in LightSwitch to be wary of the V1.0 release, as it’s documented fairly sparsely and it took quite a while for the forum junkies on MSDN to get up to speed with some of the common glitches that you might come across.  With that said, once you’ve got over the initial hump and had to rebuild a couple of apps from scratch you’ll find it to be a much more efficient solution for building business applications than hand-coding WinForms, ASP.NET, WPF or Silverlight apps.  The flexible deployment options also make for a painless release process and your infrastructure guys will love you for the painlessness of the application deployment side of the picture.

This solution is going to form the basis for a cloud-based multi-tenanted solution that other higher educational institutions can subscribe to.

In addition to the status compendium solution I have also started mapping out data models and some initial screens for a couple of other applications.  The first is an IT architecture repository that allows IT architects, change managers and service delivery managers to provide traceability and audit of business functionality through to the application systems, source code and the infrastructure on which those solutions have been deployed.  The second is a concept for a crowd-sourcing solution to allow people with idle capital equipment to lend/hire out their gear to other people who need it for short term projects.

[tweetmeme only_single="false"]