Hi, Rubyists!

Whenever I try to make a quick solution program,
I stop for a moment to think which approach I should take.

Let's say that you want to make a puzzle-solver (like Sudoku-solver)
and it's made up of one 'solve' method and several helper methods.

Which is your preferred way among the following?
And why?

[1]

def solve_sudoku problem
...
end

def helper1 args
...
end

def helper2 args
...
end

puts solve_sudoku "15000..00358"


[2]

class Sudoku

	def initialize problem
	...
	end

private

	def helper1
	...
	end

	def helper2
	...
	end
end

sudoku = Sudoku.new "15000..00358"
puts sudoku.solve


[3]

class Sudoku

	class << self
		def solve problem
		...
		end

	private
		def helper1
		...
		end

		def helper2
		...
		end
	end
end

puts Sudoku.solve "15000..00358"

[4]

module Sudoku

	class << self
		def solve problem
		...
		end

	private

		def helper1
		...
		end

		def helper2
		...
		end
	end
end


end

puts Sudoku.solve "15000..00358"




I'm a big fan of Object-orientation.
But if the object's life-span is as short as Solver.new(problem).solve,
I'm really hesitant to create an object when a simple method call will 
do.
Am I thinking of a worthless subjective thing?

Do you have any criteria about going for object/class/module/top-level 
methods?

Thanks.

Sam

-- 
Posted via http://www.ruby-forum.com/.