CodeAesthetic
CodeAesthetic
  • 8
  • 8 685 518
Dear Functional Bros
Access experiments at CodeAesthetic.io
Discord, deleted scenes, song names and more at patreon.com/CodeAesthetic
zhlédnutí: 440 910

Video

Dependency Injection, The Best Pattern
zhlédnutí 720KPřed 9 měsíci
Try using the attachment service at www.patreon.com/codeaesthetic You'll also find deleted scenes, song names and more
Premature Optimization
zhlédnutí 748KPřed rokem
When should you optimize your code? Access to code examples, deleted scenes, song names and more at www.patreon.com/codeaesthetic
Don't Write Comments
zhlédnutí 760KPřed rokem
Why you shouldn't write comments in your code (write documentation) Access to code examples, discord, song names and more at www.patreon.com/codeaesthetic References: www.commitstrip.com/en/2016/08/25/a-very-comprehensive-and-precise-spec/?
The Flaws of Inheritance
zhlédnutí 878KPřed rokem
Let's discuss the tradeoffs between Inheritance and Composition Access to code examples, discord, song names and more at www.patreon.com/codeaesthetic 0:00 Introduction 0:25 Inheritance 3:32 Composition 5:22 Abstracting with Inheritance 6:52 Abstracting with Interfaces 8:20 When to use Inheritance
Why You Shouldn't Nest Your Code
zhlédnutí 2,6MPřed rokem
I'm a Never Nester and you should too. Access to code examples, discord, song names and more at www.patreon.com/codeaesthetic Correction: At 2:20 the inversion should be "less than or equal", not "less than"
Naming Things in Code
zhlédnutí 2MPřed rokem
It's hard to come up with good names in code, but its also easy to get wrong. By looking at some examples, we can get 80% of the way there. Access to code examples, discord, song names and more at www.patreon.com/codeaesthetic 0:00 Introduction 0:31 Variables with a single letter 1:08 Never Abbreviate 2:06 Types in your names 2:36 Units in your variable names 3:37 Types in your types 4:30 Namin...
Abstraction Can Make Your Code Worse
zhlédnutí 599KPřed rokem
Support me on www.patreon.com/codeaesthetic. Access to code examples, discord, song names and more at www.patreon.com/codeaesthetic Adding abstraction to your code always feels like the right thing to do. But when you add abstraction, you add coupling which can often undermine the value of the abstraction. #programming #code #design #softwaredesign

Komentáře

  • @Sam-by3uk
    @Sam-by3uk Před 10 hodinami

    I write variable names that are a whole paragraph

  • @vicenteferrari5394

    How about we let people name their variables however they want? What makes you qualified to go into people's houses and tell them how they should design their living room.

  • @josephbrandenburg4373

    Having comments can make things harder to read. Now I have to read the comment and the code! Twice as much reading! So I use them sparingly.

  • @chilli_Tea
    @chilli_Tea Před dnem

    depends on what you're building tbf

  • @pelianneil7138
    @pelianneil7138 Před dnem

    how do you make your animation for your video. I need that for presenting programming to my class.

  • @a_external_ways.fully_arrays

    12'th year pure-FP programmer debugging of your video: * It is not true that there is no state in FP; you confuse mutable state with state. In pure FP immutable state is carried through function arguments - which e.g. includes when you have an accumulator argument to `fold`. In functional reactive programming, you can even have state that is kept over time, and used to calculate the new result from a new event that shoots. * This previous point is also related to your confusion at 9:00, where you *state*: "it's funny that FP should be so different from OO". ... it's about immutable vs mutable state. * At 15:30 you say that pure FP is awful - which is obviously a skill/culture/language-issue. It's actually fantastic to write your whole core program logic in pure FP, and then push all IO to the edges of your program. This avoids most bugs at the core of the program, minimizes error-prone code, and you then know where to look for the bugs; the edges.

  • @cflowlastname548
    @cflowlastname548 Před dnem

    "Pure function programing where you can not mutate any state or have any side effects is kind of awful. The issue is it's fake. Computers fundamentally have state." "Pure functional programming is still mostly academic" Erlang bros be like: Say what? 😀

  • @charlesdeuter
    @charlesdeuter Před dnem

    The biggest selling point of functional programming is OOP. Classes are simply state coupled to logic. The only reason you should ever write a class is if it increases cohesion. The problem with OOP is that it cannot help but encourage contriving reasons to do so, and thus it guarantees that your code with be incoherent.

  • @charlesdeuter
    @charlesdeuter Před dnem

    I love monads because they are impossible to understand theoretically, but take a half second to understand what it's doing when you actually see one even if you have no clue how monads are supposed to work.

  • @fg786
    @fg786 Před 2 dny

    How is everyone doing fine with max 80 characters and having spaces between operators, properly descriptive variable names aswell as descriptive function names (wiht underscores have you) that take in a couple properly descriptive variables as arguments. Is every function call that returns to a variable like 4 line breaks long?

  • @jesusplayscraft
    @jesusplayscraft Před 3 dny

    My friend in my comp sci class purposfully names everything as terribly as possible to make it as unreadable as possible. Its kinda funny but whenever they have a bug i cant really help 😭

  • @rishacha
    @rishacha Před 3 dny

    In case anyone wonders the song in the start is -> Anatoly Boardman - Boy's Heart

  • @spacelem
    @spacelem Před 3 dny

    As a mathematician, I frequently give my variables single letter name (or possibly "beta", or in Julia I can use β), and it makes life so much easier, because then it matches the equations. If I can write dS = +r*N*(1-N/c) - d*S - β*S*I/N then I know exactly what is going on. If I instead had to write rate_of_change_of_S = reproduction_rate * population_size * (1 - population_size / carrying_capacity) - mortality_rate * num_susceptibles - infection_coefficient * num_susceptibles * num_infectives / population_size that's so much harder to read and I'm much more likely to make a mistake.

  • @janhetjoch
    @janhetjoch Před 3 dny

    On the ++i vs i++ debate, I agree that it doesn't really matter for performance, but I think their is an argument to be made for the entire project using the same one for consistency. And if you are going to do one, might as well do the one that is, at least in theory, a teeny tiny bit faster

  • @SporadicGroups
    @SporadicGroups Před 3 dny

    beautiful and insightful. Thanks. How do you animate your videos by the way? Which tool do you use? Thanks in advance.

  • @thedude9014
    @thedude9014 Před 3 dny

    Me too

  • @balroc
    @balroc Před 3 dny

    Glad to meet a fellow never nester.

  • @ov3rcl0cked
    @ov3rcl0cked Před 4 dny

    unique_ptr isn't a big responsibility, because the ownership semantics imply that you just let the pointer fall out of scope and it gets freed. Whereas in old systems taking ownership did carry the responsibility to explicitly free. Figured I'd mention that, since people should totally embrace smart pointers.

  • @ov3rcl0cked
    @ov3rcl0cked Před 4 dny

    Extraction and inversion are universal and the obvious main 2, but there's also opting for more concise features. I think it's reasonable to assume this is Java, and with that the containsKey check could be replaced by a computeIfAbsent. You might end up doing a redundant setName, but I'm just working with the example you gave. With computeIfAbsent you can declare a function to compute a field if one doesn't exist, then this returns the computed or present value for the key, kind of like a pull through cache. This really begins to shine when you use concurrent map types like ConcurrentHashMap, because these features work atomically. With a concurrent map implementation you'd still need to make sure that the map hasn't changed in between the containsKey and the put, but if you do a computeIfAbsent you can atomically check if the key exists and assign a value if there isn't one. This is really useful to avoid having to manage your own synchronization on concurrent maps, because most concurrent map types have granular locks which only lock a given bucket of the map at a time, whereas you only have the control to lock the entire map without coming up with an overly clever solution.

  • @gnarfgnarf4004
    @gnarfgnarf4004 Před 4 dny

    Recursion is a problem here: the function call depth will grow so fast as to exceed stack memory. Not a practical solution.

  • @simpleprogrammingcodes3834

    When trying to understand assembly source code, the only hope is the comments (and also a documentation). There are even people who disassemble binaries, then add comments on each line of the disassembly. So in my opinion, comments can be extremely useful. It's a way to understand what code does and how, and why. Code doesn't tell that you need perform some operation to avoid some problems. But comments might.

  • @SaiTaX_the_Chile_boi

    I can go up to 5 deep, but wont be happy with it and will try to denest it into 3 deep or 2 deep.

  • @Zeioth
    @Zeioth Před 5 dny

    Bad programmer don't think the code they are writing from the point of view of "how hard is this going to be to understand for the person that come after me".

  • @simpleprogrammingcodes3834

    You should try assembly. It's not a problem in assembly. Also there are languages where this problem does not occur very often, like Prolog or Haskell.

  • @WolfireGaming
    @WolfireGaming Před 5 dny

    "There Shall Be No State" Anarchists 🤝Functional programmers

  • @andreypopov6166
    @andreypopov6166 Před 5 dny

    That is why i hate reading data science books and frameworks after 15 years being a software engineer...most of the time naming and consistency are so terrible there ((( And i fed up seeing (and actually trying to change) BaseSomething, StandardSomething, DefaultSomething type names. Thank you for highlighting such an important topics! PS. I would add one more rule: fields/local variables should be nouns and functions/methods should be verbs :)

  • @Rignchen
    @Rignchen Před 6 dny

    I think there's an exception to this and it's when you make code that'll be used by other, for example if you create a compiler, the compiled version of the code should be as optimal as possible so that the user won't lose process time on something he didn't do

  • @nicholaswood3250
    @nicholaswood3250 Před 6 dny

    Linis Torvalds has a saying about how any code that reaches three levels of nesting has a high likelihood that it needs to be refactored or pulled out into a separate function. I generally agree with this

  • @tj_r_3679
    @tj_r_3679 Před 6 dny

    this has to be the most awesome video on dependency injection ever made. Please make a course or playlist on DI and design patterns and how to solve problems using DI and the Design patterns.

  • @KushLemon
    @KushLemon Před 7 dny

    This channel is a joke.

  • @Sheopaard
    @Sheopaard Před 7 dny

    I hate doxygen

  • @Omnis2
    @Omnis2 Před 8 dny

    I have no CS background and had a Casio instead of a TI calculator when I was in school. I've tried to pick up programming over the past several years but don't understand anything unless it has parentheses.

  • @keyser456
    @keyser456 Před 8 dny

    FP scratches that itch when you don't really need a formally declared method/function but have a lot of very specific stuff to quickly get done. It's creating several quick "do some stuff with some things" bit of logic, almost like macros, that you can pass around (in languages that support it). Once you grok the concept, it opens up your world to intelligently break complex tasks down into simpler ones with less keystrokes and less code clutter. The problem is it's not nearly as readable and followable as more traditional code. You could arguably say it's an order of magnitude more complex to follow and read along with than non-functional programming. In 20+ years of professional software development as a .NET developer, other than things like Predicates (in Linq .Where) and arguably Projection (Linq .Select), you pretty much never see FP in production code. I've floated the idea by teammates from various companies in the past and nearly all of them have poo-pooed the idea of using FP in prod code, to the point they would probably reject any PR's including it.

  • @leoking3235
    @leoking3235 Před 8 dny

    I think that this is really going to depend on the language. If you're doing any serious shell scripting, comments are invaluable - sure you *can* sit through and work out what a long piped expression means, but far easier for the author to at least briefly explain it, especially given how arcane shell commands are. If you write a regex, you had better comment on at the very least what the intention of the regex is, and I have had no issue with taking multiple lines of comments to explain a complex regex before. Comments guard against folks who don't write readable code - I'd much rather have unreadable code with comments than without.

  • @donatj
    @donatj Před 8 dny

    My argument for naming things *Interface is that it makes code review a ton easier. Having worked on teams where younger developers are inclined to just type against whatever concrete type they're using at the time rather using an interface, having all interfaces in "Interface" makes it a lot easier when scanning code to say "Hey, maybe you should use an interface here"

  • @kqvanity
    @kqvanity Před 9 dny

    3:00 hahah

  • @floatswitch
    @floatswitch Před 9 dny

    No no no. Why would you remove intent? Comments get compiled out anyways. Sorry comments are required where I'm concerned.

  • @nitheshkumar.g
    @nitheshkumar.g Před 9 dny

    whole recreation of loops in functional is what recursion is.

  • @brig2913
    @brig2913 Před 9 dny

    This was so good, more videos like this please!

  • @PatrickStar914
    @PatrickStar914 Před 10 dny

    2:04 there’s an advantage to it when trying to hide code on another’s device

  • @LoZander
    @LoZander Před 10 dny

    I agree with the "don't name things single letters names", with the caveat that for certain functions which are abstract math (abstract in the sense of not being tied to a specific problem domain), like for instance "divides", it can make sense to call the parameters x and y, because the inputs are just abstract values. Though in this case you could also say dividee and divider or something like that, I suppose

  • @commissariomontanaro2931

    i'm sorry, but i believe in snake case supremacy

  • @cheerwizard21
    @cheerwizard21 Před 10 dny

    Sometimes it's better to repeat yourself in the code, rather than overabstracting things and dive into "abstraction hell". Just make your program do something interesting first, and than you may think about restructuring and abstracting code pieces.

  • @user-kk5cv1rs5r
    @user-kk5cv1rs5r Před 10 dny

    Please keep making more videos !

  • @user-kk5cv1rs5r
    @user-kk5cv1rs5r Před 10 dny

    Please keep making more videos !

  • @prettygoodman16
    @prettygoodman16 Před 11 dny

    Just don't nest your code too much. It's a pain in the ass to go through the codes 😂

  • @rafal7217
    @rafal7217 Před 11 dny

    there is also second rule, function no longer than 20 lines of code

  • @commarchinin
    @commarchinin Před 11 dny

    I feel like this is a mostly pretty good perspective, while also I think its kinda strawmanning the FP community a touch. A core thing I think needs to be pointed out is functional programming is never actually about eliminating state, its about controlling it. Even in Haskell when all your state is in monads and theoretically pure or whatever, it is still state. The point is just that by tightly controlling state you get lovely guarantees - I think of it as the guarantee that you will never be hit by gotchas in the vein of 'oh yeah, python default argument elements are mutable'. And in terms of pure FP conflicting with the fact that computers are stateful? Yep, very much. The whole point is trying to write your code in a way that's easier to reason about, and trusting that a compiler can work out how to make that work on real hardware.

  • @saranleenukul5329
    @saranleenukul5329 Před 11 dny

    The comment can lie, outdated document too.

  • @PORYGON9001
    @PORYGON9001 Před 12 dny

    Elegant code. Is beautiful. The title. Has flaw in its title. Beauty and flaw. Go hand in hand.