Daily Refactor #52: Remove Middle Man Kanban#find

The Refactoring

Now that everything has been refactored out of Kanban#find, there really is no use for it. All that it does is to wrap the constructor so it’s now useless code.

Before

1
2
3
4
5
6
# app/models/kanban.rb
class Kanban
  def self.find
    Kanban.new
  end
end

After

1
2
3
4
# app/models/kanban.rb
class Kanban
  # ...
end

Review

After every refactoring session you will have some useless code left over. Sometimes it’s to keep a public API stable, sometimes it’s a simple delegate, and sometimes (like now) it’s just garbage that should be thrown away. Whenever possible, throw it away. If you need it back, git will be there.

Reference commit

Share

  • Facebook
  • Twitter
  • HackerNews
  • Reddit
  • Tumblr
  • Delicious
  • Email
  • RSS

Related posts:

  1. Daily Refactor #50: Remove Middle Man methods in Kanban

About Eric Davis

I founded Little Stream Software where I provide Redmine and ChiliProject services to help projects teams. I also created an ebook, Redmine Tips, were I show you how to become more productive using Redmine. I am also the author of Refactoring Redmine, where I go about refactoring Rails using Redmine as an example.

, , ,

Chirk HR     Reuse your existing job applicants »
WP Socializer Aakash Web