Monday, November 21, 2011

SCNA 2011

SCNA 2011 better known as "Holy Crap, do I have a ton more to think about concerning my craft!"

From the terrific conversations while driving from/to Cleveland with Michael "Doc" Norton, Joe Fiorini, Randy Eppinger, Melissa Lewis & Zee Spencer to the fantastic talks given by all speakers as well as the hallway conversations with folks I haven't met before or I haven't seen in a while, SCNA was a blast.

Many of the talks were thought provoking and I hope to write a little something about some of them as well as follow up on posts that I'm sure will appear from some of my LeanDog compatriots.

Friday, July 29, 2011

Threaded/Recursive Objects in Rails 3.0.x & Mongoid 2.0.x

So I am building a useful internal app for work in Rails 3 (soon to be 3.1), Ruby 1.9.2 & MongoDB. For those of you that know me, it's a bit of stepping out of my comfort zone of experience with .NET. However, I'm really digging the power of the Ruby language and Rails environment so it's all good.


So with that said, I'm learning how to do some things with MongoDB & Mongoid that I had run into some trouble with. I'm planning to do a few posts coming up that will be just knowledge dumps and would hopefully be useful to some folks that may be running into the same problems as I did.


One of the things I wanted to do was provide the ability to have threaded comments in the system. Due to the schemaless design of MongoDB, this should be relatively easy. Some of you may have seen this gist then you have encountered the older way to handle this kind of situation where a Comment object would be able to be embedded within a Comment object.


Let's start with a plain Comment Mongoid document class in Ruby.
require 'mongoid'

class Comment
    include Mongoid::Document
    include Mongoid::Timestamps

    field :title, type: String
    field :body, type: String

    validates_presence_of :body
    
    attr_accessible :title, :body

end
Now, Mongoid 2.0.x now supports recursive models instead of using the syntax seen in the gist. This just requires one line to be added to the class:
recursively_embeds_many
Adding in this will now provide your Comment Mongoid model with two new methods: parent_comment & child_comments. These are dynamically created based on the name of your class (parent_# & child_#s) and they allow you to traverse the hierarchy.


The Comment model would now look something like:
require 'mongoid'

class Comment
    include Mongoid::Document
    include Mongoid::Timestamps

    field :title, type: String
    field :body, type: String

    #comment.parent_comment # Gets the parent.
    #comment.child_comments # Gets the children.

    recursively_embeds_many
    validates_presence_of :body
    
    attr_accessible :title, :body
end


That's it! Not so bad once I read the upgrade page that this was changed.

Wednesday, February 23, 2011

The Times They Are a-Changin'

So it's been a fairly crazy 4 years that I have been with The Firm That Shall Not Be Named(tm) as a Lead .NET Developer. I've been on a number of projects with a number of really great folks at the Cleveland, OH office.

I have grown a bit while at The Firm but my interests have grown and changed over the years. As the IT organization has reorganized a few times over my tenure, it became more apparent to me that I wanted more out of my career & to get more deeply involved in Agile practices & coaching while keeping my technical prowess up to snuff. I also have an interest in sharing my knowledge with others & collaborating in software development.

I'm proud to announce that I will be joining the LeanDog team as an Agile Coach & Developer. Depending on the need, I will be embedded in client development teams doing Agile coaching as well as being part of the overall effort for the client team to deliver quality testable software. I may also be involved in dev projects "On The Boat".

I'm really pumped and looking forward to being a part of a great team of really talented folks all united in our commitment to delivering quality software and value to our customers.