1

I might have the same method name across different and disparate objects:

Frame.hide = function() {
//
}
Dialog.hide = function() {
//
}
Treasure.hide = function() {
//
}

Is it good to keep method names across the application unique, such as:

Frame.hideFrame = function() {
//
}

Dialog.hideDialog = function() {
//
}

The best efforts of an IDE such as Webstorm, can't differentiate between the 3 hide() methods in the top snippet. As our application is growing bigger and bigger (we are at around 80 classes now), it is becoming almost impossible to navigate around code sometimes because method names are the same, and refactoring becomes downright dangerous.

4

1 回答 1

1

嗯,这真的是一个品味问题。我个人不喜欢在函数中重复对象名称。所以我赞成:

Frame.hide = function() {}
Frame.show = function() {}
Frame.validate = function() {}

超过:

Frame.hideFrame = function() {}
Frame.showFrame = function() {}
Frame.validateFrame = function() {}

您的 IDE 绝不应该强迫您做一些可能不是更可取的事情,在这种情况下,您可能想要搜索另一个 IDE(Netbeans?)

于 2013-03-28T09:20:10.400 回答