class Employee
attr_accessor :id, :salary, :birthday... # about 10 more attribures
def qualify_for_raise? ..... end
def qualify_for_promotion? ..... end
# 10 more instance method
end
class Review
def review(employee_array)
employee_array.map do |employee|
if employee.qualify_for_raise?
# ...
end
if employee.qualify_for_promotion?
# ...
end
# ...
end
end
end
Since I will create 50,000 Employee objects, would it be better to take all instance methods out of Employee class as each Employee object will have its own copy of instance methods? If that's true, I have design my classes like below, I much prefer declaring methods to operate on Employee data inside Employee class itself. Is there a way to find out size of Employee object with/without instance methods?
class Employee
att_accessor :id, :salary, :birthday... # about 10 more attribures
end
class Review
def review(employee_array)
employee_array.map do |employee|
if is_qualify_for_raise(employee)
# ...
end
if is_qualify_for_promotion(employee)
# ...
end
# ...
end
end
def is_qualify_for_raise(employee) ..... end
def is_qualify_for_promotion(employee) ..... end
# 10 more methods
end