5 ms·
I really dislike automatic conversion between cases. There does not seem to be any established convention of how to handle uppercase acronyms across all differe
by SahAssar 2y ago
I really dislike automatic conversion between cases. There does not seem to be any established convention of how to handle uppercase acronyms across all different ecosystems that use camelCase, so
```
document.getElementById('example-div').dataset.myID == "1"
```
becomes:
```
<div id="example-div" data-my-i-d="1"></div>
```
- floydnoel 2y agojust treat acronyms as a word, e.g. `myId` instead of `myID`. That's been the standard practice in JavaScript as long as I've been using it at least.
- jaffathecake 2y agoIt is for id, but not for acronyms. Eg `innerHTML`. https://w3ctag.github.io/design-principles/#casing-rules https://w3ctag.github.io/design-principles/#casing-rules
- kevincox 2y agoAnd that isn't even getting to XMLHttpRequest.
- jaffathecake 2y agoHaha, yeah - Isn't limited to XML - Isn't limited to HTTP - The returned object is also the response Beautifully named.
- bandie91 2y agojust as well-thought-through as other parts of the web ecosystem, starting at the scripting language designed in a mere week.
- schindlabua 2y agoI'm having to touch Spring occasionally nowadays and wow it is a hodgepodge. It really is the backend equivalent of jQuery.
- ruszki 2y agoCan you provide some example why it’s a hodgepodge?
- schindlabua 2y agoReact for example has a solid mathematical foundation and that's why it provides really good, clean abstractions. Spring is just a bunch of annotations and if you haven't done it for half of your life it really isn't clear why I have to write an empty! class that has 6 annotations on it, just to get the plumbing right for configuration. Smells like what I'm doing there should just be a function instead but maybe that's also partly Java being Java. Yes it's very mature etc but at the end of the day it's just a collection of stuff that evolved over time. It's a framework written by developers, not mathematicians; a BeanPropertyRowMapper is likely something that happened on accident, react's algebraic effects are not. Maybe it's not a fair comparison because react is super slim and spring (boot) is huge but when using it you have to work your way through endless baeldung tutorials to figure out which annotations to put onto your methods with no clear design. I also found asp.net easier to work with. Reason it reminds me of jQuery is because it's everywhere. A coworker of mine just wrote some websocket code that should be really great and reusable but it uses spring annotations extensively so you can never use his code without spring. But it doesn't really matter because if he wants to reuse the code in another java project, spring will likely be there. And that's a level of hodgepodge that jQuery achieved back in the day too. Guess what I want to say is that not all of web is "badly thought out" like the above poster insinuated.
- ruszki 2y agoYou should read Java EE standards, and Spring documentation, not Baeldung. There is design there. Finding the name of something is difficult in both, but of course React’s search space is way smaller due that Spring is larger by magnitudes, so it will be obviously easier.
- SahAssar 2y agoAnd the first letter in the XML acronym shouldn't even be X. Obiously the JS API should be called ExtensibleMarkupLanguageHyperTextTransportProtocolRequest
- deleted 2y ago[deleted]
- culi 2y agoThat is the standard practice in Java. But JavaScript has XMLHttpRequest, innerHTML, etc There's not really a good standard at all, but I think the _emerging_ practice is captured well here > When using acronyms, use Pascal case or camel case for acronyms more than two characters long. For example, use HtmlButton or htmlButton . However, you should capitalize acronyms that consist of only two characters, such as System.IO instead of System.Io . Do not use abbreviations in identifiers or parameter names. https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-1.1/141e06ef(v=vs.71) https://learn.microsoft.com/en-us/previous-versions/dotnet/n...
- shkkmo 2y agoIt isn't hard to correctly convert from camel case, you just tree any sequence of one letter words as a single word. However, without a standard for camel case acronym calculation, when you convert back you won't necessarily get an exact match. I presume, the ability to get the exact camelCase capitalization you want is why the html spec does the conversion this way: https://html.spec.whatwg.org/multipage/dom.html#dom-dataset-dev https://html.spec.whatwg.org/multipage/dom.html#dom-dataset-...
- tyleo 2y agoPersonal pet peeve but IMO ‘ID’ is a bad example because it is an abbreviation, not an acronym. I generally recommend ‘Id’ but I’ll admit, it’s like a tabs/spaces debate. ‘UI’ may be a better example :)
- Andrex 2y agoWhoah, I never thought about that. You're totally right, "ID" should really be "Id."
- IIsi50MHz 2y agoOr…Identity Document.
- IIsi50MHz 2y agoAlthough, I admit "ID" has kinda become a word in its own right, in my usage. An attribute ID is not, in my mind, its "identity" (and certainly not any kind of document), but a way of referring to it…and hopefully locally unique.
- tyleo 2y agoInteresting. In my mind an id is an identity. I think of ids as ‘what distinguishes and object uniquely from other objects’.
- meowface 2y agoFYI, on HN, you can get code blocks by indenting with two or more spaces: like this
- vaylian 2y agoThanks. This is really good to know! Unfortunately I can no longer edit my original post, but I will use your tip next time.
- deleted 2y ago[deleted]