Archive for the ‘General’ Category

Shout Out To RailsConf!

Monday, June 7th, 2010

Well, it didn’t work out for me this year, but a few of my buddies from the FV.rb are over at RailsConf right now, having a good time I’m sure.  I’m sure that @milesforrest, @djbell, @krutten, and whomever else is there is having a blast right now.  You guys better bring back schwag, pictures, and good stories for next week’s meeting.  Also a thanks to the RubyMine guys over at JetBrains for throwing me a T-Shirt.  I’m not sure if they were giving them out to everyone, but they did say to send someone over, so I did.  Thanks guys!

Functional Vs. Object Oriented Programming In Ruby

Friday, June 4th, 2010

When I came to ruby I knew that in Ruby Everything Is An Object, but until I started writing “real” code, I didn’t realize that the Ruby world works that much better if your code is object oriented as well.

Case in point my simple Twitter to HTML program.  When I first wrote it, it was pretty much written from the point of view of where I was at, a old and functional programming Perl coder.

So what is the difference between the styles of functional programming and object oriented programming?  For me, this meant that I was basically writing a program with no classes defined with a top to bottom program flow.  There was a “main()” (if you are familiar with C programming) which basically ran a set of functions and then ended.

Ruby itself discourages you from doing this.  There isn’t (as far as I can tell) the concept of pre-defining functions, so you have to write functions that you use before you use them.  So if you have a line that calls “foo(x,y)” you have to make sure that you have foo() defined above that in the program.  and if foo() calls bar() then bar has to be defined above foo(), and so on.  Not fun if you want to make your source code readable and nicely laid out.

Once I let Ruby’s object oriented nature take over a bit though, and defined the functionality in a class, and then just created an instance of the class to do foo() and bar() operations, it didn’t matter in what order code was assigned in the file, because the entire class is parsed by the interpreter before anything is done to it*.

* I’m sure this isn’t 100% true from a compiler / systems design point of view, but for the end user that’s basically what it looks like.

So what else does this give you, or more specifically, force you to do? Well, lots or Rubyist type things.  This encourages you to…

  • create your programs in terms of data types (“this is a thing”)
  • group functionality together (“this thing does these operations”)
  • create objects that function together or off of each other (“this thing is a sub or superset of this other thing”)
  • ensure your methods play nicely (ie: method chaining)

As many have said before, you can write bad C code in any language, but I had to come to the realization that just because I was writing in Ruby didn’t mean that I didn’t have to change how I was programming to take the most advantage of it.

Not that every program needs to be “objectified”, that 10 liner to parse out some some text and insert it into a database probably doesn’t need to be split into 2 modules and get 100% code coverage, but then again, maybe you’ll re-use it again next week, or maybe it’ll turn into the central convert-everything utility program for your job, and if so, wouldn’t it be nice if it was OO and tested from the start, instead of having those “extra” bits of safety tacked on after it becomes apparent that it’s more than just a quick and dirty little hack?  (For me it’s happened way too often that I don’t realize this until way too late….) :)

Peepcode Hits Two Out Of The Park

Tuesday, June 1st, 2010

Browsing the twitters this morning I found a couple of high end posts from Peepcode that I thought deserved some attention (assuming everyone in my audience isn’t hitting their blog on a regular basis already that is):

  • First is the Live Blogging a Rails 3 Upgrade.  I think I saw one of these somewhere before, maybe on RailsCasts, but the closer Rails 3 gets the more you’re going to want to see these so you’ll be that much more ready to do the upgrade yourself.  Now this is a post from February I realize, so it’s a couple of months old, but still looks great and is still very relevant.  Well worth the 25 minutes to watch TopFunky do his thing.
  • Second on the list is an actual new post, entitled Am I The Only One To Use a Text Editor To Edit Files, listing out some requirements and what’s available for file navigation and searching in editors today.  In a twist ending that I’ll ruin for you here, the resulting list of features has morphed into a real application that works with a host of the favorite editors for the Mac.

Great stuff all around, both blog posts (as the Peepcode blog always are) look beautiful and are amazingly laid out with great graphics and typography.

Best Laid Plans

Friday, May 28th, 2010

So minimal posting this week cause I’ve been hit with the cold/flu/sinus-torture-from-hell :( I did get some design done on the two projects I’ve had rattling around in my head for the last few weeks and months.  Only problem was, when I really thought about it, they are both kinda silly and pointless.

  • My idea for a memory capture (ie: put in memories of your past) is, I realized, essentially a blog with a better way of adding by date (fuzzy dates).  Really, just a blog.  Do I want to end up re-writing wordpress or movable type again, poorly?
  • The ruby-idioms site that I spoke about a while ago appears to have been written already over at http://readmycode.org.  While I applaud the author for getting the site out in 24 hours, he also basically created what I wanted to.  Grrr…..

Now, that’s not to say that I don’t have passion for the projects, and definitely doesn’t mean I won’t still do them (nothing says you can’t create something if it exists already).  Shows the dangers of not committing and waiting, instead of getting stuff done NOW.

Guess it’s just a bummer to get to the realization that my fantastic ideas maybe aren’t that wonderful…. Bleah.

Anyway, keep on coding out there, got some ideas here for some hopefully interesting posts coming up next week as I get better and closer to upright!

Doing it Now

Monday, May 24th, 2010

It might sound like a bit of cliché from one of those high energy seminars where you’re encouraged to Take Control Of Your Life! and Actualize Now! or Create Your Own Reality!, more and more I’m finding that one of the best ways to get things done, programming wise, is just to [expletive] do it.

One of the big challenges I have myself is that I get mired down in details.  For example, I have this idea to do a Ruby Idioms site, and the setup seems pretty simple.  User login model, an Idiom model, thrown in something like acts_as_taggable-on or whatever’s hot right now, a bit of layout, some begging for real design from some helpful designer(s), a short beta with some real users to flesh out the bugs and fill in the database, and then release, iterate, release, iterate, done.

For a Rails project this isn’t overly complex, hell, an intermediate coder could probably hack that out (up to the design part) in an afternoon.

And yet a week after coming up with, and getting all excited by, the idea of doing it, I’ve only gotten as far as registering the domain.  What the hell is wrong with me!?  Heck, I started this post half a week ago and still haven’t posted it, or gotten around to doing anything more.

So why?

There are a few different reasons why people procrastinate.  I’d put them in a random order chosen out of my brain:

  • You’d have to finish if you start
  • Easier to sit on the couch and watch the new Blue Ray Alice in Wonderland
  • Too many other things to learn first

The last point is the big one for me, and for a few people I know too.  When I say “to learn” I don’t mean that in the “oh I have these awesome new technologies to get through” sort of way, but more in the “well, I can’t write a rails app until I learn rails, but I have to learn ruby first, and there’s all these libraries, and I hear that 1.9 is coming out soon, so maybe I’ll wait for that to be released, and I hear Rails 3.0 is almost out, so it makes no sense to learn Rails 2 now if the next version is only a couple of weeks or months down the road…”

I believe the seminars call this (among other things) the “whoah busy” syndrome.  With a scary task ahead of you, it’s really easy to end up bogging yourself down in the minutia of it all cause if you have to mow the lawn/do the dishes/clean the house/do the litter box/cook dinner/get lunch for tomorrow ready then it’s really easy to put off starting that new project…

That’s my issue anyway, I’m sure it’s not unique, but I don’t want to put any of my own issues on people out there.  I think if you look deep down in your own psyche you’ll figure out what it is that’s stopping you.

Ok, so in the time of reading this and a few seconds contemplation, you now have figured out what issues you have stopping you from getting your stuff done, so what now?

The most obvious is to just do it.  Seriously, close the browser, shut down your RSS reader and open up Vim/TextMate/EMACS/whatever and start coding.

Still reading? Stop, close the browser and get out and do whatever it is you need to do.  Think about that feeling you get when a project is done and how good it feels to tick something off your todo list (legitimately of course, not like this guy).  You’re a lot closer to that ticking off feeling after you start, not before right?

My best example of this from my own past was working with @milesforrest at an early FV.rb meeting and it was just the two of us, and we started into the typical geeking out, surfing reddit, etc.  I put my foot down and said “lets make something”.  We set up the site’s website onto heroku, put it up on github and worked on stuff.  It actually sucked… there’s nothing to show you the difference between having read a bunch of Rails books and blogs and actually coding it.  I did a lot of cursing that day, as all the stuff that should be just super easy turned out to be really friggin’ hard, or at least hard from a “I have no clue how to do this” point of view.

We persevered though, and worked on it and by the end of the night had  a lot better understanding of some of the Rails insides that now (months after this initial ordeal) are second nature and super simple to do.

Moral of the story?  Each journey begins with just one step, and each new web project begins with typing in “rails <projectname>”….

Related To Performance…. [link to comic]

Monday, May 17th, 2010

Ok, not really worthy of a full post, but I couldn’t help but to LOL at the latest comic on Not Invented Here.  Took me a couple of seconds to get it :)  If you didn’t remember NIH from my list of Programming Related Cartoons, it’s time to subscribe to their RSS feed right now!