EVERY programmer should follow this principle 👩‍💻

Sdílet
Vložit

Komentáře • 1,1K

  • @Kaitokid730
    @Kaitokid730 Před rokem +8168

    "you gotta think lazy" is the best description ever of programmers and is the most true 😂

  • @savirananda8337
    @savirananda8337 Před rokem +6488

    "You gotta think lazy"
    Me: coding for hours to automate 5 minutes tasks.

    • @MightyAnik
      @MightyAnik Před rokem +582

      Proceeds to use the automated program for 5days and does all the work while people do half the work in 10days

    • @maxbaugh9372
      @maxbaugh9372 Před rokem +465

      @@MightyAnik In grad school one of my friends said: "if you do it twice you'll do it 10 times, just automate it"

    • @savirananda8337
      @savirananda8337 Před rokem +44

      @@MightyAnik definitely worth it!

    • @Maleko48
      @Maleko48 Před rokem +122

      I spent 6 months building some macros / scripts / automation in AHK for my day job (a little bit each day, 100% outside the scope of my actual job's duties) but damn does it make me faster than everyone else who does my job, and with way less typing/repetitive actions. Not to mention others come to me for bulk order entries since our outdated scheduling system makes doing those rather painful.

    • @KilgoreTroutAsf
      @KilgoreTroutAsf Před rokem +3

      hah no kidding

  • @moinali828
    @moinali828 Před rokem +3760

    Be DRY don't be WET ( We Enjoy Typing)

  • @Goose____
    @Goose____ Před rokem +1806

    Oh don't you worry, im lazy alright, too lazy to even start coding

  • @andrewwood1502
    @andrewwood1502 Před rokem +554

    "Don't repeat yourself is aimed at encouraging programmers to not repeat themselves"

    • @aheendwhz1
      @aheendwhz1 Před rokem +27

      Wiser words never have been spoken

    • @LetoDK
      @LetoDK Před rokem +9

      The American way of thinking, exemplified.
      Also:
      "Use DRY in order to avoid having to refactor
      How to use DRY instead: you simply refactor the code"

    • @Lymphaofallcolours
      @Lymphaofallcolours Před rokem

      Underrated.

    • @akiraigarashi2874
      @akiraigarashi2874 Před rokem +7

      People die if they are killed

    • @hamster8706
      @hamster8706 Před rokem

      Profile picture checks out

  • @montenegrodrd
    @montenegrodrd Před rokem +201

    Well, sometimes readability takes precedence over DRY. :)

    • @user-jt9yd6vr8b
      @user-jt9yd6vr8b Před rokem +10

      Agree. When using a double code with the different data, including possibly incorrect, you can see, which line of your script throws an exception, and understand easier, where is the problem. Other case is when the count of the parameters may be extended for the single case. If the code is in the function with parameters as arguments, then you need to add a function argument and, when impossible to set the default argument value, set this value to all of the function calls.

    • @joejjj4378
      @joejjj4378 Před rokem +1

      @@user-jt9yd6vr8b Many languages allow optional parameters, and those that don't will allow you to pass JSON objects with as many parameters as you like.
      In reality, the times you don't want to write reusable code for everything would be when you create a function for one thing, then extend it for another case, then keep extending it until the function becomes too complicated and difficult to maintain.

    • @joejjj4378
      @joejjj4378 Před rokem

      @@user-jt9yd6vr8b Oh and you can also create optional parameters in the Java sense, which doesnt have optional parameters but you can create haave multiple headers for a function
      doSomething(int x){ doSomething(x, -1); }
      doSomething(int x, int y){ .... }

    • @GldnClaw
      @GldnClaw Před rokem

      Is there an efficient way where you can have it display everything it refers back to without repeating? (I know nothing about coding)

    • @caribbeanman3379
      @caribbeanman3379 Před rokem

      @@GldnClaw The example given, could be made even simply by passing the math operators as an argument to an all-purpose binary operation function: def binaryCalc(x, op, y): Only thing is I'm not sure if this programming language (Python I presume?) allows for passing operators as arguments. Maybe the operator could be passed as a string and you could use a decision structure to handled the 4 different operator cases. I think one function that decides between 4 different versions of an argument is drier than 4 different functions for each operator.

  • @ujk4887
    @ujk4887 Před rokem +416

    There is no “DRY” npm package. Am I supposed to do this by thinking?

  • @dixie-pixie
    @dixie-pixie Před rokem +116

    "You gotta think lazy"
    Me: goes to stack overflow then copy-paste

    • @AppleYoJo
      @AppleYoJo Před rokem +5

      ChatGpt entered the chat

    • @abskhairoun
      @abskhairoun Před rokem

      Now that's more like it

    • @rinzler9775
      @rinzler9775 Před rokem

      Just Chat GPT - and hope whatever it created never breaks - at least while your around.

    • @i_zoru
      @i_zoru Před 11 měsíci +1

      @@AppleYoJo nah bro i prefer google bard, more updated data

    • @AppleYoJo
      @AppleYoJo Před 11 měsíci

      @@i_zoru FR? I’ve seen some reddit posts about Bard a few months ago and its answers were often rubbish, did it get better?

  • @bassam_salim
    @bassam_salim Před rokem +352

    My professor always says: " start where others reached", that's why I used my classmates' graduation project's code to build my own, it was a php website and he had all the oop stuff ready so why spend time and effort writing it when they already did.

    • @azhagurajaallinall126
      @azhagurajaallinall126 Před rokem +11

      That's the thing,..
      that's what business corps learned to do quick & my college HOD pushed us to do IEEE projects(which was done by professors & phd students which i can't afford the project requirements) still those projects meant to cash in by corps than we actually ddo something for us(personal use) and/or to start our business from it..
      Still that's the thing.. why go from beginning to just make it different at the end.. get a done project,real world application,try to change few things little by Little,eventually we learn much & quick(that's how Engineering & reverse enginnering works)
      At the end every little change we made often,make it really different,unique & really usable than the original 😃
      just go for it 😃
      As one legend says "if you're good at something,don't do it for free" (joker ofcourse)😇 since you can sell any of your work in Computer Programming,just go for it than stayed at one 😃
      Its about how much we can do program our own ideas anytime & make it worth,build your career,happiness & life out of it.. i am putting this here,to anyone who has ideas to do something,just go for it,build it,sell it,a same product differs tto each one,its your style & usability counts..
      see y'all success,happy days ahead in our life 😃🌟✨🙌
      24.08.2022 03:12 pm ist

    • @SahilP2648
      @SahilP2648 Před rokem +10

      Php in 2022? Lol

    • @rschool5386
      @rschool5386 Před rokem +1

      @@SahilP2648 I was about to say the same thing 😂

    • @victorbitencourt9481
      @victorbitencourt9481 Před rokem +16

      @@SahilP2648 php is still prevalent all over the web

    • @SahilP2648
      @SahilP2648 Před rokem +6

      @@victorbitencourt9481 yes because we didn't have better technology available back in 2000s but now it's not an excuse to not use newer tech which is just better overall in terms of development, security, versatility, and performance.

  • @jasonpepas4290
    @jasonpepas4290 Před rokem +48

    The level beyond this is knowing when to break this rule, understanding the trade-off.

    • @ChaoticNeutralMatt
      @ChaoticNeutralMatt Před rokem +2

      Like learning writing rules.

    • @Daniel_WR_Hart
      @Daniel_WR_Hart Před 9 měsíci +4

      Yep, don't use DRY in cases where you have code duplication but you're not entirely sure if those pieces of code absolutely need to be the same, because maybe they're just coincidentally the same at the moment. If you find yourself abstracting your code into a function then adding a boolean flag to change how it behaves, you just created a crappy abstraction

    • @pixels_per_minute
      @pixels_per_minute Před dnem +2

      ​@@Daniel_WR_HartAn easy example of this in game dev is player variables.
      Walk speed might coincidentally be the same as jump velocity. You wouldn't merge those two into one variable, because you might need to change them independently of each other later on.

    • @Daniel_WR_Hart
      @Daniel_WR_Hart Před dnem +1

      @@pixels_per_minute For sure, like if you decide to add running, powerups that only effect speed or jump height, upside-down gravity in some areas, or muddy ground that affects speed a bit more than height.
      It could even be as simple as having the controls feel just a bit nicer when walk speed is 90-95% of jump speed depending on the level layout

  • @loupax
    @loupax Před rokem +16

    It took me almost a decade to get this idea removed from my head

    • @svenyboyyt2304
      @svenyboyyt2304 Před 11 měsíci

      No you should just know when not to use it.

  • @MidnightSt
    @MidnightSt Před rokem +24

    No.
    There's a great talk by Casey Muratori on his channel explaining how he rewrote a navmesh generating function so that instead of taking half a minute each time it ran, it was possible to run it in realtime, at 30 FPS.
    How did he achieve such an incredible optimization?
    By not reusing functions that did what he needed to be done, but they did it in a way horribly unsuitable for the task, since their primary use was for different tasks.
    My point is, there's no universal "every programmer should always do this". Following even the most obviously-sounding "principles" religiously, without thinking what is their purpose, and how does that purpose align with the purpose of what you're currently doing, is a surefire way to end up in horrible places.
    DRY is a suggestion suitable for most programmers, and many situations, but not for everyone, nor everywhere.
    Same as all the other "good code practices".
    They're suggestions to consider and use if suitable for the specific thing you're doing.

    • @BrunoMoreira991
      @BrunoMoreira991 Před rokem

      Absolutely, while you definitely want to keep your code organized and improve readability it's important not to overdo it, especially in intensive applications where performance is key, adding a bunch of function calls will introduce overhead so it's something to keep in mind. Every situation will be different and needs to be properly studied/considered.

    • @svenyboyyt2304
      @svenyboyyt2304 Před 11 měsíci

      Then just use functions that are suited for the task. Break it down into smaller functions.

    • @BurninVinyl
      @BurninVinyl Před 3 měsíci

      100%. This DRY thing sounds more like an religion.

  • @uuu12343
    @uuu12343 Před rokem +33

    My principle is "If it doesn't look good, it's not good"
    Fitting with the example of the class init

    • @godnyx117
      @godnyx117 Před rokem +2

      Love that! I think the same way and it's just our instinct telling us that our code sucks!

    • @samueljehanno
      @samueljehanno Před rokem

      ​@@godnyx117same

  • @magne6049
    @magne6049 Před rokem +63

    There’s nuance here:
    «Prefer repetition over the wrong abstraction.»
    «Avoid hasty abstractions»
    See the talk by Sandy Metz.

  • @tamaraoweibo2780
    @tamaraoweibo2780 Před rokem +20

    “Gotta think lazy”… that’s what I’m doing when I repeat myself. It’s out of laziness… efficiency is hard.

  • @RoyalYoutube_PRO
    @RoyalYoutube_PRO Před rokem +117

    Did he really repeat the functions in order to not repeat the function?

    • @TR_Arial
      @TR_Arial Před rokem +25

      If he ever needs to change x and y values, he only needs to change it once rather than in every function

    • @jaretsanchez1900
      @jaretsanchez1900 Před rokem

      @@TR_Arial Depending on the requirements if there is user input the user can decide which function is chosen. That deletes all extras and consolidates that down to one function. So choose this, case statement based off what was chosen then the function variables x and y.

    • @aditopguy9785
      @aditopguy9785 Před rokem

      Exactly what I was thinking

    • @simonwochner3708
      @simonwochner3708 Před rokem +4

      @@TR_Arial but why does the function has 2 arguments x and y? Just remove the overwriting part and done

    • @fifty-plus
      @fifty-plus Před měsícem

      It was a terrible example, the tests didn't assert anything and you want to use fixure values over hard coded values but even if you did use hard coded values you should be keeping them within the test.

  • @SkyTheHusky
    @SkyTheHusky Před rokem +3

    "Don't repeat yourself is a software development principle aimed at reducing repeating yourself."
    *ah yes, the floor is made out of floor here*

  • @abhinavap7301
    @abhinavap7301 Před rokem +3

    "You're a programmer, you gotta think lazy" man this line will stick with me for the rest of my life.

  • @gligoran
    @gligoran Před rokem +21

    In my experience DRY leads to premature refactorization. Instead I rather use the rule of three - 2 instances of similar code are OK, but when doing a 3 instance it should be refactored.

    • @sbkates
      @sbkates Před rokem +2

      3 strikes and you're turned into a function

    • @sabientje65
      @sabientje65 Před rokem

      Learned this the hard way. Not a fan of the 'always do X' or 'always do Y' crowd. Almost every decision requires at least some nuance and thought.

    • @homelessrobot
      @homelessrobot Před 10 měsíci +1

      @@sabientje65 yeah buy then you have to think your thoughts more than once each, and thats not DRY.

  • @klarenzcobie6595
    @klarenzcobie6595 Před rokem +5

    "I'm a programmer, I'm too lazy to think lazy"

  • @kuratse205
    @kuratse205 Před rokem +21

    "you gotta think lazy"
    the one guy who overengineers simple code to save on doing the task multiple times: 👁️👄👁️

  • @stephens3909
    @stephens3909 Před rokem +4

    Make sure not to use DRY programming in test cases, they are meant to be repetitive otherwise you will need to write tests for your tests.

  • @voidpointer398
    @voidpointer398 Před rokem +2

    Ca you make video explaining SOLID principles? Your explaining skill is great

  • @bettercalldelta
    @bettercalldelta Před rokem +15

    "You gotta think lazy"
    So true, I'd rather waste 5 hours failing to automate a simple task rather than taking 5 minutes to do it manually.

  • @rafagd
    @rafagd Před rokem +7

    I thought the wisdom on testing specifically was Do Repeat Yourself A Little Bit, so you don't break all tests by reusing code that wasn't supposed to change in the first place...

    • @raphaeld9270
      @raphaeld9270 Před rokem

      You are right. You also should only consider repetition of intent not just repetition of code itself. If the same code is used for separate intents, we tend to add boolean parameter to the function, instead of just splitting that multiple-intent function into multiple smaller functions that call shared lower-level constructs.

    • @user-hm4ew5mt2f
      @user-hm4ew5mt2f Před rokem

      Agreed, example in the video is not the best since you’re asserting for different constant values in the end. And if you change values in the init, you need to go and change all the tests, which you most likely do not want to do..

  • @rookiedraconian7852
    @rookiedraconian7852 Před rokem +1

    There was once a science survey, which proved if u have a task which u want simplified or reduce the time of effort required, just hand it over to a lazy person, he'll automatically create the most efficient and time energy saving way to do that work,
    Some say even the tv remotes were made that way cuz some lazy person didn't want to stand up and walk to tv to change channels and instead wanted to change it while lying leisurely on sofa...

  • @Nofxthepirate
    @Nofxthepirate Před rokem +1

    DRY, aka: "If you reuse it, encapsulate it in a function"
    Functions are also really good for making your code look clean

  • @glezisbauk4732
    @glezisbauk4732 Před rokem +3

    I started coding seriously pretty recently and had this concept in mind, I didn't know people called it this way lol, it's like creating lego pieces you can combine in different ways to obtain completely new things

    • @TheDaruiKumo
      @TheDaruiKumo Před rokem

      It's more commonly known as object oriented programming, and it was definitely a big upgrade in the 90's. But there are a lot of problems with strictly adhering to this, I would recommend searching CZcams for something like "problems with object oriented programming"

  • @Champagnerushi
    @Champagnerushi Před rokem +16

    I prefer wet ( write everything twice). The third time you have different use cases and can create a better abstraction.

  • @rmt3589
    @rmt3589 Před 11 měsíci +1

    Code Monkey teaches this in his course. It's helping me a lot.

  • @jbird4478
    @jbird4478 Před rokem +1

    Like most rules there are situations in which it's perfectly okay to break them. Sometimes ctrl-c ctrl-v really is preferable to wasting time on some generic solution.

  • @max_ishere
    @max_ishere Před rokem +6

    That might lead to a bug if you reuse the SE test object for all tests. Now you have to make sure that your test runner kills the object before next test so you may need another test for that

    • @bedtimestories1065
      @bedtimestories1065 Před rokem

      I don't get the impression that this video is for professional developers. I was thinking the same thing lol

  • @tbuk8350
    @tbuk8350 Před rokem +10

    In this case, you don't even need to do anything with classes (though you should). You could just use variables in the intended way, and if x and y will always be the same, just initialize them outside the scope, and add them within those functions.

    • @thecwd8919
      @thecwd8919 Před rokem

      Yea i dont know why hes asking for inputs if hes just redefining them

  • @Indie_Live
    @Indie_Live Před rokem +1

    "don't repeat yourself is a way to stop repeating yourself"
    Wow

  • @zawadlttv
    @zawadlttv Před 3 měsíci +1

    if you dont want to use objects in this case, you can pass a function to a wrapper function that does the setup
    def wrapper(operation):
    x = 10
    y = 10
    return operation(x, y)
    def add(a, b)
    return a + b
    and use like this: wrapper(add)

  • @twitch7657
    @twitch7657 Před rokem +3

    And vice versa
    Don't follow WET
    We Enjoy Typing

  • @vincentlegaspi1329
    @vincentlegaspi1329 Před rokem +4

    I think it is okay to start with a mess long line of code and then think to re-write it with a shorter one. I remember while creating neural network I write every single weights and outputs cuz I wanna know how it works, after it works I re-write with a shorter line of code.

    • @homelessrobot
      @homelessrobot Před 10 měsíci

      right. "Don't repeat yourself if you know exactly what you are doing", which is after you have come to the conclusion that you know what you are doing, which should be almost never, lol.

  • @Arken119
    @Arken119 Před 6 měsíci

    “You gotta think lazy” bro resumed my whole life in 4 words 💀

  • @HunDev_PL
    @HunDev_PL Před rokem +1

    "we gotta think lazy"
    yeah, perfectly describes me writing 15 lines of code for 3 hours

  • @CodingWithLewis
    @CodingWithLewis  Před rokem +4

    What programming principle do you follow? 🤔

    • @samucancld
      @samucancld Před rokem

      DRY and KISS mostly

    • @redthered279
      @redthered279 Před rokem

      @@leshtiz440 What is it?

    • @redthered279
      @redthered279 Před rokem

      @@leshtiz440 So what you saying is, if I ever encountered a bug, I should leave it for later?

    • @redthered279
      @redthered279 Před rokem

      @UCk45TyHC6P97yuqKHSP6DoA Lol thank you for the explanation, kind stranger.

    • @redthered279
      @redthered279 Před rokem

      Uh the tag broke lol.

  • @BeardBarians
    @BeardBarians Před rokem +8

    yeah I gotta do this with my code at some point - but I also think make it work, then tidy it up

    • @JordanMetroidManiac
      @JordanMetroidManiac Před rokem +1

      You’re right. Making it work comes first because you never know what you’re going to have to add later that might not fit your current modular design. They say that premature optimization is the root of all evil.

  • @sharpfang
    @sharpfang Před rokem +1

    And then you get a framework that requires you to write 200 instances of the exact same boilerplate for 200 different dialog boxes but now it's not considered bad practice because it's no longer business logic, it's just boilerplate and you'll never need to refactor it except in a week when the framework announces API change.

    • @10101amit
      @10101amit Před rokem

      Lol, totally agree dry doesn't usually work specially in UI when you eventually have to write each case code inside the common function ..
      The only principle i follow is to not have any principles .. and that from people who have to make videos regularly ..

  • @byakuyatogami2905
    @byakuyatogami2905 Před rokem +1

    That's what first got me using lists. I'm someone who gets bored writing and typing the same thing multiple times. Glad to know I'm on the right track

  • @realcryptc
    @realcryptc Před rokem +6

    “Don’t repeat yourself is a software development principle aimed at reducing repeating yourself”
    It’s the dry humor for me 😂

  • @makezdtem
    @makezdtem Před rokem +11

    You are really inspiring 10/10

  • @BungWasHere
    @BungWasHere Před rokem +1

    "You gotta think lazy" is probably the best quote to sum being a programmer up. Somebody put that on a shirt.

  • @RickyRoundhouse777
    @RickyRoundhouse777 Před 9 měsíci

    When writing tests, be careful not to confuse code that looks the same but is testing different things as repetition that should be abstracted. Too much abstraction can create dependencies where your tests aren't completely isolated from each other and which can lead to problems.

  • @grapes008
    @grapes008 Před rokem +3

    Copy paste seems pretty lazy to to me

  • @blackcloud415
    @blackcloud415 Před rokem

    This is good advice for code you know you're gokng to use again. Sometimes you just have bulk operations that need to get done in a specific way that doesn't pertain to another scenario.

  • @seancollinray1478
    @seancollinray1478 Před rokem +1

    "Laughs and then cries in VHDL and Assembly"

  • @aidanvega9778
    @aidanvega9778 Před 5 dny

    "Don't Repeat Yourself is a software principle aimed at reducing repeating yourself"
    Nice

  • @ItsSandox
    @ItsSandox Před rokem +2

    I can't be DRY cuz im too WET (Write Everything Twice) 🤡💀

  • @upper_moon1727
    @upper_moon1727 Před rokem

    I am subbing "we are programmers you gotta think lazy" this is so true it feels targeted ☠️🤣

  • @RiderThatOneIdiot
    @RiderThatOneIdiot Před 4 měsíci +1

    As someone who just started c# this help a lot. Thx!

  • @Joshinken
    @Joshinken Před rokem

    You’re right. From now on all my code will only contain the word „if“ a single time and i refuse to repeat it.

  • @Duck_side
    @Duck_side Před 11 dny

    Sometimes it makes more sense to spend 5 hours repeating yourself than spending 5 hours setting up a function to do what you need in a reusable way, then only using it once

  • @pessimistic5579
    @pessimistic5579 Před rokem

    learning design principles is one of the most productive things you can do as a new programmer when you feel like theres not much else you need to learn in terms of syntax in your preferred language. Learn things like SOLID, KISS, DRY, YAGNI, and others. theyre all very easy concepts and will take your code to the next level

  • @Nobrainn
    @Nobrainn Před rokem +2

    **starts replacing repeating stuff with different but also repeating stuff**

    • @homelessrobot
      @homelessrobot Před 10 měsíci

      *unrolls every loop in his program so that the running program never jumps back to the same place twice*
      DRRRYYYY

  • @grzegorz.kocjan
    @grzegorz.kocjan Před 6 měsíci

    DRY is good for the beginning but later you need to understand also separation of concerns. It tells you when it is good to repeat your code :)

  • @brightlyvirya7500
    @brightlyvirya7500 Před rokem +1

    it is called modular coding. we put a multiple used code in a module that we can call by a variable

  • @quenten7860
    @quenten7860 Před 4 dny

    "Don't repeat yourself"
    -> proceed to repeat himself

  • @hyoseok
    @hyoseok Před rokem +1

    "You gotta think lazy" nice 😂♥️♥️♥️♥️

  • @m.a.daquatics4588
    @m.a.daquatics4588 Před rokem

    I just learned the lazy bit last night. I over complicated my code and have been struggling to get it to work. So I took out some extra bits and it works

  • @BrandNewByxor
    @BrandNewByxor Před rokem

    Sometimes identical code snippets exist for different purposes. I advise AGAINST de-duping these ones or you'll make it hard to modify one snippet without modifying the other. It's very hard to know when this applies or not, but you will encounter these situations when you overapply DRY principle

  • @prospekt_1
    @prospekt_1 Před 11 měsíci +1

    Refactoring and abstracting is not “thinking lazy” - quite the contrary, as saving time long term takes a lot of effort up front.

  • @hugazo
    @hugazo Před rokem

    Thinking lazy is what brought me to development

  • @lapieuvreee
    @lapieuvreee Před rokem +2

    "Don't repeat yourself" → make a short that literally repeats itself indefinitely :D

  • @Tom-vc4yq
    @Tom-vc4yq Před rokem

    I am learning how to use magic methods now. this short helped me to understand the use a bit more. thankyou!

  • @eradubbo
    @eradubbo Před rokem +1

    A lot of times following this could make some code unecessarily diffucult to read, so it depends on the context.

  • @wimeatsworld
    @wimeatsworld Před rokem

    I like the irony of a DRY explanation on an auto loop.

  • @nothanniballecktor9633
    @nothanniballecktor9633 Před měsícem +1

    I thought that was the point of the editing process. You design the logic ahead of time then go back in and do alterations to modulate it and make it better. It’s just like writing an essay, you wouldn’t turn it in without an editing process, would you?

  • @efeminella
    @efeminella Před rokem

    I spend a considerable portion of my day conducting code reviews and continually emphasizing points such as this. If developers would just take a step back to really grasp fundamental design principles; specifically: encapsulation, single responsibility, separation of concerns, principle of least knowledge, and DRY, they would significantly expedite their domain of expertise and that knowledge will always carry across any language or platform.

  • @FDroid01
    @FDroid01 Před rokem +1

    "assumed at avoiding repeating yourself" bro yes I'm dead 😁

  • @demarcorr
    @demarcorr Před rokem +1

    very context dependent, but sometimes the cost of repeating yourself doesnt outweigh the cost of refactoring to be DRY. Again, also very context dependent but you can risk tighter coupling by trying to be too DRY

  • @inesnabilla8401
    @inesnabilla8401 Před rokem +1

    this have been my motto for lyfe
    'minimum effort, maximal result' 😂

  • @the16tha.i.26
    @the16tha.i.26 Před 11 měsíci +1

    I garuntee I have seen this 16 - 20 times

  • @beepbeepgamer1305
    @beepbeepgamer1305 Před rokem +1

    welcome to step one in Machine Learning.

  • @e0nema0tak1v
    @e0nema0tak1v Před rokem

    Good tip for someone that is just starting.

  • @pirateskeleton7828
    @pirateskeleton7828 Před rokem

    Using C#, I have made a static class called “Conventions” that holds all of the most common functions I use everywhere. Similarly, I have a static class for extensions that also holds more type specific functions that I also use all the time, but as class extensions

  • @LittlesProductReviews1
    @LittlesProductReviews1 Před 8 měsíci

    I like to think in my head I came up with this idea first which is one of the reasons I don't take advice from programmers on the internet. But look for the answers myself on their coding.
    And I think I would find it fascinating how people solve different problems.

  • @tomjerry0796
    @tomjerry0796 Před rokem +1

    An another way is declare x and y as global variables
    And use it on all functions

  • @delavanty
    @delavanty Před rokem

    Damn u know what's funny is I actually like the idea of splitting any things up in factory games so this is very accurate

  • @circuitcoder
    @circuitcoder Před rokem

    "You have to be lazy" Wisest phrase ever

  • @makarambles
    @makarambles Před 8 měsíci

    in compsci classes in university we actually got MAJOR points off for not following DRY. I thought it was a pain in the butt but now that I'm working as a SWE I'm super thankful for having this drilled into me

  • @cyrusol
    @cyrusol Před měsícem +1

    This principle is overutilized, not under-.
    There are valid cases to duplicate code. Especially if it's about 2 distinct business rules that may change independently from each other and are just accidentally relying on the same logic right now.

  • @xardnaslp3171
    @xardnaslp3171 Před rokem

    "you gotta think lazy"
    I am MADE for this

  • @thatsalot3577
    @thatsalot3577 Před rokem +2

    It's kinda true but a lot of times you make your code literally unreadable, and scalable as you're locked with one design, I'd suggest looking into SOLID principles as they clearly express when you need to write more code and when less.

    • @doktoracula7017
      @doktoracula7017 Před rokem

      SOLID is as far away from clear as it's possible. S - the single thing is not defined

    • @thatsalot3577
      @thatsalot3577 Před rokem

      @@doktoracula7017 single responsibility principle is one of the most important thing to do when you're writing reusable code. I don't know about you but I've made tons of projects and I've seen them go crazy I'd rather stick with a few design patterns than starting another project.

    • @doktoracula7017
      @doktoracula7017 Před rokem

      @@thatsalot3577 It's single RESPONSIBILITY principle. And every single person defines responsibility differently.
      I made a ton of commercial projects too and I'd prefer one that doesn't stick to any design patterns over one where people stick to them religiously.
      People take S from SOLID too far and divide things that should be one function into 3-4 functions and then you get a ton of one use functions with bad naming that make future changes hell.
      It's far easier to divide a 1000 line function and clean it up than to collect 100 one to few use functions together and clean it up.

    • @thatsalot3577
      @thatsalot3577 Před rokem

      @@doktoracula7017 that was a typo 💀

    • @thatsalot3577
      @thatsalot3577 Před rokem

      And yeah i get that but when you're new and Don't have much experience about how to structure your code the SOLID principles act as a beacon
      I like following those principles because I often reuse my code and not to mention how easy it becomes to debug the code, make commits in git I've been using them for a year now and I owe it the projects I've made so far despite being small or big.

  • @arekxv
    @arekxv Před rokem +1

    DRY is good for code which is meant to coexist together, it is HELL for code which must be kept separate.

  • @pickinandgrinin7535
    @pickinandgrinin7535 Před rokem

    One of the first lesson in any good programming class.

    • @nox5282
      @nox5282 Před rokem

      Yet professionals seems to forget it

  • @jaysonbunnell8097
    @jaysonbunnell8097 Před rokem +1

    The object isn’t bad, but it’s still more typing than I like. I prefer to create a test(a,b,callback) and inside just call my various functions, seeing as they all take the same parameters. In my main() I’ll just have a few calls like so:
    function test(a,b,callback)
    return callback(a,b)
    //could also just be this:
    // const test = (a,b,callback) => callback(a,b)
    const a = 10;
    const b = 10;
    const add_val = test(a,b,test_add);
    console.log(add_val);
    OR in python:
    test = lambda a, b, callback : callback(a,b)
    # could also be this:
    # def test(a,b,callback):
    # return callback(a,b)
    a, b = 10, 10
    add_val = test(a,b,test_add)
    print(add_val)

  • @haiderabbas6175
    @haiderabbas6175 Před rokem

    Keep posting man. You rock

  • @acelyon5221
    @acelyon5221 Před rokem

    True, to be honest I end up finding ways to make my program more dry. For instance I would have 2 different outcomes that need to do different things, and when I look back on it I can see that most of the code within them are technically the same in some way. so I would try and put it all into a function and then once I do that, I can add many different outcomes I just need to pass in all the needed stuff to the function. Made my code much cleaner and no repeats

  • @iVo42928f
    @iVo42928f Před rokem

    If you want to be very strict in this principle, you should also factor out the `x y` pattern. In reality, there is quite the grey area between what counts as a code clone and what doesn't.

  • @UncoldStone
    @UncoldStone Před rokem +1

    "you are a programmer, you gotta think lazy"..... I was like: Hey is he talking to me???😂

  • @SomeguyIdk-df5td
    @SomeguyIdk-df5td Před rokem

    I learnt about this last week.

  • @kacperrutkowski6350
    @kacperrutkowski6350 Před rokem

    And that's exactly how my code always ends being a ravioli.

  • @josephbousaada9796
    @josephbousaada9796 Před rokem

    This is a solid advice for almost all cases, but sometimes you need to sacrifice DRY for clarity

  • @MrVeps1
    @MrVeps1 Před rokem

    Also, stuff the setup for your unit tests inside of a fixture. Don't repeat fixtures, use inheritance. Don't invent your own homebrew testing framework, use an existing one.

  • @flamehiro
    @flamehiro Před rokem +1

    Don't repeat yourself long as it doesn't drive you nuts. I got too ocd into don't repeat yourself that it actually made things worse at one point.

  • @CreamusG
    @CreamusG Před rokem

    I see this immediately after a video saying don't be afraid to repeat yourself. It was in regards to inheritance, but still :P