6 karma · joined May 29, 2020 (6y ago) · 5 submissions
comment 6y ago · link · parent
2. This is the App-style notation. Notice how 'count' is used to indicate quantity not 'int'. You can see all app-style suffixes listed in the article.
3. I'm not the only one to come to these conclusions. From the Wikipedia article you provided:
* Steve McConnell: "... the basic idea of standardizing on terse, precise abbreviations continues to have value. Standardized prefixes allow you to check types accurately ..."
* Bjarne Stroustrup: "... a technique that can be useful in untyped languages ... [like JS]"
* Joel Spolsky: "... There's still a tremendous amount of value to Apps Hungarian, in that it increases collocation in code, which makes the code easier to read, write, debug and maintain, and, most importantly, it makes wrong code look wrong..."
4. this is a sensible, simple, and very light-weight approach to resolve a real problem that is especially pronounced with JS. It has been use for over a decade to manage code and teams and it works very well.
What naming convention do you instead suggest for JS?
comment 6y ago · link · parent
I researched this 4 years ago, and since then Typescript has added the `--checkJs` option, but it still you to run a separate process to run the check, which seems to certainly fall under the category of "... otherwise preprocessing the code". And that's an edge case. If you've got TS installed, your almost certainly transpiling. Type guards are typecasting, just renamed to make you sound smarter.
Flow requires a transpiler (https://flow.org/en/docs/install/) and advocates the use of background process. Again, this solidly fits the above premise.
These are enormously complex solution to a problem that can be resolved without transpiling by using 6 small functions and a sensible naming convention. Certainly there are many cases where that makes a lot of sense.
I've developed lots of mission-critical JS that is very widely distributed and there are no type errors despite not using Flow or TS.
comment 6y ago · link · parent
comment 6y ago · link · parent
I do not recommend JSDoc. Instead, typecasting has these advantages:
1. Precise self documenting 2. Much easier to maintain and less verbose (see 1) 3. Requires no external tooling outside of the typecast functions which are hundreds of times less complex than JSDoc checking environments like Closure 4. Adds valuable run-time capabilities that JSDoc does not
Sincerely, Mike