7

Having two methods is perfectly fine, as both are valid use cases. The key to this is to have one method call the other, as you have shown. You don't want to duplicate code. Having a single method which operates on arrays is fine, too. If you find you are using that method to operate on a single word often, though, you may find the first option a little ...


5

Better can only be defined in the context of your application. Usually, the public API you choose should reflect the use case of the application. For that, let me present two different scenarios, in which for each of them I would give a different answer: Scenario #1: capitalizing words is an user story You are developing a text editing app, and there is ...


2

My argument is frontend doesn't care which database backend is using. Sorry, but that is actually an argument for checking of the existence of IDs. The database backend is an abstraction which tends to be leaky - it does not matter how much effort you invest to make your frontend DB agnostic, there is always something which behaves differently when you ...


2

As a relatively senior guy in my org, I just plainly reject PRs that have insane code structure, like 30k lines in a single file (I bet much of that is copy-paste). My suggestion would be to talk to the team and make them aware of the best, or at least reasonably idiomatic, React practices, and then enforce them. Make sure you actually can afford doing ...


1

In general, you are correct. The back end should be abstracting the detail of the database away. We've switched databases twice without the front end even knowing. If you need a list of hotels with ids, the back end should provide a way to query only hotels with ids, regardless of what database is in use. Expecting the front end to filter a table is error ...


1

Adding to Victor's comment, simplifying and exploiting ES6 for varargs function getInfo(howFn, ...info) { try { return howFn(...info); } catch (error) { logger.error(this part needs a little work); } } // Calls let shopInfo = getInfo(shopConfigModel.getShopInfo, phone); let shopInfo = getInfo(shopConfigModel.getShopInfoById, shopId); ...


1

Assertions to me were always about documenting my assumptions related to the functioning of an algorithm. They communicate that, at this point, I’m asserting something should be true—likely, it’s a property I can prove to be true of a functioning implementation. For example, in a Semaphore implementation, I might have asserts that the value is never below ...


1

Consider your problem domain, and what's the most common use case. If 90% of the time, client code will be working with arrays or some other collection type, and if it is preferable to do it that way, say, to encourage cache locality, then it's probably better to just have the array version - it helps suggest how client code should be written. If not, ...


1

Would you find it easier to work with JavaScript if dom events were sent directly to window instead of to the impacted dom element? If your event is not linked to a specific dom element (like the window userproximity event), it makes sense to send it to window directly instead of creating an artificial dom element. Otherwise, if your event is linked to a ...


1

Nowadays the recommended approach is to use Authorization Code with PKCE (Proof Key for Code Exchange). The threat to be concerned about is leaking the access token from the URL - the URL is not a good place to put sensitive information and there are a number of ways that the URL could be leaked. When a confidential client uses code flow a leak of the ...


1

Nice research effort from the OP! Upvoted. So you have already got an answer from your cross-posted question in SO. On top of that, here I'm just trying to clarify on the one statement in your question, based on the original OAuth2 RFC 6749. I understand the security concerns with having an AT show up anywhere in a log file. I do not, however, understand ...


1

I use this same style with my video game development with Unity 3D. I create components like Health, Input, Stats, Sound, etc. and add them to an Game Object to build up what that game object is. Unity already has mechanics to add components to game objects. However, what I found was most everyone was querying for components or directly referencing ...


Only top voted, non community-wiki answers of a minimum length are eligible