My 10 “Clean” Code Principles (Start These Now)

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ม.ค. 2025

ความคิดเห็น • 264

  • @euqinuykcaj
    @euqinuykcaj 10 หลายเดือนก่อน +507

    I like the first sentence I hear after clicking your video is "The first principle of clean code ..." just jump to the point. Love it!!!

    • @ConnerArdman
      @ConnerArdman  10 หลายเดือนก่อน +101

      Turns out people can read the title and don’t need videos to introduce it for 2 minutes! What a novel concept 😂

    • @BackToVoid
      @BackToVoid 6 หลายเดือนก่อน +4

      it means he's an honest man, not a jackal who wants to steal your time for their "watch time".

    • @RoamingAdhocrat
      @RoamingAdhocrat 3 หลายเดือนก่อน +1

      clean video writing

  • @zeeeeeman
    @zeeeeeman 9 หลายเดือนก่อน +184

    0:00 1. Eliminate if/else branching; early termination
    2:16 2. Ambiguous definitions: ‘is’ function prefix to denote boolean return
    4:05 3. Self documenting code: avoid belaboured comments
    5:37 4. Consistent formatting. Use Eslint + Prettier to automate code style
    7:14 5. DRY business logic. Look for opportunities to refactor. Make sure to test!
    8:37 6. Fail or exit functions fast. Related to 1.
    9:28 7. Avoid magic values - declare and use CONSTANTS instead.
    10:41 8. Avoid violating single responsibility. Prefer to use pure functions (no side effects)
    11:57 9. Overly clever code (code golf). Leads to impenetrable single liners (have to rewrite in order to debug)
    14:00 10. Premature optimisations.

    • @brunofilgueiras3518
      @brunofilgueiras3518 9 หลายเดือนก่อน +1

      thanks for the summary buddy

    • @mortsaidmort
      @mortsaidmort 8 หลายเดือนก่อน +2

      1. Is also called Guard Clauses or reducing nesting

    • @konkerouf
      @konkerouf 2 หลายเดือนก่อน +1

      Long time ago, i was a singler liner... but that was a long time ago
      So many times i had to split the code just to add a breakpoint
      So many times I had to decrypt my own code couple of months after writing it
      I came to disgust myself

  • @yt.Interest
    @yt.Interest 9 หลายเดือนก่อน +145

    W, no bullshit, no annoying stuff, straight forward, not only clean code, also clean video

    • @wsbchk_
      @wsbchk_ 6 หลายเดือนก่อน +1

      he "forgot" to ask to subscribe and hit the bell icon :)

  • @kikocastroneto
    @kikocastroneto 9 หลายเดือนก่อน +26

    This video is an excellent example of what uncle Bob mentioned in his book about being pragmatic with your own clean practices. All your tips are in the book, and the tips you don’t judge it to be good you just don’t have to use. People flame uncle Bob with the “functions shall be short” tip, but they forget the pragmatism mentioned by Bob in the introduction of the book.

  • @R1pTheJacka
    @R1pTheJacka 10 หลายเดือนก่อน +235

    This might be the first TH-cam video I've seen in well over a decade where the content actually starts at 0:00
    Subscribed

    • @kresuu3567
      @kresuu3567 10 หลายเดือนก่อน +1

      For real LOL it's refreshing to see

    • @Frankenstein786
      @Frankenstein786 2 หลายเดือนก่อน

      This video is sponsored by SquareSpace…. Skip.

  • @Ssek16
    @Ssek16 10 หลายเดือนก่อน +25

    You made me realise that my JavaScript code was complete doodoo and made me redo it all again.
    This time I actually understood what I was trying to do. Thank you.

    • @ConnerArdman
      @ConnerArdman  10 หลายเดือนก่อน +1

      That’s awesome 🙌

  • @dr.downvote
    @dr.downvote 6 หลายเดือนก่อน +8

    His habit of clean code shows in his way of doing a video. Clean and crisp

  • @davidmartensson273
    @davidmartensson273 10 หลายเดือนก่อน +59

    The isPrime example, you use Math.sqrt in the condition, this will in many languages, including js, cause the sqrt to be calculated on each pass of the loop so you should break that out to a variable and the comment can then be added to the creation of the variable, this will make it even more clear that the comment is for why we use Math.Sqrt and improve performance and reduce line complexity since the loop conditional will be a simple i

    • @ConnerArdman
      @ConnerArdman  10 หลายเดือนก่อน +22

      Good call, putting the smart in Smartensson

    • @davidmartensson273
      @davidmartensson273 10 หลายเดือนก่อน +4

      @@ConnerArdman the s is actually from my real middle name and I never realized it was part of the visible name :D.

    • @BangsarRia
      @BangsarRia 10 หลายเดือนก่อน +2

      Try to convert comments to names. For example, name the variable nonPrimeWillHaveFactorBelow and assign 1 + the Sqrt.

  • @AntonioSantos-ve6zv
    @AntonioSantos-ve6zv 9 หลายเดือนก่อน +7

    Though of skipping the video, but it immediately got my attention due to how objective it is. Thanks for the content.

  • @willowthewispy
    @willowthewispy 2 หลายเดือนก่อน +1

    A common mistake about dry is that people think it's about the same code. I love that you add for the same purpose. Many people even seniors, overlook this.
    The reason is that same code with different purpose will likely not mutate the same. And you might break one usage because you change the other.

  • @learntocodequick
    @learntocodequick 20 วันที่ผ่านมา +1

    3:39 these prefixes are called “auxiliary verbs” and include: is, does, was, will, should, can, and more.
    Great video! 👍

  • @paultapping9510
    @paultapping9510 2 หลายเดือนก่อน

    you just properly clarified what side-effects and pure functions are for me. I don't know why your phrasing is what finally got it to click, but I think I actually get it now.

  • @rty1955
    @rty1955 7 หลายเดือนก่อน +5

    I have been coding since 1969 and constantly learning. With ober 13 Lang under my best (1st love is assembly on a mainframe) I always agonize over "is it readable?" If not them clean it up! I write with the intention that someone else may have to maintain this.
    I also never take code personally, as I have seen many coders do. Instead I will show my code to others and ask them "is this easy to understand?" If the answer is no, I need to fix it.
    On each function, I place "function notes block" which are a block of comments, right before the function definition. It describes why the function is used, all the variables used, along with global variables, and in the case of assembly, what registers are touched or referenced.
    I used to run the code through a custom print program to output all these "function note blocks" to be used along any documentation I have. It shows the functions sorted alphabetically, the module they are in along with the line number where they are defined. Comes in very handy when something goes wrong

  • @anthonysetiadi
    @anthonysetiadi 10 หลายเดือนก่อน +6

    This video is so good. So many gold nuggets that you don't learn in traditional coding bootcamps or tutorials.

    • @ConnerArdman
      @ConnerArdman  10 หลายเดือนก่อน

      Glad you enjoyed it! 😀

  • @jazzpants
    @jazzpants 10 หลายเดือนก่อน +4

    Thank you Connor!!! I am forever dealing with "code smells" because people are not taking the time to do clean code. And I always end up cleaning up THEIR mess when I have to do the daily merge of everyone's code. 😭

    • @MeriaDuck
      @MeriaDuck 8 หลายเดือนก่อน +2

      Try and make it their problem, that is, try to get the teammates to use the same principles as you want to. That way you are less burdened when doing merges and they get their stuff merged with more ease and probably learn from it. Where possible / feasible, use linting and code guidelines to automate the guidance.

  • @scrapsplaysgames
    @scrapsplaysgames 10 หลายเดือนก่อน +3

    Just a small addition on the example of DRY; what's covered here is to replace three functions that do the same thing with one function that can do anything. If you want to enforce the passed-in value is always one of a specific set of strings, it should still be fine to use these other three functions. They can cover an abstraction, enforcing the passed "action" to be a specific value. Such as "return logAction("logged in")" in the first example function.

    • @JohnDoe-sq5nv
      @JohnDoe-sq5nv 6 หลายเดือนก่อน +2

      Yep. DRY is dangerous advice because many times you don't repeat yourself but rhyme. Code should be allowed to rhyme, if it isn't then you've created an abstraction layer that will need logic. In worst case in the abstraction layer. And the more rhyming code you try to fit in the more logic you need, thus the abstraction starts growing and growing and growing.
      Don't repeat yourself. But don't be afraid to rhyme.

  • @alphadog007
    @alphadog007 5 หลายเดือนก่อน

    Well Done! Solid advice. It's Saturday night, I've had a few drinks, and you STILL held my attention!

  • @cavendysh
    @cavendysh หลายเดือนก่อน

    Kudos to you. This is all good advice. Keep up your love of programming and teaching; it'll serve you well. 😀

  • @Xnight-X
    @Xnight-X 3 หลายเดือนก่อน

    perfect explanation, directly to the point, no wasted time, it was worth it 👏

  • @maurolimaok
    @maurolimaok 3 หลายเดือนก่อน

    I'm just beginning at The Odin Project, and this is AWESOME.
    Thanks a lot.

  • @Ольга-ж5к4й
    @Ольга-ж5к4й 6 หลายเดือนก่อน

    my hero who just jump into the topic with no delay and smalltalk ❤

  • @jhontriboyke5534
    @jhontriboyke5534 10 หลายเดือนก่อน +1

    the if else principle really help me, sometime i was confused why my else block code didnot work. thank you

  • @urbanpuma9136
    @urbanpuma9136 2 หลายเดือนก่อน

    Love the way you explain code

  • @정하은-h6s
    @정하은-h6s 10 หลายเดือนก่อน +1

    Hello Conner,
    This is absolutely great advice! Please make videos like this :)

  • @logank.70
    @logank.70 4 หลายเดือนก่อน

    I'm not sure if it would be another principle worth considering, but over the last year I've stopped dealing with the traditional try/catch error handling construct and instead return results and if my code throws an exception it is an "unhandled" exception to terminate the app (I'll have a hook into unhandled exceptions so I can log it before crash). You can think of it like Zig's "panic" feature. I just find the traditional try/catch something that makes code execution more difficult to reason about. I also use error codes so if the caller of a function received an error it's easier to check the error code for certain kinds of errors that can be handled or possibly panic. If I'm using a library that subscribes to the try/catch paradigm then I'll wrap it around my own thing that hides that construct (and only expose the things I use from the library).
    Probably not perfect and, I'm sure, the methodology would conjure up some discussion and debate but it has made my experience more fun and the code I write a bit more iron clad.

  • @birgitleitner1453
    @birgitleitner1453 หลายเดือนก่อน

    Jeez thx for this. Still got sooo much to learn.

  • @eugeneponomarov7429
    @eugeneponomarov7429 9 หลายเดือนก่อน

    Great video! Beginners should take a lot of notes from here.

  • @wouterk21
    @wouterk21 10 หลายเดือนก่อน +1

    Great clear video 👍.
    But to be honest, the majority of the examples are covered by using a good ESLint configuration. Add some Prettier on top for the spacing / formatting.

  • @ibunnysaur1
    @ibunnysaur1 7 หลายเดือนก่อน

    This was excellent in that it's a practical and straightforward explanation, thank you!

  • @loudichoson321
    @loudichoson321 6 หลายเดือนก่อน

    what a gem bro, glad I stumbled upon this video.

  • @iqbalibrahim4713
    @iqbalibrahim4713 8 หลายเดือนก่อน

    Really love your content, straight to the point with examples 👍🏻

  • @Ninvus2
    @Ninvus2 2 หลายเดือนก่อน

    5:00 how complex is the Math.sqrt function in JavaScript? Wouldn't it be more optimal to only compute it once and save it to a variable than to have to compute it every time the loop runs?

  • @tmbarral664
    @tmbarral664 8 หลายเดือนก่อน

    For the "return boolean" functions, I used "has'" and "can" also, depending on my needs.

  • @KaptainKhaos70
    @KaptainKhaos70 7 หลายเดือนก่อน

    🎯 Key points for quick navigation:
    00:00 *🌐 Avoid unnecessary nesting and branching to improve code readability and maintainability.*
    02:16 *📝 Clarify ambiguous code by using descriptive names and function names that reflect their behavior.*
    04:09 *🔍 Use comments sparingly and effectively to explain complex logic rather than reiterating what the code does.*
    05:32 *🛠️ Maintain consistent code formatting for readability and reduce potential errors.*
    07:25 *🔄 Apply the DRY principle to eliminate code duplication and enhance maintainability.*
    08:50 *⚡ Fail fast and early in functions to minimize unnecessary processing and enhance code efficiency.*
    09:47 *🎩 Replace magic numbers or values with named constants to improve code readability and maintainability.*
    11:27 *🔧 Ensure functions adhere to the Single Responsibility Principle to enhance clarity and maintainability.*
    12:08 *🔄 Prefer clear and readable code over overly clever solutions for better maintainability and understanding.*
    14:08 *⏳ Avoid premature optimization; optimize code when necessary based on actual performance bottlenecks.*
    Made with HARPA AI

  • @Axlefublr
    @Axlefublr 9 หลายเดือนก่อน

    when it comes to quotes (in languages that accept both), I use single quotes generally, unless the string contains a single quote, in which case I use double quotes (I prefer that to escaping).

  • @ALLCAPS
    @ALLCAPS 12 วันที่ผ่านมา

    what are your thoughts on Switch statements over many ifs? I heard that switch statements are "slower" but i've been using them quite nicely with situations that require things like file type...
    So if I need to prepare a download link for a file and the file type is finite like .exe .txt .pdf .etc etc etc, and this is just an example but lets say I need to show these files in the browser before the user downloads them.. What's cleaner this:
    Using If statements
    if(fileType == 'pdf' || fileType == 'jpeg' || fileType == 'jpg' || fileType == 'txt')
    return giveFileToBrowser();
    if(fileType == 'exe' || fileType == 'zip' )
    return giveFileToDevice();
    OR using Switch
    switch(fileType){
    case 'pdf': case 'jpeg': case 'jpg': case 'txt:
    return giveFileToBrowser();
    case 'exe': case 'zip':
    return giveFileToDevice();
    }
    ORRRRRRRRRR using Includes with ternary operator
    return ['pdf', 'jpeg', 'jpg', 'txt'].includes(fileType)
    ? giveFileToBrowser()
    : ['exe', 'zip'].includes(fileType)
    ? giveFileToDevice()
    : undefined;

  • @rickybrown8264
    @rickybrown8264 หลายเดือนก่อน

    First 2 min changed my life forever 😮

  • @BackToVoid
    @BackToVoid 6 หลายเดือนก่อน

    I love the blue background on you profile pic and also that soft blue lightning in your room. I love blue too

  • @pH7Programming
    @pH7Programming 8 หลายเดือนก่อน

    Always great reminders. Keep up the hard work! 💪

  • @mansurhamidov2319
    @mansurhamidov2319 10 หลายเดือนก่อน +1

    Thanks for video!
    Principle #6: I think you have forgotten to mention about direct returning the value instead of placing it to const and then returning it
    Principle #7
    I think better naming for the second variable would be TAXABLE_TRANSACTION_MULTIPLIER

  • @sagecole8055
    @sagecole8055 10 หลายเดือนก่อน +11

    Over commenting. I’m in university and I have to comment everything line for line and have a massive comment block on the top explaining how it works overall. Why is this taught if that many comments is actually a bad thing?

    • @ConnerArdman
      @ConnerArdman  10 หลายเดือนก่อน +7

      My guess would be it’s probably for the benefit of the grader to essentially “show your work.” Hard to say for sure though 🤷‍♂️

    • @lawrencemanning
      @lawrencemanning 10 หลายเดือนก่อน +2

      Actually learning how to comment is a skill that is difficult to teach. Your prof’s approach is likely because he is just a tad lazy, but is also not totally terrible. As long as your comments aren’t just rewording the code, you’re doing ok. Explain the thinking behind it, why a more obvious approach isn’t valid, etc. Have fun!!

    • @jc-aguilar
      @jc-aguilar 7 หลายเดือนก่อน

      When you are writing a comment, think about the why not that what. The code already does and should be written in a manner that what is doing is clear. There are occasions that a “what” type of comment is needed. For example, the algorithm is complicated and long, or obscure, or using some hidden feature that it’s not so easy to understand by just looking at the code. Normally, a comment like is more useful when the piece of code is doing something that it’s not common for the environment/industry.

    • @OblivionWonderlust
      @OblivionWonderlust 2 หลายเดือนก่อน +2

      It tricks you into basically doing the rubber ducky method. By putting what the function does into words it makes you think your function through and to catch any logical errors. The format also depends on if you are using a documentation generator because that will expect the use of certain symbols to mark params and returns.

    • @Pompomatic
      @Pompomatic 2 หลายเดือนก่อน

      Could be to make you show, in words, that you understand what you've written

  • @christopheanfry
    @christopheanfry 10 หลายเดือนก่อน +1

    Thank you so much this is gold!!!

  • @ronaldpaek
    @ronaldpaek 10 หลายเดือนก่อน +7

    Thank you for this 🙏 ❤🎉

  • @ianfrye8988
    @ianfrye8988 9 หลายเดือนก่อน

    On #8 I would possibly rename it to calculate circular area or something as "calculateArea" could be for any shape but it only calculates a circle.

  • @Tomab3
    @Tomab3 9 หลายเดือนก่อน +2

    In Principle 3 you should also extract Math.sqrt so it wont call it again and again at each iteration

  • @ClockworkGearhead
    @ClockworkGearhead 7 หลายเดือนก่อน

    The side-effect with "never nesting" is you have a default behavior if a combination of checks unexpectedly work (either though a bug or unanticipated inputs). Could be good, could be bad, depending.

  • @Phenom0100
    @Phenom0100 28 วันที่ผ่านมา

    When I was an undergraduate computer science student I was taught not to have multiple return statements in a function. I would have a functgion return some variable with value being the result of the logic of the function. What did everyone else learn in school, that was different than what I was taught?

  • @pandaer-space
    @pandaer-space 3 หลายเดือนก่อน

    What VSCode theme are you using? I really like it, can you tell me?

  • @GuanglinDu
    @GuanglinDu 4 วันที่ผ่านมา

    They are of great help. Thanks.

  • @206_akbarisahil7
    @206_akbarisahil7 4 หลายเดือนก่อน

    The code with guard clause saves a lot of time while debugging a code

  • @yaaz59
    @yaaz59 5 หลายเดือนก่อน

    Just a question, for the exemple 2, it isn’t better to declare the const password length in the function ?

    • @ConnerArdman
      @ConnerArdman  5 หลายเดือนก่อน +1

      It can depend, but generally speaking no. It's a pretty common practice to add constants to the top of the file that sort of act as a configuration setup. That said, I don't think it would be the worst thing for this to be inside the function either.

  • @VLADICA94KG
    @VLADICA94KG 8 หลายเดือนก่อน +1

    at 2:00 you are missing return statement.

  • @davidcfrogley
    @davidcfrogley 3 หลายเดือนก่อน

    In principle #5, while explaining about not repeating yourself, I see a format inconsistency. Your first two functions (logLogin and logLogout) do not capitalize the embedded preposition in the noun (i.e., login vs. logIn), whereas the third function (logSignUp) does. When used as a verb phrase, "log in" and "log out" and "sign up" are separate words and therefore would include a capital in camel case or pascal case for the second word; however, when used as a noun or adjective, "login" and "logout" and "signup" are single words and therefore include no capital letter.

  • @Micosek98
    @Micosek98 10 หลายเดือนก่อน +4

    #1 Mostly agreed, but I think the last part when there are two ways of ending function, one with return and the other one with no return is more confusing than just one else statement
    #4 There was a semicolon missing in one line ;)

    • @ConnerArdman
      @ConnerArdman  10 หลายเดือนก่อน

      Yeah that’s valid. Or if there is going to be a return, it should have been an empty return in hindsight.

    • @danielbreen3945
      @danielbreen3945 5 หลายเดือนก่อน

      Glad someone else noticed on #1. Especially important in JS since the showChildrenVersion could be modified and the compiler wouldn't warn you.

  • @danielcommins1285
    @danielcommins1285 7 หลายเดือนก่อน +1

    13:14 the reason why the bitwise expression is confusing in that example is because it evaluates to a number, 1 or 0, instead of true or false. Js deals with truthy/falsy for conditional expressions so it still works, but it should really evaluate to a boolean if being used in a conditional, e.g. n & 1 !== 0
    Great tips otherwise 🔥

  • @Blafasel3
    @Blafasel3 8 หลายเดือนก่อน

    example 1 in Principle 9 is actually rather subtle O(n^2) because the reduce is O(n) and the spreading again is O(n), so its two nested loops. Another reason why the second approach is plain better ;) The second is only O(n), becasue its two consecutive loops.

    • @nikolausmoll9201
      @nikolausmoll9201 2 วันที่ผ่านมา

      In some other Languages, the second approach is only iterated once.

  • @tomz4332
    @tomz4332 10 หลายเดือนก่อน +2

    Try ESLint & Prettier & JSDoc

  • @clickbaitpolice9792
    @clickbaitpolice9792 7 หลายเดือนก่อน

    Should variables be in capital and functions in camel?

  • @jamesfx2
    @jamesfx2 5 หลายเดือนก่อน

    There's a principle I've been talking about that might fall under "single use" but I call it "avoiding code omniscience". When we develop things in a shared project, we don't want our code to impact current code or potential future code in a way that we didn't anticipate. But we also don't want our code to increase the complexity of the project such that people working on it require knowledge of your code - i.e. requiring code omniscience. Like if we have a validation process that prevents certain items being added to a cart in an ecommerce system, unless it's hooked in directly to the add to cart system, every controller that implements add to cart will need to be updated to add this - you've increased the complexity. Or similarly, if the code we write adds a flag to the item being added, and if it's there, the validation occurs. Someone rocking up years later would have to be aware of the flag if they want to make a new system that creates gift boxes (bundles of items) or something. Documentation and tests can solve this problem but....

  • @Kutlutr
    @Kutlutr 5 หลายเดือนก่อน

    2:25
    If it is just the comparison of two numeric values, then why we are sending the object to this utility function? Namely, that function does not need to know how the "length" of a "password" object is retrieved. Rather the place that is taking care of the business logic already know what password object is and how its length can be retrieved, so we can directly send the value instead of the object. With doing so we can convert this utility functions into a library which would not be depend on any object (e.g. StringUtils in Java Apache Commons). Plus, minimum password constant value can be retrieved from another constant util class's function instead of directly referencing to the variable from a function, so that the checkPasswordLength does not need to know also where actually that constant is located. My point is that, there should be minimum change in the rest when we change something in somewhere.

  • @malvoliosf
    @malvoliosf 10 หลายเดือนก่อน +1

    You aren’t going to comment on the square-root being calculated on every iteration (5:35)?

  • @MeriaDuck
    @MeriaDuck 8 หลายเดือนก่อน +1

    Example number nine does not have to be two loops, a compiler can reason about this and just make one reduction for it.

  • @faizan346
    @faizan346 3 หลายเดือนก่อน

    Principle 9 is so important, no one cares if u have written something in short unless it improves performance significantly keep ur code as easy as possible to understand.

  • @TheRealCornPop
    @TheRealCornPop 6 หลายเดือนก่อน +1

    For those on a tight schedule, his 10 principles start at 0:00

  • @BangsarRia
    @BangsarRia 10 หลายเดือนก่อน +5

    Regarding Optimization. In more than 20 years writing Production Java code for one of the largest international banks, I have had to optimize my code twice. The first time a change to the XSLT library implementation made processing take 50x longer. Simply adding a line of code to set an undocumented but supported flag returned to normal. The second time, Dodd Frank caused volume to increase 10x overnight. Because I had written the worker code to be reentrant all I had to do was change config parameter # of workers from 1 to 16 to increase throughput 10-fold (and add an extra CPU core and run code analysis and deadlock detection overnight).
    Bottom line: Just write Clean Code and - as Conner says in the video - let the compiler worry about the insignificant local optimizations that are such tempting distractions; that's its job, not yours.

  • @MeriaDuck
    @MeriaDuck 8 หลายเดือนก่อน

    Going to use this in my lessons!

  • @albertrain7093
    @albertrain7093 10 หลายเดือนก่อน

    Hey Conner) thanks for the useful tips.
    But something is not clear for me in example with reduce and filter.
    If I'm not mistaken distructuring in reduce will cause the time complexity
    Am I right?

  • @brevnobia1238
    @brevnobia1238 3 หลายเดือนก่อน +1

    there is probably an équivalent in english, in french we say : "better is ennemy of good"

    • @I_am_Raziel
      @I_am_Raziel 3 หลายเดือนก่อน +1

      I say it similar in German. I don't know if anyone besides me says it :)

    • @brevnobia1238
      @brevnobia1238 3 หลายเดือนก่อน

      @@I_am_Raziel Yet the Germans have a reputation for overengineering.😉😉 ;)

    • @Bob-1802
      @Bob-1802 2 หลายเดือนก่อน

      "The best is the enemy of the good" is a popular equivalent.

    • @DoctorLatch
      @DoctorLatch 2 หลายเดือนก่อน

      "Good is better than perfect."

  • @santra528
    @santra528 10 หลายเดือนก่อน

    Now a days, I write the code and get my code reviewed by AI to see if there can be any potential improvements or refactoring we can do in terms of clean code and it helps me to write clean code. Anyways these tips are really golden! A lot of times I make these mistakes and get review comments from my Tech lead about these mistakes

    • @CallousCoder
      @CallousCoder 10 หลายเดือนก่อน +1

      AI is very very bad at clean and efficient code! I used CODY for code smells and it doesn't even see context it says: "check that pointer" and I always go: "check line xyz for your remark number x" And it sees it's covered.
      It comes up with idiotic ideas of naming variables really long like n "number" for readability. For fuck sake, it's the only parameter in the function, the type says its an u64 what else do you want, Cody? I am not going to type number everytime :D
      So my advise is, be very critical because AI is really really bad at coding!

  • @chaoslord8918
    @chaoslord8918 2 หลายเดือนก่อน

    6:37 With these inconsistencies, I don't even know how this code can run. If I so much as misplace a comma, the code will crash with a lengthy error that says something like "'}' expected to close '{' near '}'." (Some help that is). I've just learned to interpret this error as "Oh, there's a missing comma."
    On an unrelated note, I have no idea how people who make typos are able to program.

  • @SantiiYanez
    @SantiiYanez 10 หลายเดือนก่อน +2

    Amazing video, thanks for this.

  • @AnkitGarg
    @AnkitGarg 7 หลายเดือนก่อน

    Nice content, good job. The first tip is a double edged sword. Too many control statements can also be confusing. You have to check the entire method to understand what all it can return. Sometimes the if-else blocks which populated a variable and return at the end is easier to understand.

  • @tonymihut3070
    @tonymihut3070 8 หลายเดือนก่อน

    Just came across this and immediately subscribed 1 minute in because I need Jesse Eisenberg talking about coding in my life.

  • @abdelrhmanmohamed4754
    @abdelrhmanmohamed4754 10 หลายเดือนก่อน

    Hi i have a question , how much JavaScript enough to start react js im should i build big projects with js or just simple projects

  • @sonoftroy8572
    @sonoftroy8572 4 หลายเดือนก่อน

    Yes string interpolation, it works great with double quoted strings. "code: {$example}"

  • @federicobau8651
    @federicobau8651 3 หลายเดือนก่อน

    You did a mkstake with that refactoring. The function initially returns nothing.but you make it return the output of showChildrenVersion which could return anything. You should have called the functiom. And just return with nothin in next line

  • @long_codes
    @long_codes 2 หลายเดือนก่อน

    Good video, I really like principle number 6 8:38

  • @RafaeldaSilvaPeres
    @RafaeldaSilvaPeres 3 หลายเดือนก่อน

    13:36 you preached man! Damn boi I've seen some crazy ass one line coders writting alien code justifying themselves as "It is faster!" but them themselves cant tell how much faster it is to be valueable enough to put the poor junior dev into despair when maintaining all that shit when it breaks! And it usually breaks! And even the senior who did that cant tell what's wrong with it!

  • @2000PhucNguyen
    @2000PhucNguyen 8 หลายเดือนก่อน

    I know all your principles, because I have read Clean Code book. But I appreciate this video, and I love this video and your content. +1 subscribe.

  • @codeSurvivor
    @codeSurvivor 9 หลายเดือนก่อน

    Nice video, thanks! Straight to the point! In principle 9, I think that the example was not very good regarding the 2 loops VS 1. Reduce can be a little hard to get used to, but once you do, it's really easy to read and understand what it does. I used to chain array functions as you did here, but mainly because I never took the time to work with reduce. Now it's just easy, and if you have big arrays, loop twice VS once is really not a good idea.. I agree thaw trying to be clever while programming does not make sense, but reduce is just a basic array operator 🤷🏻‍♂️

  • @der.einzig.wahre.jemand
    @der.einzig.wahre.jemand 7 หลายเดือนก่อน

    i compress my code into 10 lines, nobody can read it but it looks cool.

  • @konkerouf
    @konkerouf 2 หลายเดือนก่อน

    Regarding principle number 5, i'd go much further and a bit against you
    1. I would describe every action in const or enum (even maybe even as a map code => text to describe the action with a code but add a different value in the log)
    2. I would create FIRST the "logAction" function
    3. I would probably create the 3 other functions as helpers. Exactly like Logger classes usually have a base function "log(level, text)" with aliases like "debug(text) => log(LOG_LEVEL_DEBUG, text)"
    Helper aliases greatly improve the readability of the code, help with the learning curve, with refactoring etc.
    But definitely, the implementation needs to be done a single time

  • @GHSB7462
    @GHSB7462 3 หลายเดือนก่อน

    What's your editor theme color?

  • @amixengineer
    @amixengineer 10 หลายเดือนก่อน +1

    excellent content thanks Conner.

  • @MrAikien
    @MrAikien 5 หลายเดือนก่อน

    Really nice 👌👍. Thanks 😊

  • @filip0112
    @filip0112 5 หลายเดือนก่อน

    Omg, thank you for starting right away. I’m tired of these 2 minute beginnings that makes no sense

  • @michaldivismusic
    @michaldivismusic 8 หลายเดือนก่อน

    I wish more people used principle #2

  • @telephonedude
    @telephonedude 10 หลายเดือนก่อน

    Couldn't agree more with all of these, though Python has instilled a habit of using 'SINGLE_QUOTES' for constants and identifiers, and "double quotes" for misc./ "natural" text in me

  • @RoamingAdhocrat
    @RoamingAdhocrat 3 หลายเดือนก่อน

    6:00 the real WTF is not having a code formatter set up - you should never need to think about consistent spacing, just hit alt-shift-F and everything lines up automatically ;)

  • @proflead
    @proflead 4 หลายเดือนก่อน

    Thanks for sahring!

  • @anonimanonim1223
    @anonimanonim1223 6 หลายเดือนก่อน

    THANK YOU❤

  • @victorianrichard8097
    @victorianrichard8097 4 หลายเดือนก่อน

    Yes we need return the same follow code

  • @pizzarand
    @pizzarand 9 หลายเดือนก่อน

    Very nice video mate

  • @vengateshm2122
    @vengateshm2122 7 หลายเดือนก่อน

    Well explained.

  • @adrianperea4026
    @adrianperea4026 4 หลายเดือนก่อน

    Nice list. For #1, I actually prefer writing the last conditional with an else statement and no return statement. If I have fresh eyes on the code, my first question would be "why does the child version have a return"

  • @KeithKazamaFlick
    @KeithKazamaFlick 10 หลายเดือนก่อน +1

    thanks...this helped

  • @DevoAjit
    @DevoAjit 4 หลายเดือนก่อน

    I liked the way of code... nice

  • @EnzoAuditore
    @EnzoAuditore 9 หลายเดือนก่อน

    Thank you for this

  • @VinOnline
    @VinOnline 9 หลายเดือนก่อน

    I appreciate your videos!

  • @itzzRaghav
    @itzzRaghav 3 หลายเดือนก่อน

    Great video