Living in the Tech Avalanche Generation

A practitioner’s introspective on technology

Archive for the 'Ruby' Category

Using Ruby Naming Conventions in C# code? Is that madness?

During my journey in learning Ruby / IronRuby, I have caught myself often naming things in C# with a Ruby convention or BDD test naming regime. To be extreme here’s an example:

var customer_to_make_preferred = Get_Customer_By_Id<ICustomerMakePrefered>();

//OR METHODS LIKE THIS

public void Group_By_Orders_And_Print_To_Console_Window()
{
    //…..etc
}

I really find a benefit in greater understanding when reading code when I take this approach. Now it’s true I have been programming in C# for some 10 years and I don’t know if this kind of behaviour will see me excommunicated from the circle of brethren or not but I would like to know what others think.

Opinions please! And yes I know this is gonna be like waving a red flag in front of a raging bull :). And for the Ruby people, I am only proposing the extended underscored naming convention and nothing else – it’s all about naming and that’s it – ya basta!

Share/Save/Bookmark

6 comments

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

Preparing for IronRuby

I decided to share my experiences on the path to IronRuby so far and perhaps it might be useful to others who wish to travel that road.

Not so long ago I posted about choices in front of me regarding learning a new language. After having programmed in C# for some 7 or so years I wasn’t going to choose another statically typed language, I wanted to add a dynamic language to my arsenal and with the DLR on it’s way and a key interest and stake in the Silverlight, the choice as obvious.

After having decided to dedicate the time and effort to IronRuby, the next question was how to address the learning. Clearly picking up IronRuby as the first pit stop was going to come with some difficulties borne out of the fact that the documentation isn’t great yet and the toolset way of being close. Based on this, I decided that learning Ruby first was the best way to progress this goal for two main reasons, one it allowed me to learn in the comfort of an IDE (NetBeans) to write ‘do as you learn‘ code and also gave me a perspective on IronRuby that is not indifferent to its genealogy.

So after downloading NetBeans (Ruby Edition) and installing Ruby 1.8.6, I got my hands on the excellent free online book by Jeremy McAnally, the title of which is “Mr Neighbourly’s Humble Little Ruby Book“. This book is a nice little quick starter to get you comfortable with the absolute basics of Ruby, but needs to be followed by something with a bit more industrial strength such as Matz very own offering The Ruby Programming Language.

DLR PadOnce having navigated this far, I decided that it was time to pull down the IronRuby bits and start to have a play. A while back now, Hanselman and Gu both posted some early pieces on getting started with IronRuby. Most people seem intent on making XAML based applications the focus of their IronRuby attention, which in turn lead me to DLR Pad (see the image above) which provides the ability to interactively script IronRuby (and IronPython) against a statically set window that contains a XAML UI layout (interesting). From there I found my way to Ivan Porto Carerro’s blog and book on IronRuby. Ivan’s book is not yet released but is available as early access, so I decided to avail myself of it.

And if your wondering what code looks like (see below) for something that you might have been routinely doing (as I was), it doesn’t take long to knock something (trivial in this case) together to begin to get the picture, in the case of having gone down the path I described above.

require ‘mscorlib’
require ‘System.Windows.Forms,
  Version=2.0.0.0, Culture=neutral,
  PublicKeyToken=b77a5c561934e089′

begin

    #alias the forms namespace
    Windows = System::Windows::Forms
    #new up a form & set it’s text
    first_ruby_window = Windows::Form.new
    first_ruby_window.Text = “Simons first Ruby Form”
    #new up a button
    first_ruby_button = Windows::Button.new
    #subscribe to the buttons click event
    first_ruby_button.click {|sender, args| first_ruby_button.Text =
                                    “I got clicked!”}
    #add the button to the form
    first_ruby_window.Controls.Add(first_ruby_button)
    #show my new form
    first_ruby_window.ShowDialog()

end

And we get the following:

first_ruby_form

So that’s my story (to date) and perhaps it offers some help in getting you underway with your IronRuby / DLR journey.

Share/Save/Bookmark

No comments

Next Page »

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