New answers tagged

0

Are you the only one who is concerned about the code organization? Are you prepared to drive a discussion on coding standards with your team? What about management, have they been made aware of the risk of coming to a standstill because of tech debt? In a first round, automated refactorings like extract function or move class to file are your friend. ...


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

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

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 ...


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 ...


0

You can add a splash screen or you can say a welcome popup on your website. Which contains all the information about you. Your information contains licenses you owned for your sites etc. This way you can get all the credits of the site. All these things must be done with the permission of the team members.


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 ...


0

This doesn't answer your actual style question, but note that, in ES6, you can use the rest / spread operator to simplify and arguably clarify your code. In the simplest case below, the caller must remember to spread their array before calling your function: function capitalize(...words) { return words.map((word) => word.toUpperCase()) } console.dir(...


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, ...


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 ...


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 ...


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 ...


Top 50 recent answers are included