Hiring “Rock Stars” with the right life philosophy 0

Rocker I’m working in a team of very smart and talented people, but from time to time I feel like it’s very contra-productive. All the discussion about the way the software should be written or designed. It’s exhausting and demotivating! The reason I’m writing about it is not that I need to only get it out of my head and share, but also the believe that I know why is it happening and how to change it.

All the smart and successful guys like Joel Spolsky will tell you that you should always hire the best you can. One reason is that A players will always want to hire A players. To my experience it feels little a bit wrong. I had an opportunity to work with very smart people (I mean technically and logically smart) and I love the chalenge to work with them, but there’s something that’s missing. The missing part is the philosophy of life.

In a past few years I’ve been thinking about the fact that I’ve been working with excellent people around the world and also with some other people which wasn’t actually that skilled or experienced. It turned out that I tend to work better with people with the same philosophy of life. There were people that actually wasn’t that good at their work skills but the way they connected with me helped the whole team/project to be more productive and successful.

I think Jason Fried also mentioned this fact many times, but I didn’t see it for some reason and long time it was just about hiring A’s or “Rock Stars”. Now I know that hiring ONLY smart people isn’t the way to go. Very pity it took me so long to figure this out, but I understand it now.

My advice is: “Hire the best you can but make sure they fit to your life and philosophy of life.” The same advice goes with joining new team or company.

Note: Photo from stock.xchng

Bootstraping Chef Server/Client with Sprinkle 0

I like very much Chef tool for server configuration. I think it’s very good tool and every company doing web development should use it to bootstrap or configure their servers. But the sad truth is that before you can use Chef you need to prepare the machine with manual typing and configuration. And that’s what I don’t want to do. So I decided to change that by automating the Chef bootstrap with Sprinkle.

1) Download the code:

1
git clone git://github.com/lacomartincik/chef-bootstrap.git

2) Have ready your server or virtual machine
3) Create config file

1
cp config/config.yml.example config/config.yml

4) Set up the config with IP and user credentials

1
2
3
4
5
6
7
8
9
10
server:
  host: chef.server.local
  ip: 192.168.0.1
  user: deploy
  password: deploy

client:
  ip: 192.168.0.2
  user: deploy
  password: deploy

5) Run server/client bootstrap

1
./bin/chef-server
1
./bin/chef-client

Hope you find it useful. Any comments, recommendations always welcomed!

5 Mentors I admire and I follow 0

I read a lot and I listen to audio books whenever I’m not able to read. Because I’m doing this almost 8 years I think it would be nice if I share with you what are the people that influenced me and my life. These mentors are also my day to day food helping me to overcome my challenges (I tend to use word challenge instead of problem) and motivate me whenever I need to. I highly recommend to all of you to have a look at them and if you like them try to follow them.

Brian TracyBrian Tracy (www.briantracy.com)

You can read a lot about Brian on his own website where he’s presenting himself with very professional language but also with a lot of sales-kind-of paragraphs which I really don’t like much. For me Brian Tracy is one of the best when it comes to motivating people and explaining whatever is happening in your life and how to change it to better. His voice and the way he presents stuff is just awesome.

Audible.com offers a lot of audio books from Brian Tracy. I like very much the “Luck Factor”. For me it was eyes opening. Also I’m listening to him most of the days I’m walking to the office to keep me motivated.

Anthony RobbinsTony Robbins (tonyrobbinstraining.com, www.tonyrobbins.com)

Tony Robbins is very popular life coach and he also calls himself “the why guy“. I’m following his blog at tonyrobbinstraining.com where he shares his thoughts mostly in video format. I really like the way he explains WHY the life is the way it is and what we can do about it. Notice how often he use smashing his hands to each other or says “I”. :-) Full of win! One day I’m going to attend his seminar(s).


The Blog of Author Tim FerrissTim Ferriss (www.fourhourworkweek.com)

Life hacker, author, enterpreneur, dancer, experimenter with life style. If you didn’t read Tim’s book “The 4-hour Work Week” go and buy it and read it. Very practical book which helped me to understand how much outsourcing can help you in your life. I’ve already outsourced many things I would before reading this book maybe never considered. Tim is also very frequent blogger and video author so don’t hesitate to follow his blog and twitter.


kevin_roseKevin Rose (kevinrose.com)

He is the co-founder of Revision3, Pownce, WeFollow and the social-bookmarking website Digg. I really admire him because he’s very successful and shares his knowledge and wisdom. I really like video series called “Random” which he’s doing altogether with Tim Ferriss. I know that he’s also doing show called “Diggnation” but I’m not watching it.


Andrew WarnerAndrew Warner (mixergy.com)

I can’t miss one of the most active mentors on the web Andrew Warner founder of Mixergy.com collecting interviews of enterpreneurs and other successful people for all of us to learn from them. All the videos are great way how to learn from mistakes of others and find out how others are doing it. You should not miss any of these interviews!


Of course there are other mentors and successful people I’ve been following but these guys have been the most visible and helpful to me on my journey to understand life and it’s purpose.

Which are yours?

Replacing Ruby on Rails fixtures with Factories and Builders 1

In my current job we were facing a well known problem called Fixtures. The term Fixtures in context of Ruby On Rails framework is the default way how the testing data are prepared/created before the tests run.

Here’s the list of important reasons why Fixtures are pain:

  1. Hard to read (YAML format)
  2. Hard to define edge cases
  3. Almost impossible to modify after reaching certain size of fixtures

The only real reason for using fixtures which I can find is speed. So if you’re on small project or you really need to have tests running fast then the fixtures are good choice. But if you need to have easy to read tests with test data, possibility to easily modify them and having be able to define a lot of edge cases here’s one nice possible way to go called Design Patterns.

Factory patterns (http://en.wikipedia.org/wiki/Factory_pattern)
In these days people are already using Factory pattern as replacement for Fixtures and you can find plenty libraries to help you simplify the work:

At the end we decided to go for FactoryGirl because it’s widely used which means there’s a lot of people to help us with answering questions and fixing bugs.

Example of FactoryGirl:

1
2
3
4
5
6
7
8
9
Factory.define :invoice, :class => Invoice do |u|
  u.created_at 2.days.ago
  u.started_at 2.months.ago.beginning_of_month
  u.ended_at 2.months.ago.end_of_month
end

Factory.define :invoice_with_billing_cycle, :parent => :invoice do |u|
  u.association :billing_cycle, :factory => :billing_cycle_2_months_ago
end

Personally I also like very much Foundry by Jeremy McAnally. The only disadvantage is that it’s closely linked with Ruby On Rails named_scopes implementation.

Builder pattern (http://en.wikipedia.org/wiki/Builder_pattern)
This pattern isn’t yet widely used as Factory in Ruby On Rails community. I really don’t know why, but I didn’t find any article about using it so here we go.

I like to use this design pattern in situations when:

  • You need to create complex object structures (together with Factory)
  • You need to be flexible with creating many edge cases

The best thing about using Builder pattern is that you don’t need any library but just pure Ruby objects.

Example of Builder pattern in Ruby combined with Factory girl:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class InvoiceBuilder
 
  def initialize(invoice_factory, options = {})
    @invoice_factory = invoice_factory
    @options = options
    self
  end
 
  def with_line_items(line_items)
    @line_items = line_items
    self
  end
 
  def create
    invoice = Factory(@invoice_factory.to_sym, @options)
    @line_items.each do |li|
      li_factory, li_options = li
      invoice.line_items << Factory(li_factory.to_sym,
       li_options.merge(:invoice => invoice))
    end
    invoice
  end
 
end

The code above shows very flexible way of using Builder pattern to chain your criteria as you need them. You can than write something like this:

1
InvoiceBuilder.new(:invoice_with_billing_cycle).with_line_items([ item1, item2 ]).create

Interesting articles to read:

Things to consider:

  • Try to keep your tests and Factories simple
  • Keep your data very close to your tests
  • Create complex structures with Builder pattern

Thanks for reading. Let me know what you think in comments. Any kind of feedback appreciated!

Using Null Object pattern with Ruby on Rails 1

While back ago I’ve released plugin to implement Null Object Pattern. And I’ve decided to write about it. Mostly because people are not using it or don’t know it.

What it does?

Instead of using a null reference to convey absence of an object (for instance, a non-existent customer), one uses an object which implements the expected interface, but whose method body is empty. The advantage of this approach over a working default implementation is that a Null Object is very predictable and has no side effects.

Why should I use it?

  • You will not have to prevent your code from having null reference. For example you will not have to do this:
    1
      print post.user.nil? ? 'Null user' : post.user.name

    With Null Object pattern you write just print post.user.name and you’ll get default value for Null object defined for this attribute.

  • It’s very handy if you’re doing some kind of reporting that you don’t have to deal with null reference and you have object (in SQL row reference) instead.

To install the plugin

1
ruby script/plugin install git://github.com/lacomartincik/acts_as_nullobject.git

Let’s have a look how to use it
First you’ll need to define model to acts as null object:

1
2
3
class User < ActiveRecord::Base
  acts_as_nullobject :login => 'lacomartincik', :name => 'Ladislav Martincik'
end

Than whenever you call on User class method null_object you will get instance of NullUser class with default attributes defined in User:

1
2
>> User.null_object
=> NullUser...

Now if you define relationship between say Project and User like this:

1
2
3
class Project < ActiveRecord::Base
   belongs_to_with_nullobject :user
end

Than whenever you create new Project object with null reference to User you will get NullUser instance instead of nil:

1
2
3
>> p = Project.new
>> p.user
=> NullUser

The project is available as plugin on http://github.com/lacomartincik/acts_as_nullobject.

Enjoy! Any suggestions, bug reports and comments welcomed!

Update: I had to rename plugin name from acts-as-nullobject to acts_as_nullobject otherwise it’s not going to work in Rails!

Next Page »