Category Archives: Ruby

Reinventing Yourself at Boston Ruby

I gave a talk at the November 2013 Boston Ruby Meeting about my experience moving back to a development role after working the last few years in more managerial roles in the medical device/laboratory automation space.

My hope was that this talk would help people starting out in the Rails world, or perhaps people who are transitioning to Rails from the Java or .NET worlds as I was.

Along the way, I also talk about ways to establish yourself in a new development community and how to build up your network beyond just adding people to your LinkedIn network


Wicked Good Wrap Up

What an amazing weekend at Wicked Good Ruby, where does one begin.

Thank You Brian, Johnny, Sean, and others

First things first.  Thank you Brian Cardarella, Johnny Boursiquot, Sean Hussey, and all the volunteers for making Wicked Good Ruby happen.  I remember being at the Boston Ruby meetup where Brian announced that he was organizing Boston’s inaugural Ruby conference. We all cheered wildly…then we went home, while Brian, Johnny, Sean and others did the hard work.

Kicking Us Off

Liana Leahy got us kicked off in song, reprising the role of Ruby Minstrel.  Liana has a great gift both vocally and satirically.  And if this Ruby thing doesn’t work out for her, I’m sure she could pursue other avenues

Opening Keynote

I was really excited when it was announced that Sandi Metz would be giving the opening keynote.  She promised to tell our future.  Along the way she took us from ancient scrolls on papyrus, to the Roman codex, handwritten manuscripts, the Gutenberg printing press, right up to the linotype machine.

Sandi shared some childhood memories of her dad, who worked for a newspaper in Parkersburg, WV, who started out working with linotype machines but managed to re-invent himself when the printing world changed in 1965 with the advent of photosetting and the sudden death of linotype machines.

She gave us some hard truths about life, we are going to die, but also reminded us that we need to live and love along the way.  I can’t do justice to Sandi’s words so look for the talk online later.   I was blown away.

Awesome Talks

I won’t try to go over all the talks, though there were a few that I really liked.

Joanne Cheng taught us how to play and explore with Ruby-Processing, showing some truly amazing ways she has used it to visualize data and just have fun.  I liked that she shared unexpected lessons that she learned along the way, becoming a better programmer, gaining confidence.

Mike Nicholaides reminded us about ways of securing our Rails app.  Stuff we should all know, but I know I left the talk thinking about some of the tests I am going to write this week to test for holes in my apps.

Neeraj Singh pointed out some of the “good” and “bad” magic of ActiveRecord.  His talk made me want to rush home and play around with different “features” of ActiveRecord that we take for granted work a certain way.  Understanding how they really work can save you a lot of pain.

Dan McClain had some really awesome ways to let your app take advantage of the advanced datatypes in PostgreSQL.  Dan obviously knows a ton about the internals of PostgreSQL, but he made things very clear and easy to use.  Another talk that makes me want to experiment and grow as a developer.

Matt Aimonetti talked about “good” code and “bad” code.  I was psyched that I got a question in that got kicked around by Matt, Sandy Metz, and Katrina Owen in the round-table discussion.

I wish I had more than 140 characters to ask a fairly nuanced question about what is the right amount of testing for a Rails app.  Fortunately I got a chance to catch up with Matt just before the conference ended to explore some ideas.  I love how approachable people are in this community.

Things to Consider

There were a lot of local developers at the conference, which was really nice to see.  I know a lot of the companies and developers from helping out at Boston Ruby.  One disappointing trend I saw was people sticking with their co-workers.  Sure it gives us a common understanding that we can take back to the office, and we don’t need to reach outside our comfort bubble and engage people we don’t know.  But that’s the best part of a conference.  Meet new people, learn what they are passionate about, share your experience.

Along those same lines I wish there was a little bit more time between talks.  It’s a balance between getting as much great content as possible but also having a chance to talk to other devs, or dare I say it, approach a speaker and say hello.  I really enjoyed talking to Matt Aimonetti, Neeraj Singh, and Mike Desjardin about their talks.  The short time between talks also made for some rushed moments when a speaker talk inevitably ran long.

Finishing Where I Started

Thank you Brian, Johnny, and Sean.  You guys kept things flowing and from where I was sitting it looked like everything went off smoothly.  I am sure there was furious activity behind the scenes, but it looked like a well oiled machine.

And thank you volunteers.  Working the registration table, arranging sponsors, sending out emails, and coordinating the speakers and attendees is a mostly thankless job, but let me say this.  Thanks 🙂

So Ends The Season of Ruby

After a few false starts trying to get started with Ruby, I made a commitment this year to dive in with both feet and really learn it.  I decided on the notion of a “season” to dedicate to getting started with Ruby, and I think my initial dive has come to an end.  When are you ever done learning about a language or a technology, probably never?  And I am no more done learning about Ruby than I am done learning about C#, Java, Python, Perl, Javascript, or any other language.  Well, maybe Perl (ha, ha, ha).

So my introduction to Ruby and Ruby on Rails has not disappointed.  As expected, the community is vibrant and on the whole focused on real quality and craftsmanship.  There is no shortage of great resources out there to help a developer come up to speed on Ruby and Ruby on Rails.  And in that spirit, I wanted to take a snapshot on what I have learned, what resources I have found helpful, and where I might focus in the future.

Learn Ruby First

It is surprising easy to get up and running in Rails without really knowing much Ruby, just follow the wealth of examples and tutorials that are already out there.  I would argue strongly against that approach though.  Ruby has some really great features, especially if you are new to dynamic languages.  There is a an expressive syntax, great features like blocks and iterators, and incredibly rich set of standard libraries and 3rd party gems that allow you to build on.

Here are some of the resources I used to get up to speed with Ruby

Ruby Koans – Well structured introduction to the various features of Ruby.  A great intro to the language that you can bang through pretty quickly and refer back to when questions arise.  I have a lot of experience with Test Driven Development, but if you are new to TDD this will also get you thinking about TDD and how to write tests for your code.

The Pickaxe Book – Great resource on features of the Ruby language

The Ruby Way – Extensive resource for ways to solve several common programming tasks using Ruby.  This is also a great early introduction to writing in a Ruby-esque style, which was really helpful for me coming from C#. is another good reference for features about Ruby, especially the core API and standard library.

Moving on To Ruby On Rails

There is just an incredible wealth of resources to getting started with Ruby on Rails.

I spent a lot of time on Michael Hartl’s Ruby on Rails Tutorial.  I loved the focus on TDD and good developer practices.  Other added benefits to this tutorial is it is a gently introduction to git and even shows you how to push your code up to heroku.  I know this is a resource I will continue to come back to again and again.

As much as I loved the Hartl tutorial, I wish I had actually started with Rails for Zombies.  Rails for Zombies is put on by Code School, which has a lot of content available for purchase, but the Rails for Zombies course will give you a good introduction to Rails and it’s free.  You can blast through it pretty quickly, gives you a good sense of the basics, and it really sets the table for a deeper dive into Rails.  I actually did this after spending a lot of time with the Hartl tutorial, but doing Rails for Zombies provided a lot of “a ha” moments as I went through it.

RailsCasts has a ton of great content, both free and by subscription and is just a fantastic resource.  The screencasts are typically anywhere between 5 and 15 minutes and cover a huge range of topics.

I can’t get enough of the Ruby Rogues podcast.  These guys do a fantastic job and have great chemistry.  I am shocked that they can do all of this every week, and it has made my commute a lot more educational and enjoyable.  They have some great guests and even for a newb I find the content informative.  Some stuff goes past me, but I usually go to the website afterwards and follow up on the links for the list of topics discussed on each episode.

Ruby 5 is another great podcast.  It serves a different purpose than Ruby Rogues.  Ruby 5 is more of a news oriented feed of what’s happening in the Ruby community, what gems have been released, what books have come out, etc.

Other great resources for learning about Rails are the Rails Guides and Rails ApiDock.

Get Involved in the Local Community

I am fortunate that in Boston there are a lot of resources for meeting and learning from other people in the community.

Boston Ruby puts on some great talks each month and also does hackfests a couple times a month.  I have been to a few talks, but really need to get to the hackfests. They also have a very active mailing list that is a great resource for technical issues.

The Boston Ruby on Rails group meets more sporadically, but seems like a great group.  I went there for a series of lightning talks just before starting the Season of Ruby and there was a spirited Q&A after each of the talks.  I am sure that helped motivate me.

I also went to a few workshops put on by thoughtbot that I got a lot out of: the Web Design and Development Process, and Intermediate Ruby on Rails.

Where to Next

The simple answer is just write more code because that is the best way I know to improve.  There is still sooooooo much to learn.

The Non-Linear Nature of Learning

Learning is a funny thing, rarely does our knowledge progress in a smooth, linear fashion.  I have been spending some of my copious free time learning Ruby and Rails and in that time I have experienced various moments of joy, frustration, utter confusion, and total clarity.  It got me to thinking about the way we learn.

Inspired by Jessica Hagy’s great work at Indexed I came up with this diagram.

I experienced a brief, fleeting moment of Ruby hubris (Rubris?) a few weeks back and implied I was starting to “get it”, even invoking the good name of Ralph Kramden.  Well the Rails gods rightfully smited  me for my lack of a deep understanding of Rail’s Active Record Associations.

For my penance, I have started to take a look at HacketyHack and hope to soon contribute some lessons or help out however I can.  If anyone knows of any other resources for teaching kids to code, I’d be interested in helping out.

Needless to say I’ll also be spending some time trying to grok Active Record Associations as well.

Still having a blast on this journey.

Season of Ruby – Iteration 4 Retrospective

Iteration 4? Wait, shouldn’t I be on Iteration 5?  Yes, but as expected work reared its ugly head and the Season of Ruby got pushed to the back of the line.

I am now through Chapter 8 of the Ruby on Rails Tutorial.  I wish I had tracked the actual time spent on the tutorial, that would have been useful information for anyone wishing to follow the same roadmap.  I would estimate I have spent around 14-16 hours through the first 8 chapters.

What Went Well

  • In the interest of trying to get as much as possible, I am resisting the urge to cut-and-paste from the tutorial.  You learn a lot from mistakes, big and small, so there is a lesson to be learned when you type “name” or “@name” when what you really needed to type “:name”.
  • I still think one of the strengths of this tutorial is the focus on TDD.  As I have started to get more comfortable with the environment, I have also been trying to implement solutions on my own after writing the tests from the tutorial.  That makes me feel like I am starting to get more of a lay of the land.
  • Used the FactoryGirl gem to simulate model objects for testing.
  • Got my shiny new MacBook Pro and have switched all my Ruby and Rails development from Windows.  It was really cool once the environment was set up to grab the repo of github and pick up right where I left off.  BTW, I used the thoughtbot laptop project to get my system all set up for Rails development.  Went pretty smoothly.

What Can Be Improved On

  • I feel a little like how I felt during the Ruby Koans, that I am gaining a false sense of knowledge by following the tutorial.  It has been really helpful to get me moving forward with Rails, but you are still following a well-defined roadmap.
  • I want to finish the tutorial because I think there are several more lessons to learn and it will be a great reference to look back on, but I am anxious to start from a clean sheet of paper and make a ton of mistakes.  That is when the real learning will happen.
  • I have been pretty good about not doing a lot of cut-and-paste from the tutorial, but at times it is hard.  Just need to keep forcing myself to resist doing that.
What Am I Going To Do To Improve
The most learning has come in cases where I have tried to implement my own solutions after using the tests as provided from the tutorial.  From this point on, that will be the approach I will use.  Then when I have a passing test I can look at the tutorial and compare my solution against the tutorial solution and take that as a refactoring exercise.  It may take longer, but it will pay dividends down the line.

Iteration 5 Stories/Tasks

Chapters 9 and 10 of the Ruby on Rails Tutorial, implementing my own solutions first after using the tutorial tests to get to “red”.

Halftime Review of Michael Hartl’s Ruby on Rails Tutorial

I am a newcomer to Ruby and Ruby on Rails, so when I wanted to get started with Rails I looked around quite a bit for a good starting point.  I finally settled on Michael Hartl’s Ruby on Rails Tutorial.  I am about halfway through with the tutorial, and I am really pleased so far.  This is a great tutorial for a lot of reasons, but the aside from just teaching Rails, he is also teaching good development practices such as:

  • How to use git effectively.  The tutorial starts out with git basics and then quickly moves on to integration with github, working on branches when adding new features, and merging changes back into the master.
  • Focus on testing.  We start out with RSpec writing unit tests, but then also add in integration tests.  He also follows a TDD approach for a lot of the tutorial where the tests come before the code, a practice that I believe strongly in.
  • Stresses good developer practices like running your tests before and after merging a branch.  Sure the merge probably went fine, but be a good citizen and test it before you push it up to github.
  • Refactoring your code to reduce duplication and make it more readable and maintainable.
  • Shows how to deploy your code up to heroku
  • Introduces real world work practices like sketches and wireframes.
The focus on testing, refactoring, and general good developer practices is important to me.  These are practices that I have been using for a long time, but it is great to see them so much a part of Ruby on Rails.  Just seeing that standard project hierarchy includes a place for tests tells you it is ingrained in Rails.  I really loved this quote from the tutorial

If you ask five Rails developers how to test any given piece of code, you’ll get about fifteen different answers—but they’ll all agree that you should definitely be writing tests

As far as the Rails side of the tutorial goes, I think after my initial environment snafu (that’s all on me), things have been going great.  I am starting to see more of how Rails implements MVC.  MVC is obviously not a new concept, it’s been around for a while, but each framework and environment uses it differently.  I also really enjoy the ordered structure of a rails project and can see what an advantage it is to have this kind of common project structure.  I know ASP.NET MVC also tries to use a standard project hierarchy, but rails felt a little cleaner and more intuitive.

After some simple applications to get your feet wet and make sure your environment is good to go, the tutorial uses a micro-blogging application to slowly walk through the different capabilities in rails.  The tutorial also explains some of the “magic” that goes on under the covers that Rails provides for you.  This has encouraged me to route around (pun intended, thanks) to understand more of the magic.  Aside from routing, we have also hit a bit on database integration and migrations, some CSS, and partials.

One thing this tutorial will not teach you is a lot of Ruby, and the author is quite clear about that.  He provides some good references for learning more Ruby, but the focus here is on Rails, and he keeps the amount of Ruby necessary to a minimum.

I am about halfway through and am hoping to finish up in the next 2 weeks.  It is a little slow going because as I learn I often go off to investigate different aspects of what I am learning.  Finishing the tutorial will not be the end of the journey, but it certainly has helped get it going in a good direction.  I recommend it highly to anyone interested in getting started with Ruby on Rails.

Season of Ruby – A Bad Day Of Fishing

I have been really excited to get going with Michael Hartl’s Ruby on Rails Tutorial.  Skimming through the table of contents and the introduction, I liked that he makes testing such a focal point of the tutorial.  I also liked the Comments for Various Readers section.  I fit into the “Experienced programmers new to web development” camp, and after reading the introduction I knew  that this would be a great tutorial for me.

The first section was well laid out, and focused on getting your environment set up.  It also touched on using git and github which is starting to feel like old hat for me, but then it ended with deploying the sample app to heroku which was a new thing for me.  As someone experienced in software development, but new to web development, it was great to have the heroku deployment so well explained and easy to do.  I was feeling quite full of myself.

Then came the 2nd chapter…

Someone once said “A bad day fishing is better than a good day at work”.  Oh yeah, tell that to Captain Quint, he looks like he is having a pretty bad day fishing.

A Bad Day Of Fishing

Now you could argue that he’s actually just having a good day at work, since technically, as a fisherman, he is at work.  But I digress. Up to this point my Ruby experience has been all pie and ice cream, but today was a bad day of fishing with Ruby.

The author goes to great length to explain that the tutorial uses an older more stable combination of Rails/Ruby versions and that is what you should install.  But I am sooooooo much smarter than that and besides, I want to use the newest stuff.  To say the least, I ran into a lot of problems with getting the right combinations of Ruby, Rails, sqlite, etc, etc working.  I learned a lot about gems and bundler along the way.  I think things were further complicated by running on a Windows box as well.

After a lot of time fighting my environment, I realized I was fighting the wrong battle and the smart thing to do was to get the environment set up as the author intended to be able to get the most out of the tutorial.  Once I made that decision I was back on the happy path and am looking forward to moving on to more in-depth parts of the tutorial.  I don’t feel like it was a wasted experience, because I did learn quite a bit digging around.  I imagine this can be a significant issue for Rails projects, especially as new versions of Rails, Ruby, or different gems roll out and that the correct dependencies need to be addressed.  It reminded me a lot about the “DLL Hell” days of Windows before .NET.

The take-away is if you decide to do this tutorial follow the author’s advice and set up the environment as specified.  The lessons to be learned are more to the core of Rails and running the latest version of Rails or the application’s dependencies is not important.  And now that I am on the right track I am looking forward to moving on to more advanced sections of the tutorial.

Season of Ruby – Iteration 1 Restrospective

Same 3 questions that I laid out in the last retrospective post.

What Went Well

  • Broke through the “no code” barrier – I was learning a lot with with the Ruby Koans, but they also gave a false sense of knowledge.  Doing the String Calculator Kata got me writing my own code, posting it to github, and developing something of a “new” comfort zone.  I was definitely feeling somewhat uncomfortable as I was struggling to do things that I could do instantly in my familiar .NET surroundings, like project setup, working with version control, etc, so this was a good hurdle to clear.
  • Pushed code to github – OK, so it wasn’t a lot of code, but same idea: break through a barrier.  It also re-familiarized me with git which I had used a little over a year ago.

What Can Be Improved On

  • Not writing Ruby code in the Ruby style – Or maybe I am and just don’t know it.  Regardless, I still feel very much like a .NET developer writing Ruby code.  Bottom line, start to investigate and use Ruby as it is intended.  That means reading and writing more Ruby code.
What Am I Going To Do To Improve Things

Writing code will continue to be the main focus of the iteration,  but I also need to be focusing on what makes Ruby special.  To do that I want to work with some open-source Ruby code that will hopefully point out good Ruby style and also point me towards implementations or Ruby features that I have not seen yet.

I got some books from the library that I also hope will help educate me on elements of the Ruby language, style, and best practices.  I will fill in some non-programming time with going through the books for tips.

Iteration 2 Stories
The theme for this iteration is fundamentals.  I want to continue writing code and exploring features of Ruby, especially OO best practices as well as how Ruby implements blocks and iterators.  Building a strong base of fundamentals will position me to start doing some Ruby on Rails work in subsequent iterations.
Here are the stories for this iteration
  • As a .NET developer learning Ruby, I want to build a strong fundamental base of OO techniques with Ruby so that I can move onto more substantive uses of Ruby such as a Ruby on Rails application.  A 2-hour, time-boxed exercise of Conway’s Game of Life will provide an opportunity to get more experience using classes in Ruby.  Implementation will be stored on github exercises’about_methods’
  • As a .NET developer learning Ruby, I want to learn good Ruby style so that I can contribute to an open source project in the near-term future.  One way to learn style is to work with someone else’s code, so I will fork a repository on github and look at the style used and compare it against the style that I have been using for my development.  I want a project that is a “pure Ruby” project as opposed to Ruby on Rails to keep the scope manageable.  Since I was recently at thoughtbot for a seminar, I found a small project on github, Cocaine, that seems to fit the bill.  This will be a 1 hour, time-boxed, exercise.
  • Continue with the Ruby Koans to get more practice and understanding of blocks and iterators
    • require ‘about_exceptions’
    • require ‘about_triangle_project_2’
    • require ‘about_iteration’
    • require ‘about_blocks’

Season of Ruby – The String Calculator Kata and GitHub

Last iteration I realized that I needed to start writing some code, so the big story for this iteration was to do Roy Osherove’s String Calculator Kata and also to push the code up to github. Mission accomplished! But unlike ‘W’ standing on the aircraft carrier, I know there is a lot more work to do.

I used git a little bit a few years ago, and initially it was a painful adjustment because all my past experience was with centralized repositories like Subversion, Team Foundation, and CVS. Distributed repositories were a paradigm shift, but after some getting used to it really started to grow on
me. I loved home easy it was to create branches and that developers could work on different features in isolation before bringing their code back into the “trunk”. So it was great to get some code up on github, using both the RubyMine integration and plain old git command line tools. I need to spend a little time refamiliarizing myself with the terminology and workflow, but it was a great start.

As far as the kata goes I feel similarly. Did everything turn out exactly the way I wanted? No, but it is a kata. You do it, you learn something, you take those lessons forward, and you move on. Maybe I will do it again in a few weeks and see how the outcome is different. It served it’s purpose in getting me out of my comfort zone and writing code in a new language. It also got me asking new questions and places to take the journey. Some of the things that I wondered about as I was doing the kata

  • Does Ruby have the philosophy that there is one “right and obvious” way to do things, ala Python, or is it more Perl-like in that there are a many ways that are acceptable and it is a developer choice. At least according to this page it seems to borrow from Perl in that there is more than one way to do it.
  • How do private and protected variables/methods work in Ruby?  Are they often used or are there other patterns that are applied?  I remembered with Python that the notion of “private” was downplayed, at least with what I saw. I am not a Python expert so I may be mis-representing here.
  • Are instance variables used much?  In one of my refactorings I noticed that I was passing the same argument to a lot of methods, and decided to keep it in an instance variable. Was that Ruby-esque? Was it habits from .NET creeping in?  Was it the “best” solution

I don’t know the “Ruby Way” yet, so these questions are all the more reasons to start looking at OPC (other people’s code). So it is probably time to fork a Ruby open source project and start playing around with it.

I want to make sure I keep writing code too, so I think I will take a time-boxed stab at Conway’s Game of Life. I had a lot of fun with that at the Global Day of Code Retreat. I want to time-box it because it is something that I could spend a lot of time on, depending on how far I want to take it, and I am not looking for a complete solution but to exlore some different ideas in code. Maybe it’s time to start thinking about bring Rails into the mix too.

All these ideas make me think I should be keeping a formal backlog and continuing with the notion of treating this journey as an Agile project. I use a tool called Rally at work, maybe I’ll use that or investigate another tool. Any ideas or recommendations from the blogosphere?

Season of Ruby – Iteration Zero Retrospective

Keeping in the Agile spirit, I did a retrospective for Iteration Zero of my Season of Ruby.  When I conduct a retrospective I cover 3 areas:

  1. What did we do well
  2. What can we improve on
  3. What are we going to focus on in the next iteration to improve the process or the product

I am a team of 1 on this journey, so “we” is me.

What Went Well

  • Digging the Ruby KoansI’m happy that I am not just blowing through them to get to the next subject, but asking questions when something doesn’t make sense or surprises me.  I also find myself adding additional tests to experiment with behaviors
  • Love playing around in the IRB  –  This also has a lot to do with experimenting and following where my curiosity takes me.
  • Got a Ruby environment set – OK, so it is not the shiny new Mac I wanted, but RubyMine on my Windows laptop has been a very low-friction experience.  The Mac will come.  I have a birthday coming up and maybe I will be good to me.

What Can Be Improved On

  • Not writing enough code – Although I am learning with the Ruby Koans, I am not writing enough code.
  • Making really good progress, but need to dedicate more time – I’m happy with where I am, but the time goes by quickly.  May need to dedicate just a little more time on a weekly basis.
  • Haven’t done anything with github yet – One of the goals was to set up a github account.  Technically I have satisfied that criteria because I have an account…an empty account.  That needs to change

What Am I Going To Do To Improve Things

As a rule, I usually only like to pick one thing to improve on, especially in a short iteration, but since these two things go so well together:

  • Do the String kata in Ruby – It’s a pretty straightforward problem, one that I have done in C# and C++, and this will get me actually writing code
  • Put the String kata in github, committing as new functionality is added.
Iteration 1 Stories
  • Continue with the Ruby Koans, doing these exercises
    • ‘about_methods’
    • ‘about_constants’
    • ‘about_control_statements’
    • ‘about_true_and_false’
    • ‘about_triangle_project’
    • ‘about_exceptions’
  • Do the String kata in Ruby in a github repo