Living in the Tech Avalanche Generation

A practitioner’s introspective on technology

Archive for January, 2009

Becoming a polyglot or dilettante programmer?

Learn a new language each year. Or so the polyglot mantra goes. Sounds feasible enough right? After all, the more experienced we get as programmers the lower the barriers to entry in learning new languages right?

Over the last six months or so I have been trying to learn Ruby / IronRuby with mixed success. First up I started by reading some free information aimed at learning POR or plain old Ruby as I call it - sorry excuse the tongue in check but I couldn’t resist the chance coin my very own ‘Plain Old’ acronym given half the chance :). I started by reading Mr Neighbourly’s Humble little Ruby Book and taking all the examples and writing them (in NetBeans Ruby Edition) and then adding to those examples with some further experimenting of my own. This was all going nicely until the real world (working life) got hold of me in one way or another and my time in following through with Ruby started to wane. I have since then attempted to reorganise aspects of my daily life in a way that would incorporate Ruby in the hope of picking up the momentum again, for example I am posting some of my Patterns series in Ruby and even bought Ivan Porto Carrero’s rough cuts of his unfinished book, but still I feel it’s not enough to really let the early work take root and ferment.

many_hats_polyglot So what’s required to really learn  this new language? If you think about how we learn languages and develop our skills in them, it relies heavily on becoming active in developing with the given language, however most of us are employed in an environment where the expectation is that we will be developing (with some specialisation) in a single language and on a single platform. In my opinion I believe that what is needed is a project that is persistent and on going, all of which is easier said than done, there always seems to be an omnipresence of DotNet related learning and on the surface that should take precedence; how do I choose?

This year I am going to continue my learning of XAML based UI technology, develop a DSL for data transformation in a particular domain of interest, continue my learning of the Entity Framework as deeply as possible and really give NServiceBus a lot more time and use it at every (appropriate) opportunity and of course I will continue to write this blog. So where is my quality Ruby time going to come from? Answer I don’t know but I feel strongly that being a polyglot programmer of any depth means taking on significant projects in your newly chosen language of learning. Perhaps I have to settle with being a polyglot dilettante in the shorter term?

I would love to hear some other opinions on all this.

Share/Save/Bookmark

4 comments

Silverlight vNext needs better error reporting.

error I would really like to see better error messages and exceptions in the next version of Silverlight, certainly in the Isolated Storage realm at any rate. A message of “Operation not permitted” for just about every error is not that helpful. System.IO.IsolatedStorage.IsolatedStorageException seems to cover a bit too wide a scope of error conditions for my liking. For example I would have thought that accessing a directory that doesn’t exist could clearly throw something like a “DirectoryNotFound” or something! Take the following code:

using (IsolatedStorageFile store =       
       IsolatedStorageFile.GetUserStoreForApplication())
{
    var fileNames = from f in store.GetFileNames(“PointInCase\\*.pce”)
                    select new { Name = f };
}

Unfortunately, IsolatedStorageFile.GetFileNames(”……”) throws a very all purpose exception and message (as documented above). Generally speaking I am a big fan of the product and all for the “getting things out quicker with less” philosophy, I’m just saying that I would like to see this aspect improved a little in the next release.

Share/Save/Bookmark

No comments

LinqPad for the Entity Framework.

I recently purchased the auto completion addon which is a neat tool for LinqPad. Its pretty cheap and certainly aided in my using LINQ Pad as a scratch pad ala Query Analyzer. For example when dealing with my own Repository and Specification libraries for Entity Framework, I can write and fine tune using scratch pad code along with my libraries directly in LINQ Pad. The benefit is I can verify my queries without any debugging in VS.Net. To use my own libraries that contain the Entity Framework code I can reference those libraries as per below:

refs_linqpad

and import their namespaces into LinqPad like so:

namespaces_linqpad

No I can write code such as:

thepad

If you download my library, you can run this code after setting up as per the above.

NorthwindModel.NorthwindEntities context =
    new NorthwindModel.NorthwindEntities(
  @”Provider=
    System.Data.SqlClient;
  Provider Connection String=
    ‘Data Source=boomer;
    Initial Catalog=Northwind;
    Integrated Security=True;
    Connection Timeout=5;
    MultipleActiveResultSets=true;’;
      Metadata=
    res://*/”);

var german_cust_spec =
    new Specification<NorthwindModel.Customer>
    (c => c.Country == “Germany”);
var italian_cust_spec =
    new Specification<NorthwindModel.Customer>
    (c => c.Country == “Italy”);

var spec = italian_cust_spec | german_cust_spec;

var query = from cust in context.Customers
            .Where(spec.EvalPredicate)
            orderby cust.Country
            select cust;

query.Dump();

I absolutely love the fact that I have a tactile query analyzer(ish) IDE to test my Entity Framework queries prior to writing them in VS.Net and further to that I don’t miss out on using my custom libraries that contain classes such as the Specification<T> or  EntitiesRepository<E, C> as demonstrated below.

NorthwindModel.NorthwindEntities context =
    new NorthwindModel.NorthwindEntities(
  @”Provider=
    System.Data.SqlClient;
      Provider Connection String=
    ‘Data Source=boomer; Initial Catalog=Northwind;
    Integrated Security=True; Connection Timeout=5;
    MultipleActiveResultSets=true;’;
      Metadata=
    res://*/”);

var german_cust_spec =
    new Specification<NorthwindModel.Customer>(c => c.Country == “Germany”);
var italian_cust_spec =
    new Specification<NorthwindModel.Customer>(c => c.Country == “Italy”);

var spec = italian_cust_spec | german_cust_spec;

EntitiesRepository<NorthwindModel.Customer, NorthwindModel.NorthwindEntities>
    repos = new
    EntitiesRepository<NorthwindModel.Customer, NorthwindModel.NorthwindEntities>
    (context);

var repos_query = from cust in repos.All(spec)
        select cust;

query.Dump();

If your a LinqPad user you might want to consider buying the LINQPAD auto completion add-on which I get great value out of. I would however love Joseph to make LINQPAD more Entity Framework friendly and provide us the SQL output created by the Entity Framework Provider as it does for LINQ To SQL.

Thanks to Stefan for demonstrating how to use LINQPAD with the Entity Framework in the first instance. Give it a try.

Share/Save/Bookmark

3 comments

Next Page »

Creative Commons Attribution-ShareAlike 2.5 Australia
Creative Commons Attribution-ShareAlike 2.5 Australia