]
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
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
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'
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
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
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
> 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!
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
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
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
10 matches
Mail list logo