On Tue, Mar 22, 2011 at 1:15 PM, Scott Sauyet <[email protected]> wrote:
> npup wrote:
>> I wrote a little utility to help out with checking status of objects.
>> More specifically, checking their conformance with a "signature" that
>> you provide along with the check.
>
> As I responded in the blog comments, I'm mixed about this.  I really
> like the idea of being able to encapsulate this sort of focused type-
> checking where I can worry about only those parts of the interface
> that interest me.  And being able to check values as well is very
> useful.
>
> But I'm not thrilled with the API.  The first thing that concerns me
> is the static call to Acts.As.info() which significantly constrains
> how I could choose to use it: if I want to store the results of a
> call, I have to make a call to .info before making another call to the
> test method.  There's something wrong with that.  My first thought is
> to reverse the sense of the call, so that false means that there is no
> mismatch and a results object details the issues found. But I can't
> think of a good name for that function, which makes me suspect that
> it's not as intuitive an abstraction as "ActsAs".  Besides, it's just
> so negative!  :-)
>

Just a minimal name suggestion, could "reflect" work instead of "ActsAs" ?

Hope I have correctly interpreted the sense/intent the name must give :)

--
Diego


> I also feel that the string types are a little overloaded, but I don't
> have a good alternative syntax.
>
> And I'd love to see some sort of nesting as well.  I don't have a
> clear sense, but something like the following might do:
>
>    var mailableSignature = {
>        // or perhaps type: "nonEmptyString"
>        name: {type: "string", constraints: {nonEmpty: true}}
>        address: {type: "object", signature: {
>            city: {type: "string", constraints: {nonEmpty: true}},
>            postalCode: {type: "string", constraints: {
>                nonEmpty: true, minLength: 5, maxLength: 9
>            }} //, ...
>        }
>    }
>
> One other suggestion would be that this misses an excellent
> opportunity to do a little currying:
>
>    var isAMonkeysUncle = Acts.As(monkeySignature);
>    // ...
>    if (isAMonkeysUncle(orangutan1)) {
>      // do Ape stuff here
>    }
>
> Finally, I found the unit tests less than enlightening.  Whenever I
> can, I look to unit tests to guide me in the usage of the API, but the
> test code at first reading does not make it clear how to use Acts.As.
>
> This perhaps sounded overly negative.  My main reaction is that this
> is a good idea, and a reasonable stab at a first implementation, but
> there is significant room for improvement.  Thanks for sharing it.
>
>  -- Scott
>
> --
> 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]
>

-- 
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