Тёмный

Clean Code is SLOW But REQUIRED? | Prime Reacts 

ThePrimeTime
Подписаться 591 тыс.
Просмотров 308 тыс.
50% 1

Recorded live on twitch, GET IN
/ theprimeagen
Article link: betterprogramm...
Written by: Bawenang Rukmoko Pardian Putra | / bawenang
MY MAIN YT CHANNEL: Has well edited engineering videos
/ theprimeagen
Discord
/ discord
Have something for me to read or react to?: / theprimeagenreact
Hey I am sponsored by Turso, an edge database. I think they are pretty neet. Give them a try for free and if you want you can get a decent amount off (the free tier is the best (better than planetscale or any other))
turso.tech/dee...

Опубликовано:

 

29 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 724   
@daves.software
@daves.software Год назад
I worked on a system at the NAIC that was written in C++ and implemented all of their polymorphism via templates rather than via inheritance. The result was wrappers inside of wrappers inside of wrappers, and the error messages were horrendous due to extensive use of nested templates. We had to pipe our gdb message through stlfilt just to figure out what types were involved whenever we had a failure. There is a happy medium between code that is inscrutable because it is monolithic spaghetti code, and code that is inscrutable because it has been atomized into a fine mist of components. Ironically the reasons why monolithic spaghetti code is hard, is actually the same reason why overly abstracted code is hard. There's too many things to keep track of in your head, the only difference being what you're tracking.
@u9vata
@u9vata Год назад
Btw did you know that you can run python in your gdb? You could have prepared a python setup for your team for gdb use for custom pretty printing this - or if that stlfilt was good-enough just auto-run it via python commands you added to gdb. Also I am not sure when this way, because did static polymorphism like that (maybe an other architecture though) and did not have this issue.
@daves.software
@daves.software Год назад
@@u9vata at the time (2003ish) I'd never heard of Python.
@lerubikscubetherubikscube2813
I love that I haven't googled stlfilt and I'm confident in what that tool does
@daves.software
@daves.software Год назад
@@lerubikscubetherubikscube2813 :)
@fededevi1985
@fededevi1985 Год назад
Well there is a difference, the highly abstracted code can be accessed at multiple levels and can be modified at multiple levels ignoring the finer (or higher level) details while the monolithic ..well it is just one big mess and you are forced to understand it all. I always think it is funny that developers are fine in using the 20 or so level of abstraction CPUs - OSs - programming language and libraries provides but then they go crazy if you add another 2 or 3 layers on top of that. Maybe the problem is not the abstraction itself but the quality and the experience you have with it. In the end complex behavior will require abstraction whether you like it or not. And good abstraction will make it easier to understand, not harder.
@JoshWithoutLeave
@JoshWithoutLeave Год назад
First time I saw "Scrum Master" as a title I really thought it was something dirty and a 12 year old had hacked the employee directory again.
@djixi98
@djixi98 Год назад
Again? lol
@IIARROWS
@IIARROWS Год назад
Now I know better. It certainly is something dirty.
@iamhardliner
@iamhardliner Год назад
They recently changed it from scrum master to agile coach where I work
@xdman2956
@xdman2956 Год назад
Me too, totally
@ZephrymWOW
@ZephrymWOW Год назад
​@@iamhardlineraka retards who haven't coded in a decade and are great at inflating delivery costs
@Xankill3r
@Xankill3r Год назад
This article does the classic defence of Clean Code bait-and-switch where one moment they're talking about Clean Code™ and the next moment they're talking about regular run-of-the-mill clean code.
@Speykious
@Speykious Год назад
There was that one article talking about how "clean" means anything and everything nowadays. Since then, every time I think something is or isn't "clean", I catch myself thinking that and try to actually elaborate what I mean. "It's cleaner", what does that mean? Does it make the code more maintainable? Is it easier to understand, more readable? Or is it just a vague good feeling I have and I actually don't have any reason for it to be cleaner, and it comes down to subjective personal preferences? Usually it's the former, but the rare occasions where it's the latter, I'm thankful that I got myself to think this way. Though now whenever someone says "it's cleaner" I get infuriated because it means nothing.
@homelessrobot
@homelessrobot Год назад
@@Speykious yeah 'clean' is the least helpful adjective to describe code. Luckily, we are adjective people, professionally per-disposed to actually meaningful descriptions. Or at least we should be. I dunno what lazy shithead thought 'clean' was helpful. I am guessing its a borrow from gym bros and their 'clean eating' crap.
@protox4
@protox4 Год назад
@@Speykious I prefer the term "idiomatic".
@etodemerzel2627
@etodemerzel2627 Год назад
@@protox4 *idiotic Sorry, I couldn't help myself.
@casperes0912
@casperes0912 11 месяцев назад
I think I have a very low tolerance for file length. Most files I want under 200 lines
@jakubkoci
@jakubkoci Год назад
If the code is hard to understand and maintain, then it's not, by definition, a clean code.
@MrAbrazildo
@MrAbrazildo Год назад
3:18, you (23:54) and Casey said something that I already knew: wait the need before abstracting. This is the right way to design: focused on the practical needs. And that means building abstractions for defensive proposes too - before somebody starts to advocate FP. 3:35, 1 of the basic optimizations made by the machine is to inline f()s. The only concern is about reaching a limit, after which it won't inline or starts extra calculations about it - but 1 can set it. The actual problem about helper f()s is the options for calling them by mistake, or to feel the need to memorize them, as options, when thinking about the whole thing. To avoid this extra stress, a class to hide them can help. But this starts to require more boilerplate. The best solution is writing lambdas (within the f(), of course), if those blocks are called more than once. Otherwise, I keep them inside the f(), as explicit code, if they only make sense there. 5:03, if 2 apps have a difference of ms for each action, people will feel better with the faster 1. So, it's not just for speed-critical projects: even the common ones can benefit. Meta said that _"people feel more engaged when the app is faster"_ (probably about ms and above).
@tordjarv3802
@tordjarv3802 Год назад
I'm in high performance computing and scientific computing, and obviously speed matters to us. There is a rule of thumb in HPC that say that any clock cycle your CPU, GPU, TPU or IPU do not spend on floating-point arithmetics is a wasted clock cycle. Obviously this is not entirely true, you need to read data from storage, you need send data between nodes and so on. However, it turns out that you can more or less reach this ideal by abstracting the calculations you want to do to operations on matrices, vectors or multi-dimensional tensors. The big issue with the code I see a lot of my physicist colleagues do is that they do not abstract enough and end up wasting clock cycles on index calculations and conditional statement that shouldn't be necessary in the first place if they had found the right abstractions. The point I'm trying to make is that abstraction is not necessarily the enemy of performance, it is rather a question of finding the right abstractions (which admittedly can be very hard). Anyway, I think it is a discussion is important, and yes in some areas of software development performance is not a big concern but in others it is.
@denys-p
@denys-p Год назад
Every time I see “Clean code” book on developers table, I know that at some point of time (more sooner than later) I’ll feel a strong urge to bash its owners head with that book. Never was wrong. I have a feeling that Bob Martin made much more harm than good for software development industry
@homelessrobot
@homelessrobot Год назад
Yes. to all of this.
@adrianwilkins1161
@adrianwilkins1161 27 дней назад
The thing is, you can usually do both ; the Fast Inverse Square is an example of this - it makes ONE THING very fast and keeps it in a well defined box. I've written my fair share of "fast but ugly" code. Most code should be clear and easy to read. If you can't do this, write good docs, and hide it behind a nice API.
@ben-brady
@ben-brady 25 дней назад
8:30 The TF2 coconut is actually a myth, it exists in the game but it can actually be deleted without crashing the game. In fact the majority of the asset files can be deleted and it still plays with missing textures.
@jonb8869
@jonb8869 10 месяцев назад
I think the best approach to software development is to straight up write one to throw it away. 1. You have the option to get it to market faster. 2. You have all the unknowns now known. 3. You've learned a lot solving the problem. You can get so much done by just having a conversation about a feature ... going off doing it... making decisions on your unknowns and coming back with something done... Then saying what do you guys like... what don't you like. I had these questions these are the decisions I made. Then you go back fix those issues.. Make sure the customer is happy. Then get some automated integration tests around it. Then you engineer it. After that you can optimize it.
@deNudge
@deNudge 9 месяцев назад
The table approach of the original video is so good !! Up until the point where your boss steps in and says "Can we do complex shapes as well?" And then the junior dev that inherited the stuff from the inventor genius that happened to leave the company scratches his head.
@CptColCool
@CptColCool 8 месяцев назад
14:13 Wow! Yes! That is a principle I am going to adopt now! So easy and so obvious once you hear it.
@emiliancioca
@emiliancioca 2 месяца назад
The fast inverse sqrt is a bad example for the article to bring up. I get their point, but they are implying that there is a "clean code" alternative to that, as if putting the bit hacks into a virtual function would have solved the maintainability problem of that code.
@edvardm4348
@edvardm4348 7 месяцев назад
usually problem in these discussions is that there's too little context to give meaningful answer. What is the size of the team? How important the product is? What kind of developers there are? What is the domain? Probably at least 3x as many traits. Many of my jobs recently have been some sort of ETL. There performance does matter in a sense that "can we run these 80M new entries in 4h", so data structures and algorithms are crucial, and pretty much never some bare-metal bit fiddling made any important difference. I'm sure many others have exactly other experience. There's also the question of what "Clean Code" means. I'm fan in a way that I believe code is really hard to get even correct, if it's hard to understand, and writing maintainable, readable code is one of reasons why people try write clean code. What I don't like in Uncle Bob's approach is that 1) they are often quite OOP-centric 2) they are often presented like solution without a cost, whereas to me it seems like every design choice has cost included. All solutions derived from following say, SOLID involve these, if somebody says "there's no cost" I'll show you someone who's either a newbie or indoctrinated.
@NerdyWasTaken
@NerdyWasTaken Год назад
Deleting coconut is not blocking Team Fortress 2 to run, but the 2Fort cow model is you can't run game without the cow model.
@MatheusAugustoGames
@MatheusAugustoGames Год назад
About abstracting too early. TDD can aid with this. You write the simplest possible code needed to make the test pass; only then do you refactor. You only introduce abstractions if you find duplication or if you find a better way to solve the problem. But whatever you end up refactoring to, the tests have to pass.
@alistermunro7090
@alistermunro7090 8 месяцев назад
I never want to hear "I've got a bush in my backyard" again...
@refreshcrazyname
@refreshcrazyname Месяц назад
I agree with most of the points, but my perception of what Clean Code is is a bit different compared to what is presented here. When I use the term, it simply means that the level of maintainability of the codebase is even more important than the functionality. I have met so many developers who were entirely focused on functional outcome and perceived maintainability as a second class citizen, which leads to systems that a horrible to understand and maintain. Clean code to me expresses the intent and thoughts of the developer who did it to reduce the WFT factor! The book is not an absolute, it is Uncle Bob's view on how to create maintainable systems and as you I agree with a some (probably most) but disagree with other. But I would never apply any heuristic religiously. Back in those days system and code architecture were the only means of improving maintainability. Today automatic testing has brought a really powerful tool, but just like production code, the quality and maintainability of you test suite is of utmost importance.
@christopherwood12
@christopherwood12 Месяц назад
Yup with old code defo talk to the oldest person there. Ask if it’s been tried to be refactored and ask if there be ghosts in there waters
@CallousCoder
@CallousCoder Год назад
Also what I don’t hear anybody say is despite these (idiotic) TDD, BDD, Clean Code bollocks it is proven that software lifecycle is shorter than ever. An average product lives 4 year before rewritten. And software now is the most crap or has been! Buggy slow inconsistent! So all these mantras need to go out and just write code performed low memory usage code again. Nobody is going to maintain your code period! And good performed efficient code is often easier to understand because you don’t need to ware through a layer of files and nested class hierarchies.
@NoOnesBCE
@NoOnesBCE 8 месяцев назад
I think of clean code as a grab bag of mostly good ideas for readability. But if you apply them all you get to an extreme where following the code becomes tedious. Also I love my gated code and will never give up multiple returns.
@christophergrow
@christophergrow Год назад
There is a value judgement going on here that the community went through long ago. Performance is important in KEY areas of the code. Instead of suggesting writing performant spaghetti maybe it would be a good idea to spend time with a profiler. There will always be certain critical pieces of code and at times taking some, well commented, shortcuts are warranted. Particularly inside of time consuming processing loops. However, most application have a lot of initialization, setup code, and teardown. Unless your building a game the user interface is usually not a contentious area for performance either. Building clean code may come with a performance hit but computers are so fast that its just not the problem its made out to be. If you make a jobs initialization 20% faster do you think anyone really cares? They care about the piece of code that processes the data. Having threads synchronize appropriately, is often another performance issue. If your program is spending much of its time waiting it may seem slow but no amount of fast code is going to fix this either. The only way out of this issue is a good design ( a profiler can help with this ). The other part of performance is using appropriate data structures. It doesn't matter what coding techniques you use, if you choose inappropriate data structures , you will create unjustified slow performance no matter how you code. Honestly, it seems like so many of these people have had interactions with code using inappropriate abstraction . This is a fixable problem that is much easier to deal with than other types of spaghetti. Honestly, these types of videos seem like they are written by people who never worked on large legacy projects. Projects where you can see the change in style over time. Project where you can see how no abstraction and spaghettis can get the software into serious architectural trouble. To summarize, if you want a good customer experience and fast responsive software this is barking up the wrong tree.
Год назад
Exactly my issue with many of the videos. It's either unfamiliarity with big, long lived projects and large teams or intentionally causing a stir for viewer engagement 😂
@boxacuva
@boxacuva Год назад
Hello guys Im stupid. In my codebase i need to draw 5 UML diagrams and 21 CodeMaps to change the colour of a Button. CC 4 ever.
@davideastman5806
@davideastman5806 Год назад
Over the years, people have talked about Clean Code for more hours than anyone has actually written Clean Code
@TheAces1979
@TheAces1979 Год назад
🤣🤣🤣
@ericbwertz
@ericbwertz Год назад
By Clean Code, you mean TDD, of course.
@a-yon_n
@a-yon_n Год назад
I think what we really need is clear code instead.
@bozzistef
@bozzistef 10 месяцев назад
@@ericbwertz
@TheSoulCrisis
@TheSoulCrisis 10 месяцев назад
So funny because we love the "idea" of it, but implementing is another matter entirely. I would say much of that is chalked up to the fact that just getting things working and making it efficient is far more prioritized over writing elegantly clean code and refactoring in general, some places rush you and don't even have the time to write tests before the code.
@cinister
@cinister Год назад
As many in the chat pointed out, the TF2 coconut JPG thing was a joke that people took seriously. TF2 RU-vidr shounic has a video explaining this, but the short answer is that while there is a coconut image in TF2’s files, it’s just part of an unused “coffee bean” particle and deleting it has no effect on the game’s stability.
@temper8281
@temper8281 Год назад
I was gonna say, because the source engine seems like a really bad example for "poor" code given the sheer number of games that have been used to make it and over such a long period. I'm sure it has pain points but it's no way near a good example of "bad"
@XeZrunner
@XeZrunner Год назад
@@temper8281 It's actually quite a "personalized" code base, from the perspective of Valve. I'd imagine many of the same programmers have been working on the games that were made with it, so they were probably quite familiar with its aspects. Source 2 is/was a great opportunity to rethink the codebase and it's starting to mature with Counter-Strike 2 and S&box now.
@scvnthorpe__
@scvnthorpe__ Год назад
@XeZrunner Valve are a passionate company and their tools are beloved but in general I'm not super happy w/ the code practices of the broader gaming industry Plus the work culture...
@MichaelPohoreski
@MichaelPohoreski Год назад
@@scvnthorpe__ Everything wrong with AAA gaming: * *2003:* _I used to go into a store to find a game,_ * *2023:* _Now I go into a game to find a store._
@simonkaran
@simonkaran Год назад
So basically a lava flow
@TRex-fu7bt
@TRex-fu7bt Год назад
The fast inverse square root is self contained in its own lil function so it’s pretty clean™️ and you don’t have to worry about the details until you have to.
@ahmad_alhallak
@ahmad_alhallak Год назад
Yeah that is what I was thinking, as the long the spaghetti code you are writing has a good reason to exist, as in the fast inverse square root function case, and as long as that spaghetti code doesn't intersect with other parts of the code/logic then no one should have any problems with it, Clean Code enthusiast or not. The problem, imo, is when the spaghetti code is responsible for branching logic/decision making and routing in the app. When that is the case, no performance considerations that leads to spaghetti code should be taken in account at all, as you will pay the price ten fold later on and be forced to change it anyway
@Aidiakapi
@Aidiakapi Год назад
​@@ahmad_alhallak It's not even spaghetti. It's straightforward, linear code, which is trivial to read and understand. What is not trivial is knowing why the answer is correct, which requires knowing how floating point types work, and how Newton's Method works. If you do not understand the mathematics behind it, it might seem like magic, but that goes for most math. If you saw Vec2_Dot(normal, point) > 0, you could understand the code for it, but you wouldn't know what it represents.
@MichaelPohoreski
@MichaelPohoreski Год назад
@@AidiakapiThe dot product returns the cosine of the angle between two unit vectors. It is assumed that anyone working with dot() > 0 knows that it represents the front facing side. The problem is that there should be a comment explaining the behavior for people _not_ familiar with it: * Output ranges between [-1 … +1] * < 0 back facing * = 0 orthogonal * > 0 front facing
@aaaabbbbbcccccc
@aaaabbbbbcccccc Год назад
Precisely. The fast inverse square root code is self-contained and while it isn't at all obvious how it works to the uninitiated, it is clear what it is *supposed* to do. Should you experience a bug in your rendering code and you suspect it might be that function, it's trivial to replace it with a more explicit implementation for debugging purposes. Should that replacement not resolve the bug, you know that your bug is elsewhere. This is exactly how you want code to work - as mutable. The simpler your code, the less restrictions you have to changing it, and changing code to sniff out a bug is a perfectly reasonable thing to do. It's just much, much harder to do with huge object hierarchies and abstractions.
@stevenhe3462
@stevenhe3462 Год назад
A pure function.
@taragnor
@taragnor Год назад
I don't see why this guy is criticizing the quake fast inverse square root. That's about as clean as it gets. It's a pure function that uses primitive data types. There's nothing to maintain there. Sure it's hard to understand, but from a maintenance PoV, it's literally one standalone function. Nothing else you change in your codebase will alter how it works.
@Smogne
@Smogne Год назад
Yea and it's not esoteric or anything. Just applies mathematical approximation using series to compute something much faster with an acceptable error margin. I had forgotten most of my mathematics from collage after I left it but even then, the first time I saw that function I knew it was an approximation, just didn't remember how it worked... it's more a case of the programmer not knowing the theory used in the code logic rather than the code being bad (as you said, it's far from it)... never skip math day on college kids :)
@Rumu11
@Rumu11 5 месяцев назад
I don't think the article is calling the fast inverse square root bad code, just calling it unreadable code. As argued in the article, performant over readable code should be used only in performance critical sections, like the fast inverse square root is being used in.
@kilisinovic
@kilisinovic 4 месяца назад
It's more of "if there's a bug in the system how sure can you be that it's not this piece of code?". Now after years of analysis and discussions it's pretty clear why that function works but imagine someone implementing magic like this to, for example, send the request to the server and you come to maintain it and have some error around communication with the server. The function might be doing exactly what it says and the error might be somewhere else but it'd take you ages to actually confirm that.
@taragnor
@taragnor 4 месяца назад
@@kilisinovic Not really. It's a pure function that takes a single argument that's calculating something mathematical for which there are already slower, but definitely correct, implementations for. So you can pretty easily just toss a battery of unit tests at the thing and compare the outputs to the slower but correct function to check for any unacceptable deviations. Generate a million random floats along with a few important specific numbers like 0, 1, and so forth , feed them to both functions, compare the two, calculating the average deviation, the maximum deviation from the correct answer and an array of the top 10 worst cases. That'll give you a great idea of how accurate it is.
@kilisinovic
@kilisinovic 4 месяца назад
@@taragnor that only makes you pretty confident but not 100% confident which is the point I was trying to make. What good does it do to check edge cases for numbers when you're doing shenanigans with bits. There may be none or there may be more than few numbers out there for which the function breaks but you can never be sure unless you really understand the logic and math behind the function or you examine the function for absolutely every use case.
@remirth_bergström
@remirth_bergström Год назад
I like how Brian Will described fine-grained encapsulation, "The princess is always in another castle."
@AlesNajmann
@AlesNajmann Год назад
Sounds to me like "The Legend of Zelda" in a nutshell 😆
@hck1bloodday
@hck1bloodday Год назад
is a refference to mario @@AlesNajmann
@litpath3633
@litpath3633 Год назад
Ah, that classic star wars episode with john luke picard
@styleisaweapon
@styleisaweapon 7 месяцев назад
need more quotes like this to get the point across
@pldcanfly
@pldcanfly Год назад
"Paying our developers less because they can do more work for the money is more important then the performance of our apps." .... And that's the reason why my multicore-n-ghz-smartphone lags the F out with displaying a 350px wide webpage, while my singlecore 900mhz Pentium in 2002 had no problem with that. I'm just happy that when I learned programming we had to learn to watch our resource-usage. Today everybody is like "ok let's import a 500kb library to concat 2 strings together. More time to *sips latte, writes blogpost about stuff.*" And then I am sitting here and people wonder how I can search fulltext through 5000 rows of data and respond in ms. Like ... that's not magic, I just don't burden myself with 300 frameworks and ALL the abstractions known to man in between just to tell SQL to do a where. And that code is still maintainable.... if something looks like magic, write a comment there on the why and what... done.
@SimonBuchanNz
@SimonBuchanNz Год назад
I'm infuriated! This is slander against programmers that drink lattes!
@PanosPitsi
@PanosPitsi Год назад
Haha this guy thinks 500kb of bloat is a lot, if he discovers electron he will go American psycho mode 🥶
@mage3690
@mage3690 Год назад
​@@PanosPitsime too. A 500 KB file to do WHAT? Does the library come with a tokenizer so I can use a special operator to concat?
@pldcanfly
@pldcanfly Год назад
@@PanosPitsi: Yeah... there is a reason I don't like that thing very much.
@fededevi1985
@fededevi1985 Год назад
It is even more funny when your multicore multi-ghz moder PC does not even does the heavy lifting of rendering the page now as all the actually heavy tasks are handled by a dedicated gpu :D
@anthonyparks505
@anthonyparks505 Год назад
I think it's wise here to take the good aspects and discard the bad. Writing a million 3-line helpers = bad. Giving things reasonable names and understanding how and when to use an interface = good. Writing shouldQueryIfConditionIsCorrect() to write something that could be expressed as a ternary conditional -> bad. Using enums and structs liberally with descriptive names instead of a million hardcoded constants = good. It helps to work in a codebase with very experienced colleagues who all of their own individual takes, that way you avoid any cargo culting of ideas from books.
@reed6514
@reed6514 10 месяцев назад
Well said. It's all context dependent & there's no one size fits all solution imo.
@Karnickel93
@Karnickel93 5 месяцев назад
@@reed6514 Yep, but how else should either side (clean coders or "code rebels") sell books/talks/workshops or make youtube videos, if all would take a more nuanced approach? /s Edit: Damn, I necro'd a comment thread
@fededevi1985
@fededevi1985 Год назад
WTF. The whole discussion makes no sense. Abstraction are there so you DON'T have to think about the lower levels. Any modern, even very low-level kind of programming lives on top of dozens of abstractions, microcodes, HALS, OSs apis, languages, languages stdls and multi level of libraries. Now you are using 20 levels of abstraction but 21 are too much?
@saikiranj807
@saikiranj807 Год назад
too much padding there isn't much meat in the article.
@ytdlgandalf
@ytdlgandalf Год назад
Abstractions should be discovered, not designed
@ooogabooga5111
@ooogabooga5111 Год назад
beautiful take
@kote.7269
@kote.7269 2 месяца назад
why this comment have so few likes, damn...
@gracjanchudziak4755
@gracjanchudziak4755 Месяц назад
I don't get it, what do you mean by discovered?
@raven-a
@raven-a Месяц назад
Java fucking sucks, that's all I'm gonna say... There's a cult of bad OOP out there and they are using exoteric JS "frameworks" nowadays because they can't really dominate back end programming anymore, because people just use whatever. They are the real enemy
@on-hv9co
@on-hv9co Год назад
One of my favorite Bjarne tips was "just use a vector"
@khatdubell
@khatdubell 9 месяцев назад
Yes. There is so much push back on this (pun not intended). Most people will never hit the theoretical performance characteristics of more advanced data structures. My personal saying: Never pessimize your code on purpose, but don't try to optimize it unless you prove a need.
@sealsharp
@sealsharp 2 месяца назад
​@@khatdubellthe pun is pretty good. Appreciate it.
@raven-a
@raven-a Месяц назад
Why vectors over list, someone care to enlighten me? I've got a Google interview in two weeks or so and I'm not doing this Lettcode crap 😂🎉
@faridguzman91
@faridguzman91 Год назад
simple and readable code is much more important to me that clean code, ive seen design patterns and uber atomized components escpecially react codebases that didnt make any sense to me and was very difficult to provide any value or build new features
@evancombs5159
@evancombs5159 Год назад
Clean Code should be simple code. If it is not simple it is not clean. If your definition of clean is adding complexity then you took the wrong things away from the book. With that said, I do not really blame people for taking away the wrong things from that book, the book doesn't do itself any favors.
@klurman
@klurman Год назад
Clean code is a set of guidelines. I don’t see why people are taking it as a all-in kind of thing. I don’t think Uncle Bob intended it to be either. I think in terms of performance, OOP is the real thing people have issue with. Sure, CC encourages the use of OOPs primary “benefits”, but I think that’s a result of being written for the majority of development developers do/were doing at the time. CC principles can still be applied to FP for instance. I also think that performance of any OOP or even any high level programming language is always going to be suboptimal. Frankly, if you truly need performance, ANY language other than assembly is going to have its cons. Performance is also not the same as memory usage, memory leaks are going to happen irrespective of CC or OOP. If anything, I’d say CC will help you to at least ensure you create abstractions that might be easier to find memory issues with. Smaller objects instead of larger objects should in theory improve memory usage - something CC encourages. I think people are putting the blame on CC unfairly… look at OOP and the programming languages themselves as the real “enemies” to performance.
@krux02
@krux02 Год назад
premature code cleaning is the root of all evil
@hamm8934
@hamm8934 Год назад
And not cleaning code early enough is the root of your startup shooting itself in the foot
@joranmulderij
@joranmulderij Год назад
This is so true
@anthonyparks505
@anthonyparks505 Год назад
seriously. instead of worrying if you're doing it "right", write that 50 line method and then take a second look. First attempt should always just 'get shit working' because half the time you might not know exactly what's entailed. Once you see that on the page it may be easier to recognize if there is a pattern and its worth a refactor.
@MichaelPohoreski
@MichaelPohoreski Год назад
@@anthonyparks505Indeed. Get a _slow reference version working first_ because it *doesn’t matter how fast you get the wrong answer.* By then you’ll have a deeper understanding of the problem to write a good solution. It is almost as if everyone forgets _The Mythical Man-Month’s_ advice. *Plan to throw one away, you will anyways.* Who knew prototyping was an old concept! /s
@Elrog3
@Elrog3 Год назад
So there was no evil in the world before we invented computers and started programming them. Got it.
@eqprog
@eqprog Год назад
The bit at the end about refactoring something and arriving at the same conclusion as the original programmer is a trap I’ve fallen into several times. At this point I’ve learned that if I see some code that on its face seems just extremely WEIRD that there almost always is a reason. Sometimes I don’t always arrive at the same conclusion but I’ll understand the original reasoning more. Honestly it’s helped me get my ego in check, too.
@jorgamund07
@jorgamund07 Год назад
Yep. My current rule is, unless there's a comment in the file saying "clean this up later", I leave mystery code alone.
@robonator2945
@robonator2945 Год назад
it's hilarious to me just how frequently people have to re-discover concepts that have been around for decades just because they're not directly applicable knowledge that actually gets taught. It would take 1 class period to teach the concept of Chesterson's Fence to people in 5th grade and solve at least 23% of the world's problems.
@adriankal
@adriankal Год назад
Those places in code must be well documented. If you use hack then add comment above it to indicate that it's a hack. XXX is for that.
@karnadipa
@karnadipa Год назад
I have this experience with my own code 😅. I look at my code and think I make a mistake and change it and then I remember the reason why I code it weirdly.
@Yay295
@Yay295 Год назад
The good thing is now that you understand the code, you can leave comments explaining it.
@JosifovGjorgi
@JosifovGjorgi Год назад
I don't care about Clean Code or how applications are build as long as they are performant I will be very happy if Microsoft send to me (free of charge) workstation PC - AMD Threadripper Pro 64 code, 2 TB RAM, 8TB Raid0 card and 3 GPUs to run their slow applications, because Microsoft thinks electron is modern tech
@rusi6219
@rusi6219 2 месяца назад
Yes many of those software companies have zero respect for their customers' resources
@ErazerPT
@ErazerPT Год назад
Clean code was a GOAL. Clean Code (capital) is the religion. Not in any way different from the "Manifesto for Agile Software Development" goals vs Agile. It's always a process from where you take something that has good intentions and turn it into a clusterfsck of dogmas and rituals and ceremonies. Some more cynical people might say that it happens because you can't capitalize good intentions, but you sure can turn "the clusterfsck" into a set of books, courses, talks, etc... Maybe what you need is just an "utilitarian" version of it all. Pragmatic CC, Pragmatic Agile, etc... The pragmatic part being "does it make sense?", "do we need it?", "have we gone too far of the deep end?", etc... At my place we have a running joke about a certain component that we refer to as "the best hammer ever". It can hammer in any nail under any conditions. Only about 15% of it's potential has ever been needed/used. Nobody truly greps to the full extent how it works. As a testament to the skill of the creator, it's rock solid and never fails. And thank god, because everyone that ever went through it in debug had to resort to some alcohol fueled "therapy" after. We just marked it DontTouchJustWorksTM because it does, and we always "Step through" never "Step into" ;)
@rintaun
@rintaun Год назад
As a Pastafarian, I find all this discussion of Clean Code very upsetting. All of my code is spaghetti code.
@sqeaky8190
@sqeaky8190 Год назад
I don't understand this whole mindset of "With pattern X I can't keep the whole problem in my head", the point of patterns is that you don't need to keep it in your head anymore. With a good pattern instead of specific memory layouts, index ordering, specific formulae, or whatever specific details a coder can now write to a contract. If the abstraction isn't providing a contract then it is a bad abstraction, If the abstraction is providing a bad contract for the situation then another could be better, if the programmer is constantly trying to pierce a good abstraction maybe they are just doing it wrong.
@channel_channelson
@channel_channelson 20 дней назад
Real communism has never been tried.
@anj000
@anj000 Год назад
2:50 I will never be tired of you talking about this. I was hesitant to start coding seriously for like 10 years because I thought that since I can't hold so much in my head that means I'm bad software engineer and I don't belong there.
@jordixboy
@jordixboy Год назад
You cant be pragmatic and at the same time put abstractions everywhere for no reason just because "in the future we might need a different implementation"
@rzabcio3
@rzabcio3 Год назад
But... if one needs to jump even once to understand what code does it's NOT clean code anymore IMHO. What you've described in this part were design patterns (and typical for Java inheritance overload) and that is completely different than clean code principles.
@diskpoppy
@diskpoppy Год назад
18:21 "Parts of apps that need of performance" - Casey also debunked the whole "you just need to optimize the hot spots" argument. You can only do so much without completely refactoring or even rewriting the whole application.
@phazechange3345
@phazechange3345 Год назад
Highly abstracted code necessarily cannot deliver features faster unless every single feature request lives at the edge of your codebase. Good luck when a regulatory change swings by that none of your abstractions deals with. You cannot predict the future. Don't pretend you can with Clean Code ^TM. Abstractions are NOT extensible. >Reduce Developer time How in the world does writing abstraction on top of abstraction on top of abstraction in Clean Code ^TM result in "lower development time" over just writing the code that needs to be written? That makes zero sense. I would like for a Clean Code ^TM advocate to actually measure these absurd claims.
@khatdubell
@khatdubell 9 месяцев назад
Prime's take on this implies its impossible to both have a good architecture _and_ follow clean code principals. I don't recall any clean code principals telling you to pick shitty architecture. As a matter of fact, IIRC one of the very first things you see in the book in the saying "every programming problem can be solved with another layer of abstraction........except having too many layers of abstraction" Which, while cheeky, is clearly telling you not to go to the insane lengths of abstraction that prime is talking about here. that would be like dismissing all of functional programming because people are currying, or something, too much to the point where the code is hard to understand
@nchomey
@nchomey Год назад
Prime, I think you've said you like procedural code as opposed to object oriented. It would be cool if you could do a video expanding upon that!
@haraldbackfisch1981
@haraldbackfisch1981 Год назад
R u sure he said that,bc it wouldn't make much sense since the two are not exclusive or even competing. OO and functional are. Procedural just refers to a more let's say exploratory way to code as opposed to TDD or something with a lot of organizational overhead
@serhiipylypenko
@serhiipylypenko Год назад
@@haraldbackfisch1981yes he did say that many times
@haraldbackfisch1981
@haraldbackfisch1981 Год назад
@@serhiipylypenko that he prefers procedural over OOP?
@nchomey
@nchomey Год назад
@@haraldbackfisch1981 yes I think he has. Regardless, it would be an interesting topic for a video. What the differences are, when to use one or the other, different strategies, etc
@NoX-512
@NoX-512 Год назад
@@nchomeyThe answer is simple. Don’t do OOP (inheritance and polymorphism) unless you are forced to by the code base you are working on. Encapsulation is a good principle and not specifically OOP. If you have the chance, write as much code as possible in non-OOP languages as you can, e.g. Zig and Odin. It will force you to think in procedural/data oriented patterns rather than OOP. If you do it properly, you will find that your code becomes easier to read and maintain.
@emptystuff1593
@emptystuff1593 Год назад
People don't even understand what a Cartesian product is... So you had a product with something like 25 customizable items (color, texture, etc.) and each item had between 10 and 50 options. Some options are not compatible. For example, you cannot get the pink color with the wood texture. There was a function to select the first viable combination. Said function was stupid and would compute a large part of the Cartesian product before finishing. I estimated that it would complete after about 150 years... I extracted the responsibility of computing the Cartesian product in a separate function (and optimized it to discard non-viable combinations before computing the whole combination). In that new function, I used the lexical field of a Cartesian product, as this function sole responsibility was computing the Cartesian product... The developer that owned the module asked me to rename all variables to match the business domain, because he didn't understand what a Cartesian product was. So I cannot imagine the average developer to properly understand the abstractions from the GoF...
@dadbod591
@dadbod591 Год назад
one aspect of the constant striving for perfect, clean code that gets overlooked is the impact on developer morale. especially when you know that when you open a PR it's just going to get trashed by someone who gets a high off making others write overengineered code. I see a lot of junior engineers lose so much confidence and their performance slows to a halt because of practices like this
@etodemerzel2627
@etodemerzel2627 Год назад
This is a very good point. I find it very draining to have to respond to or follow the requests of my bureaucracy-loving colleagues.
@tarquin161234
@tarquin161234 Месяц назад
Yes any senior devs reading this need to realise that if they want to keep their staff they should allow others as much freedom as possible because otherwise you will take away the biggest joy of programming and make people resentful
@Tychosvideos
@Tychosvideos Год назад
Working with Clean code™ gives me brain damage. I'd much rather work with code that was structured to do its purpose in a way that makes sense.
@Daniel_WR_Hart
@Daniel_WR_Hart Год назад
Here's my hot take: Get good at planning ahead AND learn how to type fast. There's no reason to pick one or the other unless you're physically unable to.
@cronnosli
@cronnosli Год назад
Martin Flowers itself already explained that not all code need to be clean. And that no programmer, even himself write clean code. First you write code that works. Then you clean it, that leaves you with parts of the code that must need to be very effective, just stay that way, in those cases it is ok to leave a comment just explaining what you did. Another point is that Clean code does not mean SOLID. What clean code stand is that the code must be readable(Understandable), and that could change from company to company, team to team. Regarding abstraction, clean code just say that you shouldn't mix levels of abstraction. Levels of abstraction refer to how directly or indirectly code communicates its purpose, it has nothing to do with class abstraction principles or best practices in this context. Clean code does not means slow code. If someone is saying that, then this person didn't understood clean code. Martin argues that writing clean code is crucial for long-term maintainability and that performance should generally be a secondary concern in the initial stages of development. Make it work, make it right, make it fast! (Kent Beck). Performance first can lead to birty and bad code. This is not talking about writing slow code. Instead Martin Flowers says that poorly written code can generally lead to bad performance code. it's hard to identify bottlenecks and implement effective optimizations. On the other hand, well-structured, clean code makes it easier to profile and optimize because you can more clearly understand the code's behavior. Especially in systems with strict performance constraints. Even in these cases, however, the code should be as clean as possible to facilitate understanding and future changes. But that there are situations that require careful attention to performance from the beginning I think that people who attack clean code just don't understood what it is or just read the cover page of the book!
@MrWorshipMe
@MrWorshipMe Год назад
Your code should be easily testable. If you can achieve it without "clean code", do it. There's a great talk called "Clean Coders Hate What Happens to Your Code When You Use These enterprise programming tricks" by Kevlin Henney, I think he's criticizing "clean code" the way you mean it (and many enterprise programmers to).
@erickmoya1401
@erickmoya1401 Год назад
I agree. But of course not with "clean code" trademark. Thats shit code.
@Htarlov
@Htarlov Год назад
I believe it comes down to the priorities of the project or of the company. There are several things to consider that can have very different priorities depending on the company: 1) Performance. It might be of a very high concern if you build a game that needs that top-notch performance and wow effect (not all games are like that) or data processing that need to process terabytes of data in short time to create reports. It might be low priority if you build a JS for a web page, it is not about animations, and nanoseconds vs miliseconds doesn't matter. It might be very low priority if you write a script to process a low amount of images or data and it does not matter if it will be done in seconds or minutes. 2) Time to market. It might matter if you either build a thing and run a campaign or loose client(s) or if you either build something in time or other company will start sooner with similar service. It might be even matter of life or death for a startup in bad position. Also, a startup might be not in a good negotiating position with a big company requesting needed changes asap, or the opportunity is gone. On the other hand, if you have working reputable product and only work on enhancements, time to market won't matter. 3) Budget. You might have some budget and either you can cancel project or try to finish it without sufficient funds to do it very well. Happens pretty often in startups with investors. 4) Maintainability, quality of code, developer experience. May be a top concern for a long-run strategy. May be not if your company just tries not to drown and needs to change fast and cheap or die. 5) User experience. Usually it is very important, but might be moved to the back seat if other considerations are deemed more important. a) critical - so if that thing is even usable at all (might be not important at all for example in early PoC projects, usually top importance) b) normal - so if that thing is easy and nice to use for typical use cases I currently work in projects where it is something in this order 5a, 2, 3, 5b, 4, 1 (working startup) or 3, 2, 1, 5a (PoC projects). This means that there is a lot of rather bad code. It is not totally unmaintainable, but it is also very away from SOLID or clean code. We rarely have time to refactorize. There are also these smaller PoC subprojects that we do - there we don't take any considerations about code maintainability. We make quick scripts with code from github and GPT, stich it together and try if it works or not. If it works and project is accepted to go further, we rebuild a production version with a bit different approach (with better architecture and code), taking only some parts of PoC. I worked in projects with priorities like 5a, 5b, 4, 1, 3, 2 which were into quality. Mostly quality for enduser or client, then quality of code (but nearly on same level as usually those are corellated). This dictated totally different approach. Same person working, different projects, different decissions - both about the general architecture and code. And it is not like I evolved or rather de-evolved. I know more about how to write good quality code now than I knew back when I worked in projects which were very into the quality of code. I feel it is more like a thing dictated by the business circumstances of the projects rather than decission based on taste and knowledge. I did not work on games, but I think that in games it is most usually 5a, 1, 5b, 2, 3, 4 with 2 sometimes going up the ladder when deadline is near. They need to make game playable, make wow effects, make it to the market quick enough / on time. This dictates even different approach. Another thing is that you can overdo any of these things and make matters worse. 1) You can overdo performance and loose quality in other areas. Like your code runs fast, but results are less precise or it is too fast for the user or controlling process. 2) You can overdo time to market and add features faster than users can grasp and accomodate to the changes. It can be seen in some mobile games - they grow fast into having too many options, many with some currency/payments attached. Gets overwhelming, especially for new players. 3) Budget. Sometimes cheapest option is to take a ready code or services from the internet... and then you get locked in with it and have hard time changing things or changing provider etc. Something might be cheapest in short to middle run, but not cheap in the long run if you count cost of adaptation. 4) Maintainability. There is problem how to measure maintainability directly and we really have only some approximations like less repeating is usually more maintainable, single responsibility is usually more maintainable, more abstractions is often more maintainable. Can easly go too far with those proxy measures and get code that is actually less maintainable and harder to grasp. Also, like stated in the video, can loose on performance or user experience. 5) User experience. You can add a lot of complexity trying to have best user experience possible. You can also fall into a trap of thinking that something very usable for you will be also usable for endusers. You then can make a some custom thing instead of relying on proven typical solutions. It is hard to think like someone else or like general target group. A/B testing is here to help of course.
@Nightlurk
@Nightlurk 5 месяцев назад
Every CPU cycle you waste is a tiny bit of energy thrown away. Making your system 20 times slower means making the entire energy consumption of your service 20 times higher (at least, if you don't factor in costs required for cooling your hardware too). So if you're a company that cares about the environment and your carbon footprint, you should start by educating your developers on how to put performance first, ahead of their egos.
@Malikazz
@Malikazz Год назад
CC apologists always argue looking for nano seconds of perf is silly, but in reality I find we are often talking about 400ms per request vs 4ms. And when your que app has hundreds of requests or thousands per sec it starts to mater almost instantly. CC is an excuse used to explain bad code, it could be clean and fast its just easier to explain your bad code as clean code.
@alsto8298
@alsto8298 7 месяцев назад
Wow, you are referring the video where man, who does not understand basics of programming are trying to say that CC is bad.... and you call it a good one... maybe try to think first?... Ill explain some basics so you can follow on by yourself: 1. A man rated 5 statements (poly, incaps etc) but they go down to two (poly vs if and compute vs table data). 2. He was wrong in poly vs table data: finding function by poly is following link therefore it is O(1), when if is O(N) - so he basically lied about performance gain. 3. Precomputed values are obviously faster than computing it but it is not mutually exclusive in CC - so he basically lied about performance gain. And that's it - all his statements are a lie. Next time, try to think before referring to such clowns.
@robbie_
@robbie_ 5 месяцев назад
I never had a problem with Carmack's sqrt. I always thought it was kind-of interesting. It's precisely the kind of thing you'd want to optimise. In my own job recently I first wrote, tested and profiled "clean code". Then I identified areas where significant improvement could be made with AVX2 and then I implemented that code path as a compile-time switch. That code is less clean and less easy to understand but the "clean" version is also there in the file right next to it so you can see what the intention is. The AVX2 code is 7 x faster!
@tupak29
@tupak29 Год назад
Going for extremes is almost always not a good idea. Being an extreme "clean coder" just makes things less readable for others who are "less clean coders" than you. But we all have to agree that cleaning the code to some degree makes the code more readable and not less. We can apply some of the rules of Clean Code when they fit well while not be very dogmatic about the other ones... Just take the middle path, care for the code so that it stays as readable as possible without sacrificing too much performance and you'll be fine. The middle path is very often my path when I approach different ways of looking at problems in life.
@allalphazerobeta8643
@allalphazerobeta8643 Год назад
I feel like a lot of it is. Well, don't go for performance if don't have. but maybe you should keep some eye on performance, but then again sometimes performance is paramount. This doesn't really say anything, here's an idea, think about your design constraints and goals, and use your best judgement.
@darak2
@darak2 9 месяцев назад
I wonder when we started to program abstractions instead of machines. We've lost it. The computer is a simple machine that expends resources in order to transform data, if there is a way to do the same transform while using less resources, that should be the default. If there are ways to expend less resources with different tradeoffs, those should be exposed. If those options are harder to implement or read, or make future portability or maintenance difficult, the problem is in our tools.
@tullochgorum6323
@tullochgorum6323 Год назад
I recently tried to read a project that was presented as an exemplar of clean code. It has literally hundreds of classes for a relatively simple web project. I found it franky impossible to understand what the bloody thing was doing. The cognitive overhead was overwhelming.
@godeketime
@godeketime Год назад
Clean Code is Taylorism (the practices that lead to factory productivity) for software. For small teams or companies following service design with lots of small teams collaborating, it doesn't make *any* sense, just as it doesn't make sense to make an assembly line for one guy to run back and forth along, trying to get the work done. The context it was *supposed* to work was one where you have a large team where a programmer was just working the "widget X" station of the assembly line. However, it turns out that code isn't *not* an assembly line, even if we make 5 layers (assembly line stations). Lower case "clean code" on the other hand (writing code that isn't obfuscated) is worth fighting for.
@estranhokonsta
@estranhokonsta Год назад
Creating functions is making abstractions. So there is no conflict here. Doing abstractions is what programming is about. As you said doing abstractions correctly: "... put 15 functions in that file do that until you kind of hit that point where you're feeling I'm a little frustrated with my code..." It is the basic step by step process of creating and knowing your code as you create it. Even Uncle Bob say exactly the same thing in his clean code whatever. He even goes long on the problems of trying to abstract too early when we have the illusion that we understand the problem before even having written any code. It is just some principles based on pragmatic experience and the SRP and other wannabe principles are just some vocabulary about the structure of codes. You take what you want from it and do what you want with it. As needed. I think the problem is that the so called "clean code" that you saw were done by people who didn't understand clean code. They were maybe more old school Java programmers who like to abstract things just for the cheap feeling of it than for the need of code. That means that those were not clean code. A code with to much abstraction is dirty code, not anything else. Code as you wish and abstract as you need. That is clean code. Understanding the vocabulary and the principles is just like the design patterns. Only low quality programmers would say that those should be done exactly the same for every problems.
@keyboard_g
@keyboard_g Год назад
This boils down to a developer should know what the code they write actually does. Theories of “clean code” are a guideline, not biblical rules to be blindly followed. All this back and forth debate noise is circle jerking over semantics. Write a lot of code in different styles and you will see what is best.
@mrbutish
@mrbutish Месяц назад
It's a tragedy as a Java developer to run to the array. A bloom filter on a set will be much faster on whether the set contains something or not and cleaner.
@agatasoda
@agatasoda Год назад
Check out the video: How NASA writes spaceproof code.(Mde by Low Level Learning!) You'll have a good time!
@luizfernandonoschang8298
@luizfernandonoschang8298 5 месяцев назад
I always prioritize writing clean and readable code first as this will make it much easier for you and your team to debug. Most applications don't need the performance gain. You see, it doesn't make difference for the final user if he will get the answer 1ms or 1 second after clicking the button. But it makes difference for the user if you'll solve a bug in 1 hour or 1 week. There are specific scenarios where the performance will make a difference and we only should spend effort on those specific scenarios. Games, complex reports and highly concurrent applications/features are an example. Even so, you still can write good and fast code, you don't need to trade one for another always. Equilibrium is the key for everything in life. Try writing readable code from the beginning but allow yourself to write worse code if necessary.
@NoX-512
@NoX-512 Год назад
I prefer my code to be dirty AF.
@R4ngeR4pidz
@R4ngeR4pidz Год назад
I definitely think you're right about the "typing fast allows you to explore more", there is only so much you can figure out from reading the code and looking at the involved systems Once you make the change you increasingly get more context of the problem and might figure out that the approach isn't correct, has unforeseen side-effects etc..
@banatibor83
@banatibor83 Год назад
Total bullshit. How much code you have to write for exploring something? Maybe a 1000 lines. Not your typing speed will be your greatest obstacle.
@michaelzomsuv3631
@michaelzomsuv3631 Год назад
Why do I feel like this article is written by yet another person who doesn't have a single clue what he's talking about?
@robertochostakovis
@robertochostakovis 11 месяцев назад
"If you hire ten developers to solve the same problem, you will have eleven different solutions!" That's the real problem! Software is the creative expression of how a person thinks, how they interpret the world and the context around them. As you create abstractions, abstractions of abstractions, it will be a nightmare to maintain something that, theoretically, should be simple!
@sploders1019
@sploders1019 8 месяцев назад
I’d be interested to see some examples of “clean code” vs something you’d write. I hear this argument all the time and leave very confused. Abstractions are supposed to separate concerns, and I find that they help significantly because I also have trouble keeping that much state, but with abstractions, I don’t have to worry about implementation details when I intuitively know what something should do, unless it’s not working properly, in which case I can test it on its own. I’m wondering if there might be a disconnect due to my lack of diverse experience
@jonmartintx1
@jonmartintx1 4 месяца назад
I think maybe there’s a bit of conflation here. “Clean Code” isn’t a monolithic standard. When I advocate for it at my work, I’m advocating for code that is *more* SOLID. But mostly it’s that I want to be able to look at someone else’s code and quickly understand what they are doing. Part of that is naming variables clearly - not using “x” “_x” and “__x” as variable names within the same scope. Part of it is inverting some if statements to reduce nesting. Some of it is using standard or accepted code styles and design patterns. I’m sure another dev could have higher standards and want everything tucked away under 10 levels of abstraction. I get that. And I get how hyper meticulous adherence to SOLID principles and design patterns can leave a sour taste and spoil the idea of “Clean Code”. But just like a customer may not always ask for the right thing, or they may use vague language to describe a problem, there’s an underlying “need” that I want addressed when I say I want clean code. That need is for extensibility, stability and maintainability in the codebase. The tricky part is how we can come to agree as a team on what that standard should be because it’s ultimately subjective. The guy that writes sloppy spaghetti code with single letter variables and 6,000 lines in a method may still be able to quickly find things in his own code and that system may work for him, but other devs are in for a tough time if they have to touch that code.
@tarquin161234
@tarquin161234 Месяц назад
Doesn't matter if the sloppy guy can read his own code. The code writer always knows his code intimately, no matter how bad, for a few months at least. As you're getting at,, the objective is making the code readable for other people.
@relhimp
@relhimp Год назад
> Disregard algorithm - use an array Yes, but no. I mean, it's nice to have underlying array for your octree instead of crapload of linked lists. BUT! First I need to have octree if 3D spatial mapping implied. And that's mean you've chosen right algorithm. Can array hold BST? Sure. That, If you know it's optimal data structure to store your open set for A* search over your octree. So. Get the best algorithm. And then do it with array.
@taragnor
@taragnor Год назад
"Just use an array" can work well anytime the data set is small, because often times even an inefficient algorithm will still work okay with the benefit of cache locality that you get from an array, but once you deal with any kind of large data set the strength of the algorithm becomes paramount.
@mrnotpewdiepie8957
@mrnotpewdiepie8957 Год назад
Oh, I like planning ahead. I dont like it when I implemented it and it turns out I can throw away 80%, make it eaier and do it in another way because of that single edge case that shows up when I'm almost finished... But I still like to plan ahead XD
@RandomGeometryDashStuff
@RandomGeometryDashStuff Год назад
02:14 yes, that's why webpacked and minified js is sometimes more readable for me that many js files (having access to both many js files and webpacked and minified js is still always better)
@joshuaworman4022
@joshuaworman4022 Год назад
"it's also scattered around for my l1 and l2" right? that is my biggest problem with oot is when you read it it's hard to mentalize what's even going on.
@u9vata
@u9vata Год назад
I agree: I saw "extremely clear code style" systems that are very-very hard to navigate because everything is spread around extremely... The most clean code thing I hate is the "cannot have more then 3 line functions" like rules... My friend worked in a project that had not just mediator patterns for example - but "InterMediator" patterns that mediate between the mediators and that kind of overbloat :D Also this guy seems to have not heard that Casey do not mean all people should optimize: just not pessimize like crazy. Also there are countless other ways of doing software than inheritance based virtual polymorphism... Not just static dispatch, but many ways to do things that are both maintanable and much better performing. Also the guy went from gamedev to non-game-dev and guess what they have easier bugs? Maybe not because clean code, but because gamedev is 10x more complex....
@williamdrum9899
@williamdrum9899 Год назад
Non gamedev code doesn't have to be efficient
@u9vata
@u9vata Год назад
@@williamdrum9899Total bullshit. Especially when battery usage on mobile devices come into question, anything embedded, powertools, all kinds of tools - and generally very few software are there which should be totally pessimised for no performance... And then if you run anything on cloud you pay very high price for wasted compute in bills too...
@williamdrum9899
@williamdrum9899 Год назад
@@u9vata Ok, not as efficient.
@etodemerzel2627
@etodemerzel2627 Год назад
@@williamdrum9899 Nonsense. I'm working on a project that's only used internally by 10-15 business people. You'd think that for a project like that, the performance wouldn't matter at all. But no, the users are complaining about the performance and have even given me the green light to improve it.
@hck1bloodday
@hck1bloodday Год назад
3 line functions? thats seriously, a BS rule, but again, as the book said don't need to be dogmatic, my personal rule is a function should not need a scroll bar to see it fully, if you have to scroll, you have to refactor. again, that's for functions or methods, not classes
@SufianBabri
@SufianBabri Год назад
Hi Prime. Good video and I get what you mean how a "Clean Code" makes it difficult for you to understand what exactly goes in the flow. And this is okay because one doesn't need to read 100% of the code most of the time. It is similar to the fact that we don't read every single line of a newspaper.; we skim through the headlines (function names) before we decide what article (the function body) to read. In Clean Code, you don't get function calls like `array.holyHandGrenade(index)`. So there is no point in reading every single function body if it doesn't seem relevant. If you're talking about the Clean Architecture, that's a separate story. AFAIK, the motive behind this architecture isn't writing a Clean Code but making yourself independent of the tools and frameworks (as Uncle Bob puts it, you can swap out the dummy database with a proper DB, etc. That is, you only need to rewrite a single layer of your codebase to replace your ReactJS app with a SolidJS app).
@tarquin161234
@tarquin161234 Месяц назад
In my experience, you never do just "skim through the headlines" though, because when you're examining code, method names are generally insufficient to fully describe the contents, and more often than not are named poorly. Furthermore these methods are often thoughtlessly partitioned, with inter-dependencies, which is a big no. I find it annoying and disruptive to have to keep navigating to definitions. For these reasons, I think it is simpler and safer to just write monolithic long procedures. KISS is generally all you need. As for your clean architecture example: that just seems like typical premature over-engineering. KISS.
@SufianBabri
@SufianBabri Месяц назад
@@tarquin161234 the reason is that you have only dealt with poor quality code. When reading a clean code, you can bet your life that a printUserInfo is not going to increment the user's age. What you described is exactly what a clean and structured code will help you avoid.
@channel_channelson
@channel_channelson 20 дней назад
@@SufianBabri Exactly, listen to this guy, real communism has never been tried.
@ifeoraokechukwu1346
@ifeoraokechukwu1346 Год назад
Here's my humble take on the matter: Clean Code is not a holy grail. I have read all 17 chapters of the book; It contains very good takes on good, testable and readable software development. However, it also contains bad takes too especially: "Chapter 3: Functions". Much of the things in that chapter should not be adhered to at all. Functions can be too small and can also be too Large. I like the idea of the Locality of Behaviour and organizing files and folders by feature rather than by type better. Having multiple layers of abstraction that don't serve the purpose of encapsulating complexity such that one doesn't need to go source-diving to figure out what is happening is also not a good idea too. In addition to Locality of Behaviour, you need behavioral transparency to a certain extent too. Again. one cannot achieve this behavioral transparency without also taking a minute to name things well. Also, I disagree with the HTMX essay that says Locality of Behaviour doesn't agree with ideas like Don't Repeat Yourself (DRY), or Separation of Concerns. I don't know where they got that from
@0xCAFEF00D
@0xCAFEF00D Год назад
2:00 Already I think he's missing the point of the video already which was that the code becomes unmanagable. It's like they watched through the first two examples maybe and stopped there. Polymoprhism is by far the smallest part of the video and the least controversial I'd say. Everyone knows vtable lookups are slow and that it obviously prevents any form of vectorization. But the parts that really stood out to me is how damaging the other rules are. The DRY especially.
@-Jason-L
@-Jason-L Год назад
Dry is mental masterbation
@marcusrehn6915
@marcusrehn6915 Год назад
Clean code is just horrendous amounts of indirection.
@harleyspeedthrust4013
@harleyspeedthrust4013 10 месяцев назад
good points about following the team's practices. it was hard for me at first but i learned to slow down and see the reasons for things in the code that made no sense to me at first. the best thing is to read a lot more code than you write, and put yourself in the minds of the people who came before you
@FrenchyMcToast
@FrenchyMcToast Год назад
He always highlights everything except the first and last letter.
@jeffsteyn7174
@jeffsteyn7174 Год назад
My first c# sharp gig. Simple app had about 7 layers of abstraction. Coming from classic asp, I was lost.
@UNgineering
@UNgineering 8 месяцев назад
You did the best summary at the end: "do what the team does". If you're a performance junkie trying to squeeze extra cycles out of your react component in a "Clean Code" team building the next facebook, everyone will hate you. If you're a Clean Coder working on ethernet controller firmware team, abstracting everything, everyone will hate you. Collaboration > dogma.
@snek_john_titor
@snek_john_titor Год назад
Clean code is simple code, everything else is more or less garage
@Rin-qj7zt
@Rin-qj7zt Год назад
you can't keep track when you extract stuff? weird from my perspective because extraction is how i organize things. when a function grows to a certain point, it just gets easier to chop it up so that it functions more like a library, where i can simply click on function calls to go to the part of the code i'm examining, with good names that describe the purpose of the specific section so i can see the entire thing all at once. i guess it's how you use the tool that matters. perhaps our problems are different too.
@etodemerzel2627
@etodemerzel2627 Год назад
But do you split your big functions into a bunch of 3-line functions?
@cronnosli
@cronnosli Год назад
I think that 98% of Software Engineers are not engineers but just glorified developers! If a Engineer is not good at abstracting thinks, than it is not a good engineer!
@mulllhausen
@mulllhausen День назад
10:22 Just put doom's inverse square code in its own function. Quick_Inverse_square() and it becomes clean...
@Felipe-bi3mk
@Felipe-bi3mk Год назад
DDD has much much higher correlation to maintainability than clean code. Probably the good code bases Prime was talking about had DDD
@salvatoreshiggerino6810
@salvatoreshiggerino6810 Год назад
I think many if not most projects take major Ls from not optimizing enough at the requirements level, before writing any code or planning any architecture. There's nothing faster and cleaner than not having the code in the first place, so if you can find a way to do less and still have a good business outcome, you'll do better in every metric. Go back and read The Rise of Worse is Better every time you want to start a project or do something clever.
@ytano5782
@ytano5782 7 дней назад
I develop control algorithms for embedded systems. Everything is highly optimized but it is readable and sustainable. The drawback is, you need a reasonable skill level in C++.
@BeamMonsterZeus
@BeamMonsterZeus Год назад
I know it's what no content creator alive wants to accept, but things like Twitter or FB are poor examples to use for those not using those platforms. The NPCs don't speak for me.
@P-39_Airacobra
@P-39_Airacobra 3 месяца назад
Good code is simple, fast code is simple. Simple.
@Rockem1234
@Rockem1234 8 месяцев назад
I don’t think people understand what clean code is. It should make your code clearer and easier to maintain for you and your team. Even uncle bob doing things differently every time
Далее
The Perfect Programming Language
23:50
Просмотров 385 тыс.
КАК БОМЖУ ЗАРАБОТАТЬ НА ТАЧКУ
1:36:32
Why I Quit Netflix
7:11
Просмотров 509 тыс.
Hacker News Triggered By NeoVim
41:07
Просмотров 139 тыс.
Dear Functional Bros | Prime Reacts
26:03
Просмотров 224 тыс.
Stop Creating Microservices | Prime Reacts
33:35
Просмотров 240 тыс.
Clean Code : Horrible Performance | Full Interview
47:13
Have We Forgotten How To Program?? | Prime Reacts
22:53
Prime Reacts: The Flaws of Inheritance
29:05
Просмотров 351 тыс.
Being Competent With Coding Is More Fun
11:13
Просмотров 82 тыс.
How Senior Programmers ACTUALLY Write Code
13:37
Просмотров 1,5 млн
Why Would Anyone Hate TDD? | Prime Reacts
46:52
Просмотров 149 тыс.