8 Must Know Tips For Writing Clean JavaScript (Blind Reaction)

  Рет қаралды 17,561

James Q Quick

James Q Quick

Күн бұрын

Пікірлер: 49
@StuartAylward
@StuartAylward 2 жыл бұрын
I also prefer to define functions as `function` rather than a `const` assigned to an anonymous function. I think it reads better and clearer since a `const` can be an object or array or a primitive type. Defining functions with the function keyword is just much clearer imo. I only use anonymous functions (fat arrrows) when writing inline callbacks. I just don't buy into "use fat arrows everywhere" practice.
@JamesQQuick
@JamesQQuick 2 жыл бұрын
Fair enough. Thanks for sharing!
@dupre7416
@dupre7416 2 жыл бұрын
I also struggle with RegEx and I try to use it as little as possible. Fortunately, there is a member of my small team that is a RegEx master and they are my go-to resource.
@zengamer21
@zengamer21 Жыл бұрын
Every time I try and use ESLint and Prettier I end up with weird conflicts where one will modify the code and then the other will flag it as incorrect and then I can't run anything. It's so frustrating. I think it might be VS Code itself fighting with my ESLint and Prettier configs? I don't know. I usually end up disabling prettier to fix it.
@michaelash8552
@michaelash8552 Жыл бұрын
I've been using Regex in my development for years. I thought it was just me. I have a pretty strong understanding of regex so I often use it in searching and refactoring code. And most of the time the expressions themselves are pretty simple. It is extremely rare that I need to write any complex regexes. Since most tools let you do regex searches it's good to know that more people are taking advantage of this feature.
@hugodsa89
@hugodsa89 Жыл бұрын
Before watching the video: 1) follow the standards and practices around whichever framework, libraries, team guidelines to assimilate your coding style to it. 2) write code that communicates intent 3) be consistent 4) write a test first that has your desired output or outcome, and make it work, then chunk it into functional pieces that separate concerns and responsibility, and iteratively refactor your code and tests 5) segregated core functionality from imperative shell to isolate side effects and keep your core logic testable and reliable. 6) read other codebases and expose yourself to learn new approaches, try them yourself, and reforge a new understanding. 7) pay forward by teaching others and bringing non technical people from the business to guide them through your logic, if it’s getting difficult to explain its highligh likely that you have named things badly. (This goes much in line with DDD) Domain driven development. After all code is just instructions and a translation layer between a machine and an operation
@brianmmdev
@brianmmdev 2 жыл бұрын
Awesome video! Re: comments - I lean towards using comments as little as possible. MOST of the time you can write code that makes perfect sense for others reading it, but there are definitely edge cases or "hacks" where it makes sense to comment why you are doing it. An example would be adding strange constants in performing calculations where the name of the constant might not clearly get across WHY you are doing the thing.
@mrlordbrutish
@mrlordbrutish 2 жыл бұрын
Yes, but sometimes you do a thing in a way that is not the normal way one would expect to do it, for good reason. Comment the reason!
@ConnecticutAngler
@ConnecticutAngler 2 жыл бұрын
I like the concept of writing “self-documenting” code to help make it more readable while reducing the volume comments. I’ll generally opt to use more longer, more verbose, readable variable names to achieve this. Sometimes comments are just necessary and unavoidable, of course, but complex functions can be made much more readily intelligible if variables really spell it all out wherever possible.
@JamesQQuick
@JamesQQuick 2 жыл бұрын
Right there with you!!
@732brudder
@732brudder 2 жыл бұрын
sometimes my variable names are outright rediculous because they are so descriptive but I typically have to write very quick and fast (and often dirty haha) solutions so I typically spend a lot of effort on writing code this way. Makes going back later to document things way easier. I'm not a developer by trade, but have to write code regularly to solve problems in my work so I don't have a full time effort writing code and documenting.
@mageprometheus
@mageprometheus 2 жыл бұрын
I've just binge watched 90% of your videos from the past year. It's been great. Has your stress level gone up? High cortisol causes glitching in the thought process. Take care.
@JamesQQuick
@JamesQQuick 2 жыл бұрын
I’m not consciously stressed. Thanks for checking in though!
@mageprometheus
@mageprometheus 2 жыл бұрын
@@JamesQQuick Good. I haven't found a better collection of videos with the least need to rewatch sections.
@zalodias123
@zalodias123 2 жыл бұрын
Best use case for me with RegEx is searching & making precise bulk changes on a large codebase. Very helpful when you want to search for closely named variable names, or components with a similar prefix. Definitely can increase productivity & speed up your dev speed
@marekbee
@marekbee 2 жыл бұрын
So Fresh and so clean 🛁
@kingstonejob7840
@kingstonejob7840 2 жыл бұрын
I find my code cleaner, when written in TypeScript, rather than directly in JavaScript. Also I think knowing arrays functions like map() and filter() helps to clear the code a little bit than when I was using for each loops.
@dinckelman
@dinckelman 2 жыл бұрын
The first thing I do with a new TS project is setup a linter. An acquaintance has a package with all the rules exactly how we'd want it, so the whole config is just 3 lines. Those 3 lines would make a massive difference during development
@sewaksingh6189
@sewaksingh6189 2 жыл бұрын
thanks james :)
@JDalmasca
@JDalmasca 2 жыл бұрын
What was the extension that does the automatic conversion to template literal strings? I don't think you mentioned any names of extensions.
@TihomirKit
@TihomirKit 2 жыл бұрын
Maybe "Template String Converter", I just looked for it and that's what I've found. Someone correct me / suggest better extension if there is one.
@JamesQQuick
@JamesQQuick 2 жыл бұрын
Yep that’s it!!
@karlstenator
@karlstenator 2 жыл бұрын
I too struggle with Regex from time to time. Had to battle some today actually. Would be keen on resources... but tbh, I'm just waiting on an English-to-Regex AI conversion app to solve all my problems. 😂
@dominuskelvin
@dominuskelvin 2 жыл бұрын
Great video as always James
@JamesQQuick
@JamesQQuick 2 жыл бұрын
Thank you sir :)
@lucasrmendonca
@lucasrmendonca 2 жыл бұрын
Hi James, what's the name of the extension that automatically converts the single quotes to backticks ?
@JamesQQuick
@JamesQQuick 2 жыл бұрын
Ah it’s called template string converter!
@JeremyKolassa
@JeremyKolassa 2 жыл бұрын
Dunno about Prettier, it's opinionated enough that it can sometimes cause problems, such as an application suite I'm building widgets for and whose default ESLint is set up to be diametrically opposed to it. Definitely agree with using TypeScript, template literals, and regex; nesting can be annoying but sometimes it's the best way. I like the idea of the Stepsize extension, but I don't know if I'd use it, simply because I tried to sell my coworkers on using the somewhat similar CodeStream extension and it just didn't fit the company's workflow.
@Adam-nw1vy
@Adam-nw1vy Жыл бұрын
Please do a video about chatGPT
@patrykkowalski1305
@patrykkowalski1305 2 жыл бұрын
I heard that putting try/catch everywhere is making app slower. Is that truth?
@astb01
@astb01 2 жыл бұрын
Not much so unless the code fails. It’s not the same as an if else if where the interpreter has to check each condition. A try and catch is usually used when doing an api call so it will either pass/fail and then do the logic in that code block. Obviously use try/catch when only needed not everywhere lol Any local service code also if it throws an error
@JamesQQuick
@JamesQQuick 2 жыл бұрын
I haven’t heard that. I wouldn’t think so!
@faridguzman91
@faridguzman91 2 жыл бұрын
ive seen " senior developers " doing these nested if else statements and over use of callbacks , and after 4 mths just quit to join a younger team that actually know design patterns and best practices. i dont believe anyone can be truly senior unless u dream about clean code.
@0x007A
@0x007A Жыл бұрын
At a minimum each class, method, or function should be commented preceding the readable code.
@jasongates6894
@jasongates6894 2 жыл бұрын
1) Descriptive Variable Naming 2) Detailed Linter 3) DRY / Reusable Code 4) Separation of Concerns. 5) Comments when your team looks at the code and says "The heck does this do?"
@JamesQQuick
@JamesQQuick 2 жыл бұрын
I like it!
@hugodsa89
@hugodsa89 Жыл бұрын
I am using stepsize but it’s so much worse than sonar
@saivivekravi4844
@saivivekravi4844 2 жыл бұрын
Hi @james can you review vs code extension console ninja
@JamesQQuick
@JamesQQuick 2 жыл бұрын
What does it do? Did you create it?
@saivivekravi4844
@saivivekravi4844 2 жыл бұрын
@@JamesQQuick in any javascript library like reactjs stevelejs it will give output in the code it like quokkajs
@studioph5.6
@studioph5.6 2 жыл бұрын
No more svelte tuts, sad 😢
@JamesQQuick
@JamesQQuick 2 жыл бұрын
More coming!!
@studioph5.6
@studioph5.6 2 жыл бұрын
@@JamesQQuick looking forward to! last svelte update is confusing with all these +pages.js +layouts.js and stuff =(
@Randomguy48279xyz
@Randomguy48279xyz Жыл бұрын
👍
@devGilson
@devGilson 2 жыл бұрын
ESlint is very good, both for personal projects and, of course, for work.
@JamesQQuick
@JamesQQuick 2 жыл бұрын
Yeah I love it!
@lisaklapschinski
@lisaklapschinski 2 жыл бұрын
Great videos!! I just sent an email to your business inquiry email. Let me know your thoughts
5 Tips for Writing BETTER For Loops in JavaScript
16:15
James Q Quick
Рет қаралды 70 М.
Top 5 Async Mistakes for JavaScript Beginners (Don’t make these!)
15:11
Когда отец одевает ребёнка @JaySharon
00:16
История одного вокалиста
Рет қаралды 15 МЛН
What's in the clown's bag? #clown #angel #bunnypolice
00:19
超人夫妇
Рет қаралды 30 МЛН
Vim Tips I Wish I Knew Earlier
23:00
Sebastian Daschner
Рет қаралды 73 М.
30 Programming Truths I know at 30 that I Wish I Knew at 20
17:41
5 JavaScript Concepts You HAVE TO KNOW
9:38
James Q Quick
Рет қаралды 1,4 МЛН
I learned to code from scratch in 1 year. Here's how.
41:55
Thomas Frank
Рет қаралды 420 М.
10 Guaranteed Ways to Improve Developer Efficiency and Focus
17:21
James Q Quick
Рет қаралды 9 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 721 М.
Deno 2 with Ryan Dahl
44:32
Syntax
Рет қаралды 18 М.
Когда отец одевает ребёнка @JaySharon
00:16
История одного вокалиста
Рет қаралды 15 МЛН