Premature Optimization
12:39
Жыл бұрын
Don't Write Comments
5:55
Жыл бұрын
The Flaws of Inheritance
10:01
Жыл бұрын
Why You Shouldn't Nest Your Code
8:30
Naming Things in Code
7:25
Жыл бұрын
Пікірлер
@Weeb1367
@Weeb1367 22 сағат бұрын
Remembering C# absolutely fisting me over implementation of interface Character after I decided foolishly to change it to abstract class made me realise how much I want to know if I'm using an interface or a class...
@nonR-wf3iq
@nonR-wf3iq Күн бұрын
yea... that's a nope. utopian ideal. comments are super useful even when code is very clean. it has uses beyond describing code. in large production codebases it's not going to matter how self-evident a highly refactored part of the code is, you want to minimize human confusion and effort spent later teaching or correcting usage by new hires etc. if you are working on smaller codebases it also contributes to formal documentation efforts and human approach to code. they can serve as warnings about pitfalls that code doesn't currently demonstrate properly, and they can also genuinely make your own projects or small collaborations more fun to develop, because there's a clear voice and social aspect to it. good commenting is mostly instructive. what i would recommend is to get rid of comments that are making code LESS readable, and those cases are really quite obvious when you run across them. rather than suggesting we should not write comments, i'd try to touch the ground and suggest a pattern of commenting that engages you in such a way that you clean the code as a result of the comment and then more often than not will also end up getting rid of most comments, i think that's much more realistic.
@AllenLantz
@AllenLantz Күн бұрын
1:30 i had a colleague take this too far and used "identifier" instead "id" would actually write "const postIdentifier ="
@NickHodges
@NickHodges Күн бұрын
This is an outstanding video.
@alek2341
@alek2341 Күн бұрын
Why is it all or nothing? You can make pure functions in OOP and vice versa. The right tool for the right job, not fn( fn( fn( fn( return; for everything.
@edgeeffect
@edgeeffect Күн бұрын
Comments are useful when they explain WHY rather than WHAT. Like, if you've done some horrible hack to get round a nightmare of a legacy module... you can leave a comment that says "Yes, I know this is disgusting but I had to do it because..........." and it may prevent somebody breaking your horrible hack by "fixing" it.
@hhjpegg
@hhjpegg Күн бұрын
i only write warnings 😇
@GulshanurRahman
@GulshanurRahman Күн бұрын
Immutability by default, mutable when declared is a good compromise many new languages (Kotlin, Rust) are adopting, instead of the pure functional way of no mutation.
@howardgil499
@howardgil499 Күн бұрын
Amazing thank you. What are you using to animate the code? And the diagrams?
@DavidChrisof
@DavidChrisof Күн бұрын
I never knew I was a never nester.. I hate having long codes in one function.. So I instinctively used extraction without knowing it's actually a thing.. 🎉🎉
@airkami
@airkami Күн бұрын
Y’all it is 2024. All the context you need is in the commit message in the PR (that means pull request) if you are looking directly at code you didn’t write, that’s on you to figure it out or use the tools.
@agranero6
@agranero6 Күн бұрын
The inverse of > is <= not <
@arseneandrouse5554
@arseneandrouse5554 Күн бұрын
I thought I avoided nesting to make my code easier to understand, now I think it's just cus I hated nests fck
@j.ysr0
@j.ysr0 Күн бұрын
FONT NAME? please
@Dokattak
@Dokattak 2 күн бұрын
My variable names: __eoc __cpass __cpassl
@Pocketkid2
@Pocketkid2 2 күн бұрын
I think the possible downsides of abstraction are worth it, because it forces you to think more about the design of your program and code. If you think your program has too much abstraction, you could be correct, or you could just have bad design.
@max1point8t
@max1point8t 2 күн бұрын
"When you add abstraction you add coupling" Uhhhhhhhhh......
@Otherfox-be9up
@Otherfox-be9up 2 күн бұрын
Me casually going 8 deep:
@Gravybagel
@Gravybagel 2 күн бұрын
This take feels wrong. It seems like you are taking pieces out randomly based on repitition as opposed to creating a logical abstraction. In your save example, you would never just be delivering a file name, you would also have different formatting that would need to be performed. Using dictionary lookups or case logic to get the appropriate subtype allows easy removal and addition of different subtypes. I think what I’m seeing here is also abstraction without abstraction. You’ve gone from delivering a file name to delivering a file name to different different formats. You haven’t changed the scope of the task, only tried to cram more in. Elevating the scope and providing the necessaries to accomplish a higher level task is much better than trying to not repeat yourself.
@hamzamotara4304
@hamzamotara4304 2 күн бұрын
I'm a hyper nester.
@danhu4465
@danhu4465 2 күн бұрын
These are just two different styles of abstraction: Inheritance versus Composition. None of them is better than the other. It's just a matter of decision. And a good programmer should always be able to make the right choice depending on the circumstance.
@tareqzyad9684
@tareqzyad9684 2 күн бұрын
Fuck this videos is old
@farhadfarzi3351
@farhadfarzi3351 2 күн бұрын
This was such a good video. Tnx
@salmaalfawal6155
@salmaalfawal6155 3 күн бұрын
But when you extract that block of code to a function and then call the function in the for loop, that's still the same for the stack, just less nested curly brackets, but technically the same, no?
@bpospanov
@bpospanov 3 күн бұрын
Damn bro that was beautiful 🥹
@MiguelV-DF-xv2nf
@MiguelV-DF-xv2nf 3 күн бұрын
This helped me understand a little more about Functional Programming
@CptSDX23
@CptSDX23 3 күн бұрын
I never knew of the never nesting thing, but separating everything into small functions is a great idea. Then, your main run function looks like psuedocode
@liqian7619
@liqian7619 3 күн бұрын
Very dry!
@WhileTrueCode
@WhileTrueCode 4 күн бұрын
im not a big fan of "extraction" just for the sake of making code appear cleaner. especially if that routine is only used in one place. makes chasing the logic more of a rabbithole than just dealing with the blahhhh of having the logic in-situ. i'd rather have a comment and extra newlines around the lil block of mini-logic than bounce around through a bunch of functions defined elsewhere. particularly if those functions have sub-par names. however, "inversion" is unquestionably an S-tier tip! nesting aside, there's simply no reason NOT to get all your "early-out" conditions out of the way, so you can follow a really clear path down to the meat of the routine
@CarlosCed
@CarlosCed 4 күн бұрын
What programming language is this? Bro, I got to say that your videos are making feel like an experienced coder although I am a total noob. Seriously, with all this insight I feel ahead of the game and my code has been beautified indeed. I also followed the NASA method of avoiding mistakes. Great videos!
@AnasMations
@AnasMations 4 күн бұрын
Thanks for the video, one suggestion tho: removing the bg music would be nice
@wesley.clements
@wesley.clements 4 күн бұрын
You definitely explain and make a great case for not abstracting code with implementation inheritance as it inherently increases the coupling between derived classes. That being said I do feel it odd to conflate abstraction by implementation inheritance with abstraction in general. Or that is to say that suggesting that all abstraction increases coupling is misleading. In the example you gave, you could add a level of abstraction using interface inheritance to define a common api for your saving objects and that would fundamentally reduce the coupling of the inherited classes with their consumers. I don't believe that it would be necessary to reach for that abstraction immediately as it potentially increases obfuscation without meaningfully impacting the future maintenance of the codebase. So I definitely agree with the thesis. I just felt uncomfortable with the conflation of abstraction by implementation inheritance and abstraction generally.
@scottfranco1962
@scottfranco1962 4 күн бұрын
Yea, so the ethic now is: comments are generally poor, so better to just not use them. I hope you like to talk to other programmers, because the new ones at your company will be bothering you constantly for explanations of your code. Or you could just learn to write documents.
@Seacle14
@Seacle14 4 күн бұрын
I find the music a little bit ambitious for a video about programming naming conventions
@MiguelV-DF-xv2nf
@MiguelV-DF-xv2nf 4 күн бұрын
This is good advice.
@migionie
@migionie 4 күн бұрын
10 nests deep == upsidedown from stranger things lol
@OxygenOxy
@OxygenOxy 4 күн бұрын
Python is enemy
@aeronwolfe7072
@aeronwolfe7072 4 күн бұрын
currying your monads. lol
@whistlingblue
@whistlingblue 4 күн бұрын
wowwwww
@TykeMison_
@TykeMison_ 4 күн бұрын
What a horrible video. Computers are faster so programs don't need to be programmed better. Load of nonsense. Just because you CAN make a browser that uses 2GB of RAM and 20% of a CPU to render 15MB of script doesn't mean you SHOULD or HAVE TO. What a horrible mentality, it's like saying "it doesn't matter if you drive a battle tank to work if there's always more gas to put in it." Poor coding practice wastes a large amount of electricity and every year that fraction of unnecessary waste keeps going up.
@odiiibo
@odiiibo 5 күн бұрын
Was trampolining mentioned?
@Antebios
@Antebios 5 күн бұрын
This video MUST be required training for programmers! Excellent 👌🏽
@Antebios
@Antebios 5 күн бұрын
For small code projects I always have a UTILS class to hold the simple methods. It keeps the main code cleaner to read and understand.
@johngeverett
@johngeverett 5 күн бұрын
As someone who spent 5 decades in software development, I have seen this kind of paradigm shift every 5 years or so. 'Structured programming', 'Object oriented', Pascal, C/C++, Java, Rust, Python, each iteration seemingly 'fixing' the limitations or flaws of the previous one. I suspect that by 2030 there will be yet another wave of uber-geek alphas claiming to fix the 'problems' with the current magic du jour, 'Functional programming'. That being said, each wave has important things to contribute to the discipline of creating efficient, user-friendly software. All of which, IMHO, can be implemented in assembler. Just takes some discipline.
@durnsidh6483
@durnsidh6483 2 күн бұрын
In all fairness, I am someone who perfers assembly to C/C++, but writing in assembly is impractical for any sizable project. Also, everything being implementable in assembly is kind of the point, they're all Turing complete languages.
@Schindlabua
@Schindlabua 2 күн бұрын
I also think it's funny how new tools run into the same old problems over and over again. 20 years ago I wrote shitty PHP code using codeigniter or whatever and I decided to never use a templating language again, but then I did aspnet and CSHTML and I thought to myself let's never use templating languages again but then I used a cms based on handlebars and I'm like wait, and now HTMX comes along and I'm like yo aren't we just writing templates again haha good thing I don't do web anymore. But here I am, writing helm charts to fix shitty kubernetes deployments and I'm like, whyyy has the industry not leeeearned. But yeah all in all we're moving forward I agree. I don't think functional programming is a fad however. Software development is a new field and developers have been throwing stuff at the wall to see what sticks because nobody knew better, and functional features in current programming languages are just a way to reconcile "experimental findings" with established mathematical theory.
@ydoomenaud
@ydoomenaud 5 күн бұрын
"if you write code clearly enough with well-thought out naming and structure, other people will understand it" is a delightful bit of optimism at the most diplomatic and an indication of one's position on the spectrum at the least. Doc systems for functions are excellent and should be the first line of documenting code because they also feed IDEs which do code hinting, but in real world conditions we will write code that LOOKS like an inefficient way of doing something because we've discovered flaws, even bugs in native methods that seem like a better way and we must remind ourselves never mind others not to go back and "fix" that line later. Comments shouldn't be a substitute for writing clear code but beyond that, this is like style checkers that complain about lines going over 80 characters: it doesn't matter to performance and we should mind our own business about it.
@gast128
@gast128 5 күн бұрын
Good advise mixed in with academic advise. Even Hungarian notation has still its merits where you can fast see what the type is on use location.
@keineahnung1919
@keineahnung1919 6 күн бұрын
"never abbreviate, period" Aight, lemme just catch my HyperTextTransportProtocolRequestException
@krccmsitp2884
@krccmsitp2884 6 күн бұрын
How I would approach this example: Get to know the semantics of cookie headers and their parts (RFC6265), and use those names as identifiers. cookie-header = "Cookie:" OWS cookie-string OWS cookie-string = cookie-pair *( ";" SP cookie-pair ) cookie-pair = cookie-name "=" cookie-value So, I'd choose the following identifiers: cookiePairs for "s" cookiePair for "c" cookieName for "n" cookieValue for the return if stored in a variable
@luccadeahl5340
@luccadeahl5340 6 күн бұрын
:)
@ov3rcl0cked
@ov3rcl0cked 7 күн бұрын
"dependency injection sounds a lot more fancy than it is", yes.