This group is the best thing that happen to the internet since
broadband!  You guys are awesome!  I definitely appreciate all
feedback and I am taking everything into consideration.  What I really
need to apply from this discussion is type checking, so that param1
can be an object or a string depending on how the user plans to use
the method.  For now, I am taking this approach.

function drawPoly(args)
{
     // Set up params
     args         = args || {};
     args.points  = args.points || DEFAULT_POINTS;
     args.options = args.points || DEFAULT_POLY_OPTIONS;
     args.foo     = args.foo || DEFAULT_FOO;

     // Function Flow
}

This seemed to be the general consensus of our discussion.  Thanks
again everyone!

> > I am developing a JS API for my employer and I constantly ask myself
> > how I should accept params into my methods.  So I figured I would ask
> > the professionals.
>
> > Here is my scenario:
> > 1.) I know a handful of basic methods that I need to implement right
> > now.
> > 2.) I do not know if functionality in these methods will expand in the
> > future
>
> > Example Method:
> > A.) function drawPolygon( points, polyOptions ) { ... }
> > B.) function drawPolygon( options ) { ... }
>
> > I feel that with option B I can expand functionality a lot easier than
> > with option A.  Does anyone have advice or common pitfalls when taking
> > approach B?  I appreciate any input.

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to