Clean Code: Functions (Part 1) - Beau teaches JavaScript

  Рет қаралды 52,932

freeCodeCamp.org

freeCodeCamp.org

Күн бұрын

Learn the best practices of how to create Clean Code in JS. This video tutorial is part 1 of how easy is to make Javascript functions that are readable, reusable, and refactorable. Thanks to Ryan McDermott (@ryconoclast) for writing the article that inspired this video.
Ryan's article:
🔗 github.com/rya...
Code:
🔗 codepen.io/beau...
Beau Carnes on Twitter: / carnesbeau
⭐JavaScript Playlists⭐
▶JavaScript Basics: • JavaScript Basics Course
▶ES6: • ES6 - Beau teaches Jav...
▶Design Patterns: • Design Patterns - Beau...
▶Data Structures and Algorithms: • Data Structures and Al...
▶Clean Code: • Clean Code - Beau teac...
-
We're busy people who learn to code, then practice by building projects for nonprofits. Learn Full-stack JavaScript, build a portfolio, and get great references with our open source community.
Join our community at freecodecamp.com
Follow us on twitter: / freecodecamp
Like us on Facebook: / freecodecamp
Follow Quincy on Quora: www.quora.com/...

Пікірлер: 30
@sagnikb7
@sagnikb7 5 жыл бұрын
U said of removing duplicate in code...then told not using flags and then made 2 functions with almost duplicate code? Which practice should I follow!
@oufcena5092
@oufcena5092 4 жыл бұрын
Rule #1 A function should do only 1 thing. Rule #2 If there are 2 or more functions sharing almost same code & purpose then remove duplicate.
@alex_nevskiy_888
@alex_nevskiy_888 4 жыл бұрын
It seems that two last examples are mutually exclusive.
@SirWolf2018
@SirWolf2018 3 жыл бұрын
Mistakes were made. Function `createTempFile` should call `createFile`, but since `createFile` is trivially simple, it shouldn't even exist.
@sixtyone0145
@sixtyone0145 3 жыл бұрын
Ugh, the “one level of abstraction” was very badly explained. Confusing :/
@Elregar71
@Elregar71 7 жыл бұрын
I love the sound of your keyboard dude, takes me back many years. Clunky and loud so everyone knows that i'm workin!!!
@Ugotsta
@Ugotsta 6 жыл бұрын
Ha, I grew up with the clunkiest of keyboards and am happy the world's mostly moved past them. But yeah, they do a great job of creating the sound of work!
@z.m.4331
@z.m.4331 5 жыл бұрын
It gives me a feeling of comfort too! :)
@truthseeker2171
@truthseeker2171 2 жыл бұрын
That's why I recently got the keychron k2v2 keyboard.
@jggabayno
@jggabayno 2 жыл бұрын
this content is so underrated
@alimfuzzy
@alimfuzzy 7 жыл бұрын
are your create files and your create temp files reversed? i.e. swap the names around.
@MrOmerDalor
@MrOmerDalor 7 жыл бұрын
So you have a variable portfolio that can contain a GitHub link. Very clean indeed...
@loO5r
@loO5r 6 жыл бұрын
Totally agree, this feels very hacky
@Mohamed_Karam551
@Mohamed_Karam551 4 ай бұрын
Great content, but I didn't understand the last example
@Dystn399
@Dystn399 5 ай бұрын
why is the variable name for the const not in all caps?
@megadarkassassinn
@megadarkassassinn Жыл бұрын
Awesome video, but mad at the ear-rape at the end...
@alex5251
@alex5251 Жыл бұрын
@8:31 vice-versa for function names is more logical (createTempFile in temp folder.. ) 🙂
@jasonmcgloin8397
@jasonmcgloin8397 7 жыл бұрын
Beau, what's your take on ternary operators with respect to "clean" code? I've seen the complaint that they aren't as readable as ifs, but I happen to like them (as long as there's no nesting or really weird stuff going on). For example at about 7:00 lines 104 to 108 could be, const portfolio = employee.type === 'manager' ? employee.getMBAProjects() : employee.getGithubLink(); and you would retain the use of const. But, would this be considered "clean"? As a newer programmer, these nuances are tough to figure out, so thanks for these videos.
@BeauCarnes
@BeauCarnes 7 жыл бұрын
I also like ternary operators. I often use them in place of if statements. I think your suggestion would be a good way to refactor this.
@Ugotsta
@Ugotsta 6 жыл бұрын
Good point. I think ternary operators would have been a problem in the past for the many people who hadn't seen them yet but the world's changing fast as noticed even in this video with the arrow functions, lets and consts. One issue with ternary operators though, if you've never seen them before, it can be difficult to find an explanation. It was for me some years back. It took me a moment to realize the question mark could be an operator so I was able to find an explanation at that point but it was very confusing prior.
@FredChevitarese
@FredChevitarese 7 жыл бұрын
Hi! I think sometimes you speak very fast :P But thanks for the videos :)
@TheMKilo8
@TheMKilo8 6 жыл бұрын
createFile() and createTmpFile() ... so what u say about DRY ? )
@sagnikb7
@sagnikb7 5 жыл бұрын
😂😂😂 just to eliminate flags???
@SirWolf2018
@SirWolf2018 3 жыл бұрын
Mistakes were made. Function `createTempFile` should call `createFile`, but since `createFile` is trivially simple, it shouldn't even exist.
@thalibmuhammad9519
@thalibmuhammad9519 2 жыл бұрын
ttimeless skill
@saadiyafourie
@saadiyafourie 6 жыл бұрын
Thank you, great job. I will be aware of these things for any future code I write :)
@vitormelo22
@vitormelo22 2 жыл бұрын
Incrível.
@anuragdubey7496
@anuragdubey7496 5 жыл бұрын
At 1:32 , emailClient is still filtering the records, maybe one could directly get an array of active clients and call email functions on it
Clean Code: Functions (Part 2) - Beau teaches JavaScript
6:47
freeCodeCamp.org
Рет қаралды 19 М.
Objects - Beau teaches JavaScript
8:40
freeCodeCamp.org
Рет қаралды 42 М.
Пришёл к другу на ночёвку 😂
01:00
Cadrol&Fatich
Рет қаралды 11 МЛН
ОТОМСТИЛ МАМЕ ЗА ЧИПСЫ🤯#shorts
00:44
INNA SERG
Рет қаралды 4,7 МЛН
ДЕНЬ УЧИТЕЛЯ В ШКОЛЕ
01:00
SIDELNIKOVVV
Рет қаралды 2 МЛН
Clean Code: SOLID - Beau teaches JavaScript
12:08
freeCodeCamp.org
Рет қаралды 82 М.
JavaScript Security Vulnerabilities Tutorial  - With Code Examples
25:05
freeCodeCamp.org
Рет қаралды 77 М.
JavaScript FUNCTIONS are easy! 📞
12:14
Bro Code
Рет қаралды 37 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 812 М.
5 JavaScript Concepts You HAVE TO KNOW
9:38
James Q Quick
Рет қаралды 1,4 МЛН
Promises - Beau teaches JavaScript
5:39
freeCodeCamp.org
Рет қаралды 29 М.
Test-Driven Development // Fun TDD Introduction with JavaScript
12:55
Inheritance in JavaScript - Prototypal Inheritance tutorial
20:06
Пришёл к другу на ночёвку 😂
01:00
Cadrol&Fatich
Рет қаралды 11 МЛН