Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Should i have one constants file for the whole app or split it one for each coresponding store , action ?
My thought's are one for the whole app?
It's a matter of preference.
If you have a couple dozen constants, I don't see a downside to keeping them in one file. If you have, say, hundreds of constants it may make sense to split them up—not for any technical reason, but just to make it easier for you and your teammates to find the ones you're looking for without digging through many pages of the same file.
Either way you should do your best to group them logically—and even in a file as simple as a list of constants, generous whitespace and comments will make everyone's lives easier.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
In Javascript, is it acceptable to rename built in functions. For example, in my code, I use document.querySelector() tons of times. This is extremely long and tedious to type every single time (even with autocomplete from the IDE's side). Therefore, I decided to create a new function with a shorter name like the following:
let qs = selector => document.querySelector(selector);
Is this an acceptable practice in the JS community? Is this considered bad code? If so, why? Additionally, if doing this is alright, what are some drawbacks?
Thanks.
No.
Someone is going to come behind you to edit your code.
They will then have to track down your renaming function to actually see what it does.
Create an snippet in your IDE if it’s that much of an issue for you.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Please ignore my syntax.
This is just an example if this is a bad idea.
let's say I have select with 50 options but instead of typing out options 50 times.
would it be a good idea to use js and give it an array variable.
run through the variable.length then append it into html.
Is it bad to use js like this though and why?
No issues. Now clients are way too much powerful than they were earlier before.
So, utilizing some of its power never harms.
Now the problem .. rendering template on client is not an issue ..Angular, React all does the same.
While you are doing only a little which may consumes less than < 1 ms. So , just go ahead.
it is a better practice.
You are a programmer, you will never need to type out options 50 times :)
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I have been looking at the naming conventions used by many larger sites for styles and javascript functions and came across facebook using class names such as class="_2t-f" and just wondering if this is done for a specific reason or if this is just a choice as opposed to intuitive class naming such as class="text-center"
I have tried to do research into this and have came across the Facebook Haste system and the Phabricator Celerity system but they seem more focused on versioning and requiring static resources as opposed to naming conventions. Thanks.
It's not a human choice, it's a minified classname. Bytes on the wire at Facebook's scale are measurable and costly.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
This will be a bit strange question, but..
I am planning to use jQuery/knockout to write a dynamic custom wizard
which will depending on different scenarios will load different templates/UI logic to the user.
Question.
Should I take into consideration memory usage in this case? or should I manually unload/clean up/save to the server pieces of UI which is not in use??
PS. Current version of wizard will have 5-7 steps.
You should write your app the best you can functionally and then determine if memory is even an issue. If it is, then you can take steps to reduce it's memory footprint but odds are you'll be fine. For instance, go look at what a site like Facebook's memory usage, a site that everyone and their grandmother uses.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
For javascript functions that only apply to one page, in a large(ish) web app - is it better to have the scripts inline or in the main javascript file?
If your application gets little traffic, use whatever you like best.
If your application gets a huge amount of traffic, you want to minimize:
the number of distinct requestable resources in your application to maximize cacheability
the size of each individual resource to optimize the empty cache experience.
1 and 2 contradict each other, so you have to pick a tradeoff appropriate to your application.
I would prefer having a proper module system and useful compilation tools so I don't need to have to worry sacrificing efficiency when it comes to keeping my code organized.