RE: [Rails-spinoffs] Extending Class.create() for casting objects

2006-07-31 Thread Hill, Greg
] Extending Class.create() for casting objects   That's why you won't hear the words "components" and "configurable" too often in the Rails community.    It's often much faster to write your own customized stuff instead of trying to configure a prefab 

Re: [Rails-spinoffs] Extending Class.create() for casting objects

2006-07-31 Thread Thomas Fuchs
That's why you won't hear the words "components" and "configurable" too often in the Rails community. It's often much faster to write your own customized stuff instead of trying to configure a prefab component-- because of the speed you can develop with a dynamic language. :)Embedding defensive tec

Re: [Rails-spinoffs] Extending Class.create() for casting objects

2006-07-31 Thread Ryan Gahl
However, when creating consumable components or APIs, it's always good to embed defensive techniques into your code because you may not know which anonymous application space is trying to do what with your stuff, and yes you can tell those 3rd parties to unit test unit test, but in the end you can'

Re: [Rails-spinoffs] Extending Class.create() for casting objects

2006-07-31 Thread Thomas Fuchs
Prototype is heavily based on ideas borrowed from Ruby (which has many similarities to JavaScript), and thus relies on the idea of DuckTyping. See http://wiki.rubygarden.org/Ruby/page/show/DuckTyping for some info about this. To address the issue of stuff-that-could-go-wrong-more-easily

Re: [Rails-spinoffs] Extending Class.create() for casting objects

2006-07-29 Thread Em Te
It seems to me that attempting to enforce types to catch programming errors misses a bit of the point of Javascript. I suppose it would make certain methods of debugging simpler at the cost of greater code complexity, but that benefit seems to be less than overwhelming to me. Perhaps it's relate

Re: [Rails-spinoffs] Extending Class.create() for casting objects

2006-07-28 Thread Jay Miller
It seems to me that attempting to enforce types to catch programming errors misses a bit of the point of _javascript_.  I suppose it would make certain methods of debugging simpler at the cost of greater code complexity, but that benefit seems to be less than overwhelming to me. Perhaps it's relate

RE: [Rails-spinoffs] Extending Class.create() for casting objects

2006-07-28 Thread Hill, Greg
> Yes, it is used to catch programming errors by introducing a little type > safety. How many times have you written this in your project: > > function showMenu(obj) { > if(obj instanceof MenuItem) { > obj.getNode().style.visibility = "visible"; > } else throw new Error("Invalid parameter!

RE: [Rails-spinoffs] Extending Class.create() for casting objects

2006-07-28 Thread Em Te
Yes, it is used to catch programming errors by introducing a little type safety. How many times have you written this in your project: function showMenu(obj) { if(obj instanceof MenuItem) { obj.getNode().style.visibility = "visible"; } else throw new Error("Invalid parameter!"); } Now you

Re: [Rails-spinoffs] Extending Class.create() for casting objects

2006-07-26 Thread Jay Miller
I have to admit to a hard time understanding a real-world use case for this.  It seems like any situation where the method would fail would be programmer error and need to be fixed, and any situation where it would succeed, it would be unneccessary. Is there something I'm missing here?On 7/26/06, E

[Rails-spinoffs] Extending Class.create() for casting objects

2006-07-25 Thread Em Te
I've been experimenting with extending Class.create() to do object casting as well as its usual object creation. The idea is to use syntax similar to performing object casts in C++. For example: int i = (int)3.141; Tree t = (Tree)obj; Casting can also be used to do type verification, which Jav