ISOLATE YOUR PARAMETERS

I would like to state that this article was written from a novice and an enthusiast lens and all suggestions and corrections are welcome. Many programmers are used to providing arguments to functions or class object constructor like the one below.

**Javascript**
function sum(x,y)
{
  return x + y;
} 
**Ruby**
class User
    attr_reader :name, :age
    def initialize(name,age)
       @name = name
       @age = age    
   end
end

Let us answer couple of questions: what if we fail to pass or the user of our function fails to pass the arguments in the right order. what if we forgot to pass or user of our function forgot to pass the correct number of arguments.

Providing your arguments as an object(javascript), hash(ruby), dictionary(pyhton) or array(php) might save you from undesired situations. let us re-write those 2 codes above

  **javascript**
  function sum(args)
  {
   let x  = args['x'] || 0;
   let y = args['y'] || 0;
   return x  + y;
  }
  let args = { x: 4, y: 5 };
  sum(args);
  **Ruby**
  class User
      attr_reader :name, :age
    def initialize(args)
       @name = args['name'] || default_name
        @age = args['age']   || default_age
   end

   def default_name
     'name'
   end
   def default_age
     0
   end
 joe_doe =  { name => 'joe', age => 42  }
 User.new(joe_doe)