Write Better Code

preview_player
Показать описание
Code tips and tricks from Uncle Bob's Clean Code book

Рекомендации по теме
Комментарии
Автор

One of worst videos so far

Throw a bunch of statements from 20 years old book, and opinionately state these as 'good', and all other ways are bad

Code comments show this most beautifully

alexanderpopov
Автор

I wanted to scream that execptions are evil or new goto at first... but you selled it to me reasonably - well balanced take - excellent job!

AK-vxdy
Автор

I would say that comments should not be explaining WHAT is the code doing but WHY. The what should be visible from the code, but it is not often clear why. Explaining why is it there should prevent people from deleting it "because it doesn't even seem necessary" - when it's actually a super important hack that prevents the whole thing to crumble (on some of the supported platforms or under some crazy non-obvious conditions).

What I also like is to put some traceability into the code, as in "This function fulfils the requirement REQ-001". It's not always nice but very handy when someone needs to verify that all requirements were implemented and how.

miroslavhoudek
Автор

Comments for edge cases are very very important, especially when doing more complex backends tasks.

Documenting flags, magic offsets and other such items is pretty dang handy.

vessbakalov
Автор

Will you cover Pavel Durov arrest in you future videos? Very curious about this

vpetryniak
Автор

Can you make a video explaining with example code the do's and don'ts of error handling? That would be great

seanoverton
Автор

Thanks for the great video, as always. I doubt anyone is bothered about it but there is a spelling error in 5:40 "cencerns" instead of concerns.

UnderProxy
Автор

I would like a video of DDD next. Keep up the good work.

Devenias
Автор

Writing clean code it's like keeping your room tidy so you can find things easily

alinghinea
Автор

what do you use for making videos? cause its really good.

sumankhadka
Автор

“Good code needs no explanation” is a myth

kahnfatman
Автор

Good video, but I disagree that “good code doesn’t need comments”. Some code is complex by default and also if your working on code in which developers over many years are writing then having useful comments can be good. Imagine a codebase over 100, 000 lines of code with no comments! You will pray it has some internal docs but it probably wont if you wont even comment the code! Also there are librarys to use code comments to generate a web version of the docs.

codingwithjamal
Автор

3:59 Be careful Boy Scout! You might violate another important guideline!

1. "Don't make unnecessary changes" or "Avoid making changes for the sake of making changes"
2. "Keep your change small and focused"

codeman-dev
Автор

It’s okay to have some duplicate code, so my tip would be to not take “avoid duplication” or the DRY principle too literally. Premature abstraction is an easy way to waste your time!

nielskersic
Автор

I don't agree with comments being code smell.
It could be very helpful understanding the business logic behind the code or why something was implemented in a specific way.

OfficialRehaldinho
Автор

I was agreeing until the "use exceptions". errors as values are so much nicer wdym?? so much more explicit and clear where errors can happen, and forces you to handle all errors.

bean_TM
Автор

Here's a thing I learned about testing best-practices: Test higher-level requirements, not implementation details. I've seen some developers test nitty gritty details of their implementation, which doesn't really matter. And the result is code that is hard to refactor, and by extension hard to maintain, because despite requirements remaining the same during a refactor, tests fail and you have to adapt them to the refactor. Adapting tests is a necessary thing, but only when the actual requirements of the SUT changes.

This obviously relates to the point you made about not over testing, but this is my attempt to explain what that actually means.

gimballock
Автор

One thing you forgot to mention is to split a big complex function in pure functions and impure functions, because with the pure functions you can do unit tests and they usually has the logic of your app

andreilucasgoncalves
Автор

Comments should explain why something is done (business logic), not how/why a function works.

myotun
Автор

I agree 99% of this, this is really good!! 🙏 The only thing I disagree with is that you should avoid duplication at all costs. Sometimes it is better to write WET code when code becomes hard to understand. Don't make it so DRY that it becomes a desert 😎 I guess comments in moderation are also not bad.

QueeeeenZ