Re: Routing and controller arguments in K3

Bharat Mediratta <[email protected]> Mon, 15 Apr 2013 15:41:35 -0700
Newsgroups gmane.comp.web.gallery.devel
Message-ID <CAESa+_k9Df4-_VDfLsLcDNmV=hZj7vDwjsmdD6eAqKKgkCh2qA@mail.gmail.com>
--===============3989643657263606730==
Content-Type: multipart/alternative; boundary=047d7bea2e34f9b41404da6df691

--047d7bea2e34f9b41404da6df691
Content-Type: text/plain; charset=ISO-8859-1

> Here's take two.  No arguments means give full array; one argument means
> required; two arguments means not required with default value specified.
>

In a hurry so I'll keep this short...

As APIs go, I'm not thrilled about varying the semantics based on the
number of arguments to the function.  It feels a little overloaded to me.
 Is there any precedent for this in Kohana?  I can't find it.

I think I'd prefer

  function args();               // return all args
  function arg($key, $default);  // return value with default if it's
missing
  function arg_required($key);   // return value or throw exception

Then it's very obvious in the controller code what's required and what
isn't.  A 404 isn't really right either - I think we should be throwing a
400 Bad Request instead in these cases.

--047d7bea2e34f9b41404da6df691
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><div class=3D"gmail_quote">=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div><div class=3D"gmail_quote"><div>Here&#3=
9;s take two. =A0No arguments means give full array; one argument means req=
uired; two arguments means not required with default value specified.</div>

<div></div></div></div></blockquote></div><br></div><div class=3D"gmail_ext=
ra" style>In a hurry so I&#39;ll keep this short...=A0</div><div class=3D"g=
mail_extra" style><br></div><div class=3D"gmail_extra" style>As APIs go, I&=
#39;m not thrilled about varying the semantics based on the number of argum=
ents to the function. =A0It feels a little overloaded to me. =A0Is there an=
y precedent for this in Kohana? =A0I can&#39;t find it.</div>

<div class=3D"gmail_extra" style><br></div><div class=3D"gmail_extra" style=
>I think I&#39;d prefer</div><div class=3D"gmail_extra" style><br></div><di=
v class=3D"gmail_extra" style><font face=3D"courier new, monospace">=A0 fun=
ction args(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 // return all args</font></div>

<div class=3D"gmail_extra" style><font face=3D"courier new, monospace">=A0 =
function arg($key, $default); =A0// return value with default if it&#39;s m=
issing</font></div><div class=3D"gmail_extra" style><font face=3D"courier n=
ew, monospace">=A0 function arg_required($key); =A0 // return value or thro=
w exception</font></div>

<div class=3D"gmail_extra" style><br></div><div class=3D"gmail_extra" style=
>Then it&#39;s very obvious in the controller code what&#39;s required and =
what isn&#39;t. =A0A 404 isn&#39;t really right either - I think we should =
be throwing a 400 Bad Request instead in these cases.</div>

</div>

--047d7bea2e34f9b41404da6df691--


--===============3989643657263606730==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
--===============3989643657263606730==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]
--===============3989643657263606730==--