phase_9
Joined 14 years ago
Joined 14 years ago
I've been under the impression that using an artifact management tool such as Apache Ivy or Bower provides a more manageable and scalable solution, especially in projects with 20+ developers.
How does the solution proposed by the author compare? Does it compliment a managed artefact based solution?
For me; one of the "joys" of coding JavaScript is the expressiveness that comes with a dynamic languages; should you throw an ArgumentError when your function that expects a number is invoked with a String? Maybe - sure it can help catch problems early and effectively "stop-the-line" in your public API, but then again it will probably end up throwing the classic `TypeError: Object foo has no method 'bar'` for you anyway.
For "public" methods which form part of an API (especially when that API is going to be shared outside of my team) I try to make my functions handle failure early (before they delegate off to the "private" internal methods), even better if the public methods can repair any unexpected usage, ie:
function convertToHex(value) {
var result;
if (typeof value !== "number") {
result = convertToHex(parseInt(value, 10));
}
else {
result = "0x" + value.toString(16);
}
return result;
}
Also, with regards to default argument values, I've always felt the "native" JavaScript approach was fairly compact and descriptive when required: function doFoo(bar) {
bar = (bar !== undefined) ? bar : "default_value";
}
[0] http://en.wikipedia.org/wiki/Duck_typing[1] http://en.wikipedia.org/wiki/ActionScript#ActionScript_3.0
[2] http://blogs.msdn.com/b/ie/archive/2007/10/30/ecmascript-3-a...
Text only link for TFA: http://www.google.com/gwt/x?u=http%3A%2F%2Ftiamat.tsotech.co...
LLMs have made domain knowledge and reasoning "cheap"; it doesn't matter if the output is lower quality - look around you for countless examples of where cheap wins and "cheap" continues to improve.
Good luck out there; we will all need it.