Programmers! Learn when to stop! Don't over-engineer your code.

Поделиться
HTML-код
  • Опубликовано: 3 янв 2025

Комментарии • 2,6 тыс.

  • @nonameo00
    @nonameo00 5 лет назад +8017

    All that refactoring... and he still didn't turn PI into a constant.

    • @3sc4p1sm
      @3sc4p1sm 5 лет назад +332

      Cus he doesnt get the point.

    • @pierreabbat6157
      @pierreabbat6157 5 лет назад +62

      M_PI is in an include file for a reason. I've defined several other constants in include files, often using bc to get them to 20 digits.

    • @anmaral-sharif1381
      @anmaral-sharif1381 5 лет назад +102

      He could define it as a macro:
      #define PI 3.1415
      instead of using const..

    • @pierreabbat6157
      @pierreabbat6157 5 лет назад +77

      @@anmaral-sharif1381 It's *already* defined. There's no need to define it with less precision when it's already defined in an include file with double precision. On Linux, there's also M_PIl, in case you're using (and can get) 128-bit floats.

    • @tu6e8
      @tu6e8 5 лет назад +111

      That's what mediocre programmers do all the time - over engineering staff while fucking up simple things. I think the author left it for a reason there =)

  • @frankcastle3288
    @frankcastle3288 5 лет назад +1968

    I love a quote from a book: "Code can be so complex that there are no obvious bugs or so simple that there are obviously no bugs"

    • @igorthelight
      @igorthelight 4 года назад +16

      Nice one!

    • @TheHuggableEmpire
      @TheHuggableEmpire 4 года назад +7

      A quote by Tony Hoare :)

    • @mountieman18
      @mountieman18 4 года назад +9

      oh i like that one

    • @caioffsantos
      @caioffsantos 4 года назад +3

      name of the book pls

    • @frankcastle3288
      @frankcastle3288 4 года назад +6

      @@caioffsantos it is a quote from an article in the ACM magazine that I think I read cited in the book called "Clean Code"

  • @PersonMan000
    @PersonMan000 4 года назад +935

    I'm not even joking, this is really close to how I was taught programming in uni. You'd lose marks if every line wasn't commented.

    • @Max-el3zh
      @Max-el3zh 4 года назад +39

      Initially we had to comment everything, too. But commenting variables was only when it wasn't immediately obvious what they were gonna do. Also getters/setters would at most get 1 comment for the whole section like //getters and setters .. and then you would just put all the getters and setters grouped up below that.
      And we used real comments that described how a function was used. E.g. "takes 2 int parameters and returns a two-tuple of integers as a result". And those comments do have value if you're writing a library that others are gonna use. Because if the function names are obvious enough they don't need to read code but they can just look for the correct function in the documentation and know what parameter it uses and what the return value will be.

    •  4 года назад +13

      I'm from Slovenia, and when I was studying at university ( I finished last year ) I don't remember ever "needing" to comment your code. You just had to know what it does, if you used comments here and there to help you that was fine.

    • @assadsiddiqui
      @assadsiddiqui 4 года назад +56

      In corporate world, if you have to comment so much that means your code is not self explanatory and therefore bad.

    • @perlaramos8783
      @perlaramos8783 4 года назад +5

      Same bro, This is exactly how I how I was taught to code at my university! Except we only had to comment explaining what our functions parameters were and what it returns.

    • @wilsonafuevu9036
      @wilsonafuevu9036 4 года назад

      Very true😅😅

  • @notepass
    @notepass 4 года назад +2831

    "Getters and setters for every single field!"
    You just invented Java!

    • @AyushGupta-wn6zd
      @AyushGupta-wn6zd 4 года назад +27

      What are getters and setters?

    • @OlxinosEtenn
      @OlxinosEtenn 4 года назад +412

      @@AyushGupta-wn6zd I'll assume it's a honest question.
      Getters and setters are methods that allows you to respectively retrieve (get) or modify (set) the value of a private variable.
      ...perhaps that definition doesn't help you much either. So here's the longest version:
      In a lot of languages, there's something called "classes", basically, it's a blueprint you write for more complex objects (you can think of a class as an empty form with various kind of fields, and each object being a filled form; there are typically multiple objects of the same class). Classes also typically define functions that will operate on the data they contain (for instance, a "character sheet" class might define a function which, when executed, will roll attack damage depending on the strength and weapons filled in the character sheet; note the function is always the same for all objects of the same class, but the data it operates on changes for each object). Such functions are called "methods".
      Now, sometimes, you want to ensure that the object's data is consistent. For instance, you could have fields "Job" and "Deity" in your dnd character sheet, but it wouldn't make sense to write out "Job: Priest" and "Deity: None" because priests must always belong to some kind of church. So, most languages that define classes also allows the class' author (the programmer) to declare some fields "private". Declaring a field private forbids its use by anything outside the class, so basically, only the class' methods can use it. That way, if you declared the Job and Deity field private, you'd be forced to use one of the class' methods to update their value, and the class' author can make sure that the methods never allows "Job" to be set to "Priest" when "Deity" is set to "None".
      This is a rather naive example, but in practice, it's often important to hide implementation details that shouldn't matter to the class' user and needn't be tampered with (that's called "encapsulation"). It became common place to always declare all your variables private. However, sometimes, you still need to be able to read the value or change the value of one such variable, in which case, instead of not declaring that variable private, you'll write methods to do that for you (this can seem weird to encapsulate only to break encapsulation by defining accessors, and sometimes it is, but the key is that accessors need not be defined for everything, can do something slightly more complex than just reading/writing, and allow you to change the class' implementation details without changing its interface). Such methods are called "accessors", "mutators", or "getters" and "setters" (the latter two depends on whether the accessor is supposed to read or write to that variable).

    • @Jestrath
      @Jestrath 4 года назад +50

      It's true. I often feel compelled to make getters and setters for most fields/attributes.

    • @ThomasBomb45
      @ThomasBomb45 4 года назад +49

      I code in java. I recommend project lombok. They have annotations such as @Getter and @Setter which can auto-generate (you guessed it) getters and setters

    • @TomkhaDev
      @TomkhaDev 4 года назад +59

      @@ThomasBomb45 Most Java IDE's also have the option to auto-generate getters and setters for you.

  • @kieranwood3594
    @kieranwood3594 4 года назад +153

    This is getting played out our next dev team meeting!

  • @DoubleBob
    @DoubleBob 5 лет назад +2380

    First one wouldn't even pass a corporate code review. They'll tell you to do it like the second one.
    Second one will pass the corporate code review, but management will decide it takes too long. They'll outsource this task to India, hire a joint venture management specialist and his assistant and a secretary and a coordinator and an additional HR person. Then they'll realize how expensive everything is and fire you to save some money. Management will give itself bonuses for reducing costs.

    • @beH3uH
      @beH3uH 4 года назад +33

      AHAHAHAH

    • @LloydLynx
      @LloydLynx 4 года назад +64

      Ooohhh, so that's why opensource software is so much leaner than closed source.

    • @ChrisKeddy
      @ChrisKeddy 4 года назад +64

      Everyone should start with writing a program that replaces the need for Management.

    • @DoubleBob
      @DoubleBob 4 года назад +202

      @@ChrisKeddy Got you covered, fam.
      while (true){
      if(profits < 0){
      Employees.GetRandom().Fire();
      StartCoroutine(new MotivationSpeech());
      }
      else{
      var amount = profits * 2;
      Self.IncreaseBonusPayment(amount);
      }
      }

    • @theoriginaltoadnz
      @theoriginaltoadnz 4 года назад

      Well put.

  • @user-ov5nd1fb7s
    @user-ov5nd1fb7s 6 лет назад +3830

    "I wonder if everyone will understand what this boolean means. I mean, it could be true or false."
    HAHAHAHAHAHHAAHHAHAHAHAHAHHAAH

    • @veda-powered
      @veda-powered 6 лет назад +241

      But did he ever consider that someone might not understand what the nullptr points too. I mean, it could point to nothing or not point to anything.

    • @iknosabuk
      @iknosabuk 5 лет назад +4

      OH! I love THIS!!! xD

    • @klopte2009
      @klopte2009 5 лет назад +14

      but what if it is both?! :O *MIND BLOWN AWAY* EQUAL ... ==

    • @OpenGL4ever
      @OpenGL4ever 5 лет назад +5

      If it is an int, it could go to 11.

    • @potatoes8169
      @potatoes8169 5 лет назад +11

      nooo but he needs factoriees. integerFactoryy

  • @vrtex17
    @vrtex17 5 лет назад +1473

    "It's the best code ever!"
    *Compilation error*

    • @ahmetgokpinar8635
      @ahmetgokpinar8635 4 года назад +14

      it's me i guess

    • @YouKnowMeDuh
      @YouKnowMeDuh 4 года назад +32

      Not just any compilation error. The good ol' stone age SEGFAULT.

    • @VORASTRA
      @VORASTRA 4 года назад +12

      make your own compiler

    • @geomorillo
      @geomorillo 4 года назад +2

      The best code ever, it compiles but it doesn't works lol

    • @metaorior
      @metaorior 4 года назад +5

      Need to download MSIX package only 8gb and Microsoft booster classes for Google and bing live testing also bootcamp

  • @anttihilja
    @anttihilja 4 года назад +151

    Junior: hard-code it.
    Senior: hard-code it.
    Mid-level: let me do all that because I've just learned it, feels good!

    • @nextlifeonearth
      @nextlifeonearth 2 года назад +11

      Senior will do the other thing once it's needed. Medior will do it out of the gate without knowing whether it will ever be needed.
      Junior can't.

  • @pv2b
    @pv2b 4 года назад +280

    2:52 I laughed out loud when you pasted the entire text of the GNU GPL in there

    • @kodiererg
      @kodiererg 4 года назад +52

      When I was in high school, I always did this before I turned in my assignments. I'm pretty sure it irritated my teacher

    • @achtsekundenfurz7876
      @achtsekundenfurz7876 4 года назад +3

      LOC-4-LYFE

  • @colinkingswood
    @colinkingswood 5 лет назад +348

    This is the most important thing I have learned in 17 years of professional coding. keep it as simple as possible as complexity will appear by itself.

    • @vivvpprof
      @vivvpprof 5 лет назад +11

      Mess will appear by itself, surely xD At least that's what I learned in 20 years of amateur programming, but then I'm an amateur...

    • @vaginalarthritis1753
      @vaginalarthritis1753 5 лет назад +20

      "complexity will appear by itself", truer words have never been spoken...

    • @novelnouvel
      @novelnouvel 5 лет назад +19

      @Chris Russell thousands of thousands line of codes with no documentation is the best code ever

    • @tomebundalevski1872
      @tomebundalevski1872 5 лет назад +4

      @@novelnouvel Yeah, I kinda feel that way too. Because when you go to update your project code, you update the code and then you have to update the documentation too. Which can be very tedious and easily forgotten.

    • @kuhluhOG
      @kuhluhOG 5 лет назад +8

      @@tomebundalevski1872 yep, code which is self-explanatory is the best
      but ofc, that doesn't work if you are on a size scale like an OS-kernel, but it still helps a lot
      also, don't comment what your function does (if you need to do that, you are either doing A) a tutorial or B) comment terrible code or C) it because your boss said so) instead explain why that function is needed for the program (and if you can't come up with one, you are more than likely to not even need it in the first place)
      additionally, your function is probably too long if it doesn't fit on your (normal, so 16:9 1080p) screen anymore

  • @minoanlight4545
    @minoanlight4545 5 лет назад +997

    “Know when to stop.”
    And here I am wanting to know when to start.

    • @suza3199
      @suza3199 5 лет назад +7

      Ah man I feel you

    • @kaivalyashah5634
      @kaivalyashah5634 5 лет назад +2

      Broooooooo. 😫

    • @chakko007
      @chakko007 5 лет назад +3

      @@suza3199 Same... i try to start since years. 😃

    • @Wix92
      @Wix92 5 лет назад +30

      The best time after yesterday is today ;)

    • @ArmaganSalman
      @ArmaganSalman 4 года назад +16

      Now.

  • @user-gi7ky1rf4i
    @user-gi7ky1rf4i 7 лет назад +1647

    Truly enterprise-level. Where's the github repo?

    • @javidx9
      @javidx9  7 лет назад +138

      I didn't add all the doxygen crud either. I do have a github repo though, which has all the code associated with the videos: github.com/OneLoneCoder/videos

    • @jameswilson9011
      @jameswilson9011 6 лет назад +2

      XD

    • @bbugarschi
      @bbugarschi 5 лет назад +194

      Enterprise-level??? HA!!!... where's the ShapeFactory.createCircle()??? or new ShapeBuilder().makeSquere().setSize(10).build()? or the AbstractSqure : Shape???
      I'd say it's not enterprise enough...

    • @semplar2007
      @semplar2007 5 лет назад +93

      And where is unit testing. Nooo can't be like that, how do you expect code coverage to be done? It's needed for continuous integration!
      Oh wait, you say this project is not XML configurable? Ugh, obviously project is not configurable enough.
      And ah. This is all good, but this code is really not reuseable, well, you see, there is no dependency injection used. So extract abstract classes from all your implementation classes.
      And by the way, is your code is thread-safe? What? Have you forgot about parallelism and scalability?..

    • @pow9606
      @pow9606 5 лет назад +13

      @@bbugarschi Should be it's own component so It can be accessible to all projects. No interface 😥, no unit tests 😪? No test first (TDD) 😉 Inheritance 🤮 amateur 🤣

  • @OKRASSnaky
    @OKRASSnaky 4 года назад +348

    You've imported 2 things in that code: where's your dependancy manager?!

    • @PetrPss
      @PetrPss 4 года назад +89

      Yeah, what if universe physics changes and you'll need another rectangle implementation?

    • @Airblader
      @Airblader 4 года назад +18

      @@PetrPss Well, what if you want this to work in non-Euclidean geometries? That is a thing.

    • @PetrPss
      @PetrPss 4 года назад +8

      @@Airblader Non-Euclidean geometry rectangle class should be chosen explicitly, not injected. Because it's different type (kind) of object.

    • @NeoTechni
      @NeoTechni 4 года назад +3

      @@Airblader I don't know if I want to take into account other dimensions that I might not even use.... (Phillip J Fry)

    • @kkamarada4
      @kkamarada4 4 года назад

      @@PetrPss LMAO

  • @kushagra64
    @kushagra64 4 года назад +78

    I liked you included both "cmath" and "math.h" because on of them must be the correct one :)

  • @holmrekr
    @holmrekr 7 лет назад +685

    duuudee!!!!youdidnt const the getters!!!!!!!!!! angerY

    • @javidx9
      @javidx9  7 лет назад +115

      lol, looks like i need an update to this with all the suggestions!

    • @nikolabozin5078
      @nikolabozin5078 6 лет назад +8

      @@javidx9 please do that haha

    • @londospark7813
      @londospark7813 5 лет назад +34

      @@javidx9 Dare I point out that some things could also be constexpr as well and that the value of Pi is dupicated? Better make that a constant. Also - pow(i, 2.0) might not quite convey that we're squaring something nicely enough... better make a function with the name square, or overload the ^ operator for T to make it nicer.

    • @SuperMopga
      @SuperMopga 5 лет назад +1

      NOEXCEPT!!! AAAAAAAArgh!

    • @MrEdrftgyuji
      @MrEdrftgyuji 5 лет назад +1

      @@londospark7813 Don't forget to declare a constant - sorry a constexpr function - to return the value 2.0 for the pow() function. Need to get rid of the magic numbers.

  • @drewestification
    @drewestification 5 лет назад +867

    #include , #include //I'm not sure which one so let's be safe
    brilliant idea

    • @scarm_rune
      @scarm_rune 5 лет назад

      bruh wrong planet

    • @qwerasdfhjkio
      @qwerasdfhjkio 5 лет назад +3

      Lol

    • @5cover
      @5cover 4 года назад +7

      I dont get this one. cmath is for c++, and math.h is for c, huh?

    • @Rotem_S
      @Rotem_S 4 года назад +2

      @@5cover I think cmath is complex number math (so Euler's formula and stuff). That's how it is in python at least

    • @eddieh7962
      @eddieh7962 4 года назад +1

      +hebrewname ummm no. Don’t be answering questions on a beginners programming youtube if you don’t know the answers!!

  • @DavidWonn
    @DavidWonn 5 лет назад +560

    1000 lines of code just isn’t sufficient enough to square an integer.

    • @ian-qo8fq
      @ian-qo8fq 4 года назад +6

      Math

    • @_DanerJimenez_
      @_DanerJimenez_ 4 года назад +3

      well, yeah, i mean the Builder alone would take a good hundred lines or so.
      we'd also want some results to be Persistent and Thread-safe so we'll need separate classes for that.
      and I think it would be useful for some classes to be updated when a class is done squaring, so we will be modifying these legacy classes to be able to "subscribe" to the IntegerSquarerImpl class when it is done.

    • @lekanswansons3646
      @lekanswansons3646 4 года назад

      @Богдан Кондратов stack it

    • @socialgamergang4474
      @socialgamergang4474 4 года назад

      Mathf.sqrt(int);

  • @DrunkenUFOPilot
    @DrunkenUFOPilot 4 года назад +321

    One sees over-engineering in software all the time. Overly academic engineering, overly abstract engineering, overly layered designs, all that. In what other fields of engineering do we see over-engineering? Electronics may sometimes look complicated to outsiders and beginners, but I can't say I've ever seen over-engineered electronics, not in real life. Maybe in over-priced gimmicky high-end audio, gold cables and all that fluff. Mechanical? Architectural? Costs keep things pretty well constrained to practical. Anything "over" is for extra strength, extra capacity, extra longevity, or for spacecraft to survive extreme conditions. What is special about software that so many pathologies of creation and implementation beset the industry?

    • @tobiasschafer9095
      @tobiasschafer9095 4 года назад +66

      A line of code is cheap and all the extra fluff is eaten by the compiler/linker anyway. If the resulting hex is small enough and fast enough it passes.
      (I wouldn't be surprised if both versions of the program output the same hex.)

    • @jacobrichard9569
      @jacobrichard9569 4 года назад +8

      It comes from the mind and not the physical world

    • @LudwigvanBeethoven2
      @LudwigvanBeethoven2 4 года назад +16

      I think because developers don't consider time as the important cost. They waste time and when dead line is near they actually write some good stuff!

    • @NukeCloudstalker
      @NukeCloudstalker 4 года назад +33

      @@LudwigvanBeethoven2 there is also an element of software developers being expected to be "agile" in the sense that they should be able to do arbitrary changes to the program they are requested to work with, and any change should be doable within days or at most a few weeks of a request!
      A good lead programmer will prevent that stuff from happening to his department of course.
      If specs were clear from the beginning in software, which they often aren't, then it would be easier to deal with. Premature optimization and generalization, as well as unclear end-goal, seems to be the cause of a good deal of bad code.

    • @BHBalast
      @BHBalast 4 года назад +10

      I do electronics and to be honest often "under-engienieering" is a problem. :D

  • @zombiekick
    @zombiekick 4 года назад +47

    yeah, I definitely went through a phase of over-engineering code when I was right out of college. Another thing we coders always do is when you learn a new thing, you inevitably start inserting that new thing anywhere you can.

    • @shurik121
      @shurik121 3 года назад +1

      I had to maintain some internal tool written in Go by someone who was learning Go as he was writing the tool. He was a huge fan of select-case operator (using it incorrectly in places that didn't require it) and of goto, for some inexplicable reason. Maintaining this code was a nightmare.

    • @Reegeed
      @Reegeed 2 года назад

      good thing about this is that you'll let this memorize

  • @marevixopol
    @marevixopol 6 лет назад +518

    Oh shit... I just saw myself in this vid. Thank for bringing me back on the ground

    • @javidx9
      @javidx9  6 лет назад +80

      lol, its scary isnt it Marevixo? That's why I made it! I saw myself trying to write code to some arbitrary standard that was imposed simply by the "community", based on nothing other than opinion and myth...

    • @marevixopol
      @marevixopol 6 лет назад +16

      Yeah, I'm working on some game in Godot Engine, now I see lines of comments of which purpose was to tidy up the mess, but these lines brought even more chaos...

    • @Yetipfote
      @Yetipfote 5 лет назад +4

      huh? I try to make a functional language out of everything I see! Don't care if it's C++ or Rust or anything xD

    • @aydenburgoyne7856
      @aydenburgoyne7856 5 лет назад +6

      Uni basically forces you to write code comments like that 😂

    • @Yetipfote
      @Yetipfote 5 лет назад

      @@w花b what kinda help?

  • @albingrahn5576
    @albingrahn5576 5 лет назад +355

    lmao "It works for all 2D shapes, but I've only implemented rectangles and circles."

    • @WorBlux
      @WorBlux 5 лет назад +10

      Well it's an outline at best. Really you'd likely want to know more than just the perimeter and and area. Otherwise a 2 by 8 rectangle behaves exactly the same as a 4x4 square. And what if you want a circle with an inscribed square taken out of the middle.
      And it's possible to create shaped of finite area but infinite perimeter.
      At the very least a shape in a real and useful library would need to include a reference point, and a method to determine if any particular x,y offset is within the shape or not.
      Then you could start building real generic functions like draw, union, disjuction, scale, translate, and rotate.

    • @rGunti
      @rGunti 4 года назад +16

      But what about 3D shapes? And 4D shapes? Hell what about nD shapes?! What if …

    • @russellbloxwich693
      @russellbloxwich693 4 года назад +22

      ​@@WorBlux Not to discuss your other points but
      2x8 Perimeter: 8 + 8 + 2 + 2 = 20
      4x4 Perimeterer: 4 + 4 + 4 + 4 = 16

    • @computerfis
      @computerfis 4 года назад +1

      Polygons! concave and convex :D

    • @YouKnowMeDuh
      @YouKnowMeDuh 4 года назад

      I'm dying

  • @thefoolishgmodcube2644
    @thefoolishgmodcube2644 7 лет назад +1064

    This should become a meme

    • @thefoolishgmodcube2644
      @thefoolishgmodcube2644 7 лет назад +38

      Wait! I forgot bold characters!
      *This* should become a meme.

    • @thefoolishgmodcube2644
      @thefoolishgmodcube2644 7 лет назад +28

      Hold on, it doesn't look good enough, let's add some more words!
      *This video of javidx9 about over-engineering* should definitely and most of all become the greatest meme in history of internet.

    • @thefoolishgmodcube2644
      @thefoolishgmodcube2644 7 лет назад +32

      Hey, I need to comment about my amount of likes and set an EDIT and P.S line!
      *This video of javidx9 about over-engineering* should definitely and most of all become the greatest meme in history of internet.
      EDIT: omfg, 3 likes? Thanks guys, can we get to 100 likes, please? :))))))
      P.S: You should make a part 2 of this video, I liked it and it's amazing!

    • @thefoolishgmodcube2644
      @thefoolishgmodcube2644 7 лет назад +38

      Hmmm, there's not enough memes in this comment, let me fix this.
      Last time I was this early...
      I was still over-engineering my own comment in my comment section like an idiot ( ͡° ͜ʖ ͡°) 360 no scope, get rekt, give a like if you want 1 million dollars and a reply to kiss your crush tonight.
      *This video of javidx9 about over-engineering* should definitely and most of all become the greatest meme in history of internet.
      EDIT: omfg, 3 likes? Thanks guys, can we get to 100 likes, please? :))))))
      P.S: You should make a part 2 of this video, I liked it and it's amazing!

    • @holmrekr
      @holmrekr 7 лет назад +14

      you have created the most clever comment i have ever seen my guy

  • @akashdutta1620
    @akashdutta1620 4 года назад +66

    Encryption - "Nah!! Too old fashioned"
    Over-engineering - "Yeah!! This will save my code from theft. "

  • @altimmons
    @altimmons 3 года назад +28

    This is the story of my life. Neurotic perfectionism makes me a comparatively bad programmer

  • @user-ov5nd1fb7s
    @user-ov5nd1fb7s 6 лет назад +360

    My company is transitioning to a new platform. I have to work with the vendor to reproduce our old system with the new framework. They write code exactly like you did in this video. All the things they wrote have memory issues, for the exact same reason. I keep telling them that simplicity is King. They keep lecturing me on how good their abstract structure is. They cannot fix the slow performance of their modules, I have to do it. This is stupidity, at it's finest. When their code doesn't work and other people fix it for them, they still argue. Unbelievable!

    • @javidx9
      @javidx9  6 лет назад +123

      It still surprises me when people think this video is a mockery. Almost everywhere I have worked with "pro" code has been like this :D

    • @somalioperating
      @somalioperating 5 лет назад +4

      :D yep that's true simplicity is everything

    • @iM7SnaKe
      @iM7SnaKe 5 лет назад +12

      well, if your code will be in some lib. that can be used somewhere else for different purpose, this way is the best way to make them work properly but if you need them for only one purpose then is a big NO. if you know that your lib gonna work only on two types of data there is no point to use templates, if you don't have issues with different classes with the same name there is no need to packages like namespaces. as robert martin said if the code is clean it can be self explanatory so you don't need those comments, like: "what this class called slackUser is meant for? what are those methods called: getName, getAge, getNickName; are there for?" duh!? those are self explanatory. you should put comments if is there something compicated that your self has difficult to even remember the day after (big allarm to clean your code and make a better version) but they might help you. so some are ok, that much are not.

    • @nicktk
      @nicktk 5 лет назад +4

      a memory limitation will lead them to optimization. :)))))

    • @isodoubIet
      @isodoubIet 5 лет назад +15

      ​@@iM7SnaKe " if you don't have issues with different classes with the same name there is no need to packages like namespaces."
      You don't have the foggiest clue what you're talking about. You should _never_ write nontrivial code of any kind in the global namespace.

  • @pandaDotDragon
    @pandaDotDragon 5 лет назад +262

    Well you forgot one important thing: to decouple the code. Usually I have to go across 8 or 12 layers of decorators, visitors, law of demeter, etc before reading a line that actually do something...

    • @l-cornelius-dol
      @l-cornelius-dol 5 лет назад +28

      What's that you say? Law of dementia?

    • @chillappreciator885
      @chillappreciator885 5 лет назад +5

      Especially in libraries

    • @Peto111222
      @Peto111222 5 лет назад +39

      Did he multithread the code? What if you could call multiple getters from different threads at the same time!

    • @justsiwi
      @justsiwi 5 лет назад +2

      Ohh My God!

    • @jakubrogacz6829
      @jakubrogacz6829 5 лет назад +3

      Now don't spew crap about decorators and visitors, there ARE places they have their place. however it's places not "Let's base our project on programming patterns ". Now it's all new and fad but in 5 years finding a dev to wrap their heads aroud it will be nightmare.

  • @KuroRiot
    @KuroRiot 5 лет назад +322

    "now I need a license, so I'll grab one from the internet" *literal wall of text ensues* "that's excellent" LMAOOO

    • @LordOfTheBing
      @LordOfTheBing 4 года назад +10

      and it's the GPL-3, a meme on its own.

    • @JamesAudioslave
      @JamesAudioslave 4 года назад +5

      @@LordOfTheBing yo, dont hate on gpl3 my dude

    • @devans.5324
      @devans.5324 4 года назад +1

      @@LordOfTheBing gnu vult

    • @Gamesational1
      @Gamesational1 3 года назад +2

      oi m8 u got a loisence for that code?

  • @LudwigvanBeethoven2
    @LudwigvanBeethoven2 4 года назад +103

    "What if future developers don't understand this?" (Says while he is the only developer who will be using that code ever)

    • @Yhushe
      @Yhushe 4 года назад +30

      Then you come to your code after a long while and you're like "What did this thing do again?"
      Not that I'm talking by experience...

    • @Mugistan
      @Mugistan 4 года назад +14

      @@Yhushe This doesn't work with me because I don't understand what the code does in the first place
      I once written an algorithm to scale a buffer full of pixels I spent 5 hours just changing variables randomly until it start working
      here is the code
      while(x < 64*256)
      {
      Plot_Pixel_Fast(x%64+y, x/32%128/2*2/2+z, c[x/16/16%16][x/4%16]);
      x = x + 1;
      }
      the function takes three parameters x, y and color
      c is just the colors of pixels
      If you know how it works please tell me since I who made it doesn't know
      also x = 0;

    • @tylerdaniels9000
      @tylerdaniels9000 4 года назад +1

      I never care what others would think of my code, I always try to make my code as small as possible with comments that only I can understand so that when if I ever come back later I don't get lost

    • @jonayedmohiuddin538
      @jonayedmohiuddin538 3 года назад +1

      @@Mugistan I am just interested to understand the code. So will you tell me, what the z variable is.🙂

    • @Mugistan
      @Mugistan 3 года назад +5

      @@jonayedmohiuddin538 I'd want to help you but I really have no idea how it worked

  • @denisrock01
    @denisrock01 4 года назад +313

    I couldn't understand polymorphism for 2 years until I watched this, and it's not even the point of the video

    • @karimm.elsayad9539
      @karimm.elsayad9539 4 года назад +6

      same lmao

    • @shootme4472
      @shootme4472 4 года назад +8

      polymorphism, in short, is like animals are walking but in different ways.
      *Example:*
      *Tiger:* walks in four legs
      *Human:* walks in two legs

    • @Dennis19901
      @Dennis19901 4 года назад +48

      @@shootme4472 Well, this is a bad example...

    • @shootme4472
      @shootme4472 4 года назад +4

      @@Dennis19901 How? can you explain why?

    • @shootme4472
      @shootme4472 4 года назад +8

      @@Dennis19901
      public class Animal
      {
      public virtual void Walk()
      {
      Console.WriteLine("Animal Walking");
      }
      }
      public class Human : Animal
      {
      public override void Walk()
      {
      Console.WriteLine("Walks in two legs");
      }
      }
      public class Tiger : Animal
      {
      public override void Walk()
      {
      Console.WriteLine("Walks in four legs");
      }
      }
      EDIT: written in C#

  • @carljacobs1287
    @carljacobs1287 5 лет назад +229

    Not enough operator overloading!! Should at least override the equality operator to see if two shapes are the same.

    • @MagicGonads
      @MagicGonads 4 года назад +7

      This but unironically in python

    • @2xsaiko
      @2xsaiko 4 года назад +4

      And Java
      Having to use Java for some stuff (specifically Minecraft modding), kill me. Especially since it doesn't have operator overloading.

    • @MagicGonads
      @MagicGonads 4 года назад +5

      I hate having some vector library in java but not being able to add them together with the + symbol

    • @DagaraLP
      @DagaraLP 4 года назад

      @@MagicGonads could use Kotlin instead, it has (limited) operator overloading.

  • @Dante3085
    @Dante3085 5 лет назад +18

    On a serious note, I sometimes struggle with considering for a long time if I coded something the "correct" way instead of just implementing the thing that i wanted. That's kind of due to the thousands of little advice bits you get from people online.

    • @Sevalecan
      @Sevalecan Год назад

      I had this same issue for a very long time.

  • @mrwasgehtsiedasanderzweite
    @mrwasgehtsiedasanderzweite 5 лет назад +46

    You got me with the GPL license

  • @Tikoetikoe
    @Tikoetikoe 4 года назад +33

    a 3:00 i'm seeing the best code i've ever seen. so well documented i could scroll through it for hours and not get a thing done.

  • @gamecodeur
    @gamecodeur 4 года назад +2

    Excellent. Remind me 30 years of professional programming with "professional programmers", while I was climbing the ladder they were still discussing the use of templates or "programming rules". And the comments are as good as the video.

  • @tehforma
    @tehforma 6 лет назад +35

    This video is golden! Sadly, this is exactly what we got taught at my university. That's probably why you sometimes see this kind of code

    • @javidx9
      @javidx9  6 лет назад +11

      The code is not wrong, and it's certainly a parody video, some folk just take it too seriously, and despite their best intentions, actually make it more frustrating for others!

    • @iM7SnaKe
      @iM7SnaKe 5 лет назад +2

      that code is right one if you need to reuse your lib. he makes fun but using that as an example cause in the first place that class is doing it job for it purpose, but sometimes there are people who thinks too big and start to over-engineer the code even if they are not gonna reuse it for diffent types.

    • @AlbertoSalviaNovella
      @AlbertoSalviaNovella 5 лет назад +5

      @@javidx9 The code is wrong in the regard this functioning was never required, it's over-processing. Like building a truck for someone who just wants to go to work.
      Code shall only be extended like this in the very moment it's required. Otherwise it's waste, it serves no purpose. It isn't cleaner but shittier.
      Academia is about correction, not effectiveness. After spending so much time on it you have to unlearn plenty of things, specially in the regard you write.

    • @steven_mkn
      @steven_mkn 5 лет назад +2

      But university was just teaching you most of these so that you can use them when you need to. Not that you should use them always

  • @sean8190
    @sean8190 5 лет назад +105

    2:22 "I'm not sure which, lets be safe." LMFAOOOOOOOOOO THATS ACTUALLY GOOD HAHAHA

    • @toebel
      @toebel 4 года назад +7

      Not to mention that pow(x,2) is signifigantly slower than x * x lol

    • @asurp7173
      @asurp7173 4 года назад

      yeah because pow(x,2) is incorrect lol

    • @HannibalLecter-w3r
      @HannibalLecter-w3r 4 года назад +2

      @@toebel compilers will optimize this.

    • @toebel
      @toebel 4 года назад +2

      ​@@HannibalLecter-w3r Do they? I just got out of a CS class where our projects were graded on efficiency, and one of the projects required us to do a lot of euclidean distance computations, particularly on larger test cases. Some people were posting on our class's piazza that their programs were going over time before they replaced their pow function calls

    • @HannibalLecter-w3r
      @HannibalLecter-w3r 4 года назад +1

      @@toebel using pow is the idiomatic way. Note that pow uses double(64 bit float) so even if exponent is constant and equals 2, we still need to cast float to double, multiple it by itself and cast to float. If you are working with float(32 bit), use powf insead, it will be zero cost.

  • @gale93
    @gale93 5 лет назад +87

    "I've added a virtual destructor now because vs always seems to add one, butu I'm unsure what it does" LOL

    • @timothyLucasJaeger
      @timothyLucasJaeger 4 года назад

      Isn't this actually pretty important, though? stackoverflow.com/questions/461203/when-to-use-virtual-destructors

    • @gale93
      @gale93 4 года назад +1

      @@timothyLucasJaeger yeah ofc, but it's fun because I think everyone has had that thought in their life :)

  • @ccgb92
    @ccgb92 4 года назад +5

    I come back to this every few months to regain some sanity. Thank you

  • @LordOfLemon
    @LordOfLemon 4 года назад +13

    I admit, I've been guilty of some of this during my University years. In my defense, a lot of the programming instructors seemed to consider two variables when giving out grades:
    1) Are there bugs?
    2) How many comments were written per line?
    Thanks for the wake-up call, though. Great video!

  • @gzozulin
    @gzozulin 7 лет назад +122

    It's not done yet - nobody knows how the end user will want to handle multiplication and memory allocation?! Let's add some policies and allocators via templates. That's how C++ and Boost libraries were born out of C.

    • @javidx9
      @javidx9  7 лет назад +28

      lol, that's the spirit!

    • @ishdx9374
      @ishdx9374 5 лет назад +1

      And factories because who knows how user will need to make objects

  • @attamahcelestine4263
    @attamahcelestine4263 5 лет назад +106

    This is what happens when your boss watch you code.

    • @Stoney3K
      @Stoney3K 4 года назад +14

      ... and when you get judged on your 'performance output' by lines of code witten per week instead of actual functions implemented.

  • @SuperMopga
    @SuperMopga 5 лет назад +17

    YOU HAVEN'T USE AN ENUM INSTEAD OF BOOL! Dude, you've made my day! Thank you very much!

    • @anselmschueler
      @anselmschueler 4 года назад +3

      it needs to define an enum like SetterSanityCheckResult and using a custom object creator like myOverEngineeredShapesLibrary::SetterSanityCheckResultCreator(DefaultSetterSanityCheckResultCreatorConfiguration, ...)

  • @josipcuric8767
    @josipcuric8767 4 года назад +38

    "I don't know which one, let's be safe"
    The amount of times I did that.

    • @JorenX
      @JorenX 4 года назад +1

      cppreference pages are everywhere? Google it lol, takes 10 sec

    • @burnttoast111
      @burnttoast111 4 года назад

      @@JorenX Also, you can just try building with one, and if that doesn't work, build with the other. Depending on the build time, it can be faster than googling.

    • @onyx_7187
      @onyx_7187 3 года назад

      Or you can just man whichever function you're trying to include and it will tell you in what file it is :)

  • @googleuser4720
    @googleuser4720 4 года назад +1

    Thank you! I got rejected for a code test for not putting comments on all my functions (this is in C#). This video validates I did the right thing and not over-engineer my code, especially for a code test!

  • @ricemenarq6230
    @ricemenarq6230 6 лет назад +34

    I love how you turned into John Romero at the end of the video.

  • @mishame156
    @mishame156 5 лет назад +4

    So true! I've already implemented templates, but I didn't add namespace and licience yet. Way to improve my project Thank you for this brilliant idea!

  • @EximiusDux
    @EximiusDux 6 лет назад +141

    You know when it's done when you look like John Romero. :3

  • @DKC1011
    @DKC1011 4 года назад +27

    *lights cigarette*
    "Was it good for you too?"

  • @christianschweda2530
    @christianschweda2530 Год назад

    I didn't know how much I needed to hear this, I was laughing loudly full of shame and sudden self awareness. Thank you very much.

  • @amisner2k
    @amisner2k 6 лет назад +198

    Don't forget the Unit Tests! XD

    • @javidx9
      @javidx9  6 лет назад +133

      Unit tests for every getter and setter individually!

    • @iM7SnaKe
      @iM7SnaKe 5 лет назад +18

      @@javidx9 yeah i've got some project like that, and the teacher at university said: well to pass this course you need to reach at least 90% of code coverage. and i was like: damn 40% of those methods are just getters and setters, i don't need to test them i know for sure what the result gonna be, duh.

    • @anonanon3066
      @anonanon3066 5 лет назад +4

      @@iM7SnaKe what the hell is "code coverage"?

    • @iM7SnaKe
      @iM7SnaKe 5 лет назад +2

      @@anonanon3066 google it

    • @85set05
      @85set05 5 лет назад +1

      @@iM7SnaKe That my be an indication that it's time to refactor your code.

  • @dnkreative
    @dnkreative 7 лет назад +409

    It's not done! There is shape factory?

    • @javidx9
      @javidx9  7 лет назад +91

      I'll have to update this soon!

    • @Cybeonix
      @Cybeonix 6 лет назад +45

      If you update, make sure to add in some mutexes or semaphores, you DO want it to support multi-threading don't you?? Oh and don't forget message ports for those who would rather work with it in an event driven way.

    • @figloalds
      @figloalds 5 лет назад +12

      Yeah this lacks shape factories and repositories with unnecessary single-implementation interfaces.

    • @aorusaki
      @aorusaki 5 лет назад +1

      @@Cybeonix hahaha

    • @Kasokz
      @Kasokz 5 лет назад +34

      don't forget the ShapeFactoryBuilder and ShapeFactoryBuilderFactory

  • @peterSobieraj
    @peterSobieraj 5 лет назад +164

    I still see lot of bugs.
    First of all if even setter you should validate is argument is >= 0.0.
    If it's not, then throw exception. So ofcourse you should also have your own exception class. Different class for every thrown exception. And try catch in every function that uses setter.
    Other people already mentioned that you haven't put PI in variable. You could just use M_PI from math.h, but if you want to be really profesional, then you should calculate it at start of application using Monte Carlo on max( 0.0, sqrt(1.0 - x*x) ).
    2.0 * M_PI is TAU. Another constant to calculate on start using Monte Carlo.
    That kind of calculation will look really beautiful in your CV.
    Another unproffesion thing that I notice is that you have no Unit tests at all. This is so unproffesionall.
    You should make unit tests for every single method that you have created. Just to be sure that you haven't made any mistake. It also helps with planing, and reading and understanding you code.
    Another inapropiate thing is that it's all in one file. For every class you should have 2 separate files: *.h and *.cpp. All shape classes in one project, and main function in separate project. Then you should compile shapes in to shapes.dll or shapes.so, and import it in project with main function.
    Offcorse once that done, you will need to make sure that it will work on every possible OS.
    It's good that you have put comments, but non of them is compatible with javadoc. You need to make comets that later can be used for generating documentation.
    There is lot of javadoc commands that can be used to controll how documentation will be generated. And since not everybody know javadoc, you should put normal comment above every javadoc comment, and explain what that javadoc command do, everytime you use it.
    Also everybody know that mathematical operations are much faster on GPU, not CPU. So you should use Cuda if available, if not then use OpenCL, and if that is also not available, then use CPU, but try to use advance of multithreating. If it's not availble, then go back to standard single threated CPU calculation.

    • @opp5772
      @opp5772 5 лет назад +24

      Stfu

    • @TS111WASD
      @TS111WASD 5 лет назад +3

      awake lol

    • @TheAdriyaman
      @TheAdriyaman 5 лет назад +22

      This guy code reviews

    • @Stoney3K
      @Stoney3K 4 года назад +5

      False. Setting a negative size is a valid action -- it will just mirror the shape in one axis. And if it's a symmetrical shape, a negative size will yield the same result as a positive one.
      Validate your user's inputs, but correct them if they can be corrected and don't be a school teacher to your users. If you didn't get the input from your user but instead something like a sensor, you would have needed to condition it anyway.

    • @peterSobieraj
      @peterSobieraj 4 года назад +7

      For cube or rectangle fine, we can correct negative length.
      But what should we do if we are working with tirangle defined by length of 2 sides and angle between them, and one of sides is negative ?
      Lets say 2.3, -1.8, 30*.
      On one hand we can just calculate abs, and get 2.3, 1.8, 30*.
      But on the other hand if we are going to mirror axe it should become: 2.3, 1.8, 150*.
      Thats totaly different triangle.
      So personaly I would always consider negative length as invalid input, but I see that other people may have different view on it, and it's fine.
      Should we validate is input valid or not, is different think.
      And it depend on what kind of project are working on, and what part of code.
      If you write a code for computer game that will be called 60 times per second for every vertex of every object on the scene, then go a head and skip error checking.
      But if you are writing medical software that is going to calculate drug doses once every 10min, and you get as input pacient height -5m, then please please throw an exception on every configuration. And make sure that while catching it, there will be email send to hospital IT, sms send to nurce, and print big red text on a screen. And then continue with default dose, or dose from 10min agao, or some good aproximation what it should be.
      And if you are writing software that will be runned only once, on your own machine, and it's job is to sort pictures of cats on your hard disk, and after that you will delete whole project, then again, go ahead and skip error checking. Just test it before running it on real photos.
      And to be clear, my previous comment was irony.
      I fully agree with point that this video is making.
      All my points are valid in certain cases, but usually they are over engineering.
      And over engineering is bad.
      And code like this is usually writen by people who do programming only for money. People who hate programing.
      They learned programing at univercity, and next they got some jobs as programmers, only because that was best paid job they found.
      And they don't even have PC at home.
      And if you ask person like that why they write code that way, they will tell you "becuase that wise book say so" (paper book).
      And book is writen by some 60y old prof who have never writen code other than example for students. Book writen using typewriter.

  • @rhornak2381
    @rhornak2381 4 года назад +3

    Brilliant video hahah ! I love how you emphasized the evolution of the programmer from "it works, now it's better, now it's getting crazy". I could recognize myself on a few "faults" x) .
    The line between over-engineered code and properly-engineered code can be a lit bit blurry sometimes. Because eg. the code might, maybe, someday, be used by someone, somewhere, who would eventually desperately need to use the code using doubles, and not using templates would make that impossible ..

  • @NilesBlackX
    @NilesBlackX 4 года назад +18

    2:49 "it works for all 2d shapes, but I've only implemented rectangles and circles"
    HAHAHA YESS

  • @somnolence5339
    @somnolence5339 5 лет назад +14

    And now add architectural over-engineering on top:
    1. Make it micro-service and expose functionality via Rest API
    2. Package it into Docker container that can run on container orchestration system like Kubernetes
    3. Set up continuous delivery pipeline
    4. Make sure your micro-service has multiple instances and set up load balancer to ensure high availability.

    • @jonathandaniel7321
      @jonathandaniel7321 2 года назад +1

      Yes and abstract away the microservices with othe rmicroservices, I have actually seen this happen

    • @memenchomezov
      @memenchomezov 2 года назад

      I laughed so hard, it is too much :D ruclips.net/video/jKolJFvqniQ/видео.html
      :) :D

  • @Fr0zen0RB
    @Fr0zen0RB 5 лет назад +78

    Needs more AbstractShapeFactoryConfigurationFactory

    • @Stoney3K
      @Stoney3K 4 года назад +6

      /* !< Putting this class in to comply with arbitrary coding style standard IEC-123456-789 as per company requirement. */

  • @capresto1
    @capresto1 6 лет назад +131

    If you don't comment your code they can't fire you...as simple as that ;)

    • @satibel
      @satibel 5 лет назад +8

      they can, but that'll be the next guy's job, till they quit or get fired.

    • @skewty
      @skewty 5 лет назад +14

      Good code shouldn't need a lot of comments. In just about every case when I see a comment it was due to a missed opportunity to create a function with a good name or name their variables better.

    • @Baekstrom
      @Baekstrom 5 лет назад +13

      If your code needs a lot of comments to be understandable then you should be fired.

    • @rikwisselink-bijker
      @rikwisselink-bijker 5 лет назад +9

      @@Baekstrom That strongly depends on the language and the proficiency of everyone who needs to understand the code. My main language is Matlab, and if other people see my code, they will probably be bad at it. So I don't just need to use good variable and function names, I also need to comment my code. If I'm pushing the language to its limits I'll be writing about 1 line of comment for every 2 lines of code. Simpler functions and algorithms might not need code at all, even for that audience.

    • @cybrainx72
      @cybrainx72 5 лет назад +1

      Code is also in English, why do you need to comment ?

  • @Outfrost
    @Outfrost 4 года назад +42

    *"TEMPLATES"* - that one hit me right in my 2nd year of college
    *"Getters and setters for every single field!"* - that one must've hit my college professors

    • @n0ame1u1
      @n0ame1u1 3 года назад +1

      Am currently in my second year of college, can confirm I've spent an inordinate amount of time making things with templates for no reason.

  • @Impo666
    @Impo666 Год назад +1

    "Getters and setters for every field" - Thank you, thank you, and thank you! I want to scream into the wind atop a nearby mountain peak for a whole year now for this very reason

  • @seancpp
    @seancpp 6 лет назад +12

    "I know! templates!" *whacking away at the keyboard*
    LMAO

  • @arkhtor
    @arkhtor 5 лет назад +273

    Thumbnail looks like Keanu Reeves techaes programming

  • @simmonscarl1
    @simmonscarl1 7 лет назад +28

    We called it creeping elegance.

    • @javidx9
      @javidx9  7 лет назад +2

      This is a phrase I like, and will take to work :D

    • @simmonscarl1
      @simmonscarl1 7 лет назад +9

      The problem is that there is always something programmers want to change. We just draw a line in the sand and say that it will be in the next model or next upgrade. If you don't you'll never get anything finished :-(

  • @AceGamer445
    @AceGamer445 4 года назад +1

    I am glad I viewed this video as, I must confess, I tend to over engineer my work. Simultaneously, I found this video quite entertaining! Thank you for sharing this.

  • @theroninpianist4443
    @theroninpianist4443 4 года назад +20

    "This code doesn't show how good I can be as a programmer"... I have seen job security empires start like this

  • @AdolphusOfBlood
    @AdolphusOfBlood 5 лет назад +13

    As a fan of C I feel this way when I see you use C++, but I both feel we can agree is is much worse with higher lever stuff then we might have to deal with.

    • @MagicGonads
      @MagicGonads 4 года назад

      Every time I see a namespace, I cringe
      Every time I see angled brackets (outisde of include or html), I cringe...
      Imagine using objects, at all...
      I'd be hopeless at C++
      get::me_out::ofThisHell::PleaseThankYou

  • @fronix5060
    @fronix5060 6 лет назад +15

    This looks exactly what I work with except all the comments because we have a *huge* google doc for that

  • @marlegagaming1274
    @marlegagaming1274 4 года назад +77

    Why is this recommend to me during quarantine, 3 years after the video was released 😂

    • @GrammeStudio
      @GrammeStudio 4 года назад +2

      so this is what Gilfoyle ends up doing during the quarantine after the Pied Piper fallout

    • @keith3278
      @keith3278 4 года назад +2

      The code that is the RUclips algorithm will forever be a mystery.

  • @joshlovesfood
    @joshlovesfood 3 года назад +1

    This is so funny! Seen this lots in my career, lots of big egos trying to show everyone they are 'smarter' than everyone else and therefore 'better' than everyone else. The insecure path of a narcissist. Great video!

  • @Gontrill
    @Gontrill 4 года назад

    Oh man I love this. I think the same. People make things so big so overengineered "just in case" or if "someone who doesn't know about programming looks at the code he can understand it that way".

  • @AAA-de6gt
    @AAA-de6gt 4 года назад +4

    You also need to overload operator, and add final and override in as many places as possible. The this pointer should be explicit in case someone doesn't know where the variable comes from. Also, you didn't specify that the angles of a rectangle were 90 degrees and that it is two pairs of sides are equal. So it's really a parallelogram at best, and at worst, some random quadrilateral.
    Also, cRectangle shouldn't derive from cShape, there should be cPolygon, cQuadrilateral, cConvexQuadrilateral and cParallelogram in between.

  • @wjrasmussen666
    @wjrasmussen666 5 лет назад +35

    I remember being mad at some code I had to edit and then it turned out I wrote it! I prefer amazing code that I didn't recognize that I wrote.

  • @KoKoKen
    @KoKoKen 5 лет назад +154

    my largest comment was shrek ascii art in a function called meatspin();

    • @zurechtweiser
      @zurechtweiser 4 года назад +8

      You are a true nerd. I find that slightly sympathetic. No homo, though.

    • @Ramash440
      @Ramash440 4 года назад +2

      My brethren, I once hid the entirety of the Navy Seal Copypasta inside a random class' file.

    • @achtsekundenfurz7876
      @achtsekundenfurz7876 4 года назад +1

      // if anybody reads this, add the line "// was here" and commit
      *6 years later*
      Still unchanged.
      Prof: "Add comments or you won't get full marks."
      Most popular comment: "// Boy, that's a hard problem" and similar stuff
      Found in ASM code: "nop ; unintended"
      Found in a constructor:
      /* First the universe was created.
      That was universally seen as a bad start,
      so we created this mess instead. */
      One coder had a variable dwTIME in every single program, and never used it.
      His all-time fave song: "Dancing with tears in my eyes"
      Another had his ex's number as a random seed.

  • @klokibril
    @klokibril 4 года назад +2

    I feel personally attacked as a developer. Great video. Liked!
    An eye-opener right when I needed it.

  • @mick5108
    @mick5108 2 года назад +1

    Probably one of my favourite videos on RUclips 😄

  • @AP-bo1if
    @AP-bo1if 5 лет назад +19

    funny cause that's what you typically get on open source github repos

  • @fireballgfx
    @fireballgfx 7 лет назад +80

    I think at the end you should delete the pointer. ;-)

    • @javidx9
      @javidx9  7 лет назад +91

      Bah Avon! Why bother deleting pointers?? Computers have loads of memory these days! ;-) C++ garbage collects doesn't it? Yeah, I think it does because modern languages do that these days. Anyway this code will be someone else's problem next week, I'm sure they'll remember to fix it because I'll leave a comment somewhere, and when I update the repo, I'll add the message "needs a fix". Job done! Syntax check passed, ship it!

    • @MrSapps
      @MrSapps 5 лет назад +6

      @@Ultr4noob should have been unique_ptr

    • @kanizh
      @kanizh 5 лет назад +1

      And alloc memory for `shapes` array.

    • @kanizh
      @kanizh 5 лет назад

      oh, my bad, it's ok.

  • @SpencerDavis2000
    @SpencerDavis2000 5 лет назад +8

    I love how toward the end he kind of started looking like Gilfoyle from Silicon Valley. great video

  • @iamzepeqeno5086
    @iamzepeqeno5086 4 года назад

    i honnestly just love this guy. My man your simply amazing no other words. LOVE FROM THE UK

  • @susseratal
    @susseratal 3 года назад +1

    I've been working on a coding project the last few days, and no joke, last night I looked at it and went "jesus, why've I plastered so many comments on this?" and tidied it up. I was then really anxious that it was hard to understand, but I left it as is. This video gave me the confidence to leave it as is

  • @CaptmagiKono
    @CaptmagiKono 5 лет назад +114

    Hey man, I need to over-comment because I will forget within 20 seconds of writing it.

    • @rikwisselink-bijker
      @rikwisselink-bijker 5 лет назад +31

      Over-commenting is still less bad than under-commenting buggy code that doesn't use descriptive variable names.

    • @DukeDudeston
      @DukeDudeston 5 лет назад +13

      As all of my code is for me I tend to over comment. It could be a very long time between coding sessions for me so knowing exactly what the code is, how it works, and why it's there in extreme detail helps me.

    • @aszahala
      @aszahala 5 лет назад +7

      @@DukeDudeston Yep. I just had to use one (a bit more complicated) script that I wrote three years ago and I found a bug from it. Thanks to my over commenting I was able to instantly figure out what was wrong.

    • @y.z.6517
      @y.z.6517 5 лет назад +11

      My experience is that erring on the side of over-comment is always better. You will thank yourself 6 months later. Skipping comment is fast, but figuring out what 1000 lines does isn't. In the worst case, you will think hundreds of lines are redundent, but only to find out they fixed a bug after they are deleted.

    • @samsibbens8164
      @samsibbens8164 5 лет назад +1

      I haven't seen your code so I don't want to judge too quickly, but maybe your variable and function names aren't clear enough? Maybe you don't split your code into enough separate functions, something like that?

  • @CrisMW98
    @CrisMW98 6 лет назад +8

    You have NO IDEA how some profs stress on useless functions u ll use once in a lifetime here in uni...

  • @condew6103
    @condew6103 5 лет назад +17

    I think maybe this is why I retired.

  • @cuttingchai8231
    @cuttingchai8231 4 года назад +1

    Love everything about this. And the taste in music most of all.

  • @jacobabarbary7097
    @jacobabarbary7097 4 года назад +2

    "Sometimes I have to work with other people's code!", A death sentence, truly

  • @omeryehezkely3096
    @omeryehezkely3096 5 лет назад +6

    Hold on, you forgot to:
    1. Have a design review - so we'll be able to demonstrate how smart we are, and make you code something that nobody would want to touch, including you.
    2. Open an epic + tasks + sub tasks in jira and keep changing the statuses as you "progress" with the feature.
    3. Let us do a code review before you push, so we can demonstrate how smart we are (again) and make you rewrite your code over and over again. At least for two and a half years... the time it took google to recommend this video to me.

    • @Stoney3K
      @Stoney3K 4 года назад

      The short term for these three things is called "job security".

  • @Scottx125Productions
    @Scottx125Productions 5 лет назад +17

    If someone asked me to write it like that I'd be like "Yeah F*** that!". Probably the most important rule of programming, keep it simple stupid :D.

  • @tahwnikcufos
    @tahwnikcufos 7 лет назад +21

    C'mon now, be honest... have you never been "that guy"? Hated on by your peers, because they considered themselves "leet", and above all reproach... just because you hadn't mastered, some arbitrary method/skill that, "duh, everybody should know"?

  • @SyvexDilecta
    @SyvexDilecta 4 года назад +1

    this video perfectly describes what my uni expected of me. one of the first bigger projects i've ever written were about 600 lines of code, 300 lines of comments and i didn't pass the first time it was tested because I DID NOT COMMENT ENOUGH so after i was done with what was done in this video i had 600 lines of code and 750 lines of comments and then i passed the course. i didnt change the code or anything and trust me, it wasnt overcomplicated since as a student i didnt have much idea about how to make it this complicated in the first place... though the "flaw" i had was that i didnt use enough libraries and wrote too much code they said

  • @adriannuske
    @adriannuske 4 года назад +1

    not that I wasn't already laughing, but when you pasted the licence, I cracked up! so true, all of it. And I must admit that I over comented in the past. A clever boss will say It was prior to leave a project :D. Love your content!

  • @NickEnchev
    @NickEnchev 5 лет назад +37

    Out of curiousity, do you work on any libraries that other developers may use? Not talking about the sample/utility stuff I've seen you upload to Github. I can definitely say I've been guilty of actually over-engineering, spending days thinking and researching the "fastest/best" solution to something that isn't even clearly needing it yet. On the flip-side, I've worked with FAR FAR FAR more under-engineered garbage, unmaintainable code, than over-engineered code. In a professional setting, I'd much prefer to work with the over-engineered code. I know that I've considered code "over engineered" in the past, only to then find out it was my own knowledge gap that made me feel that way. Sometimes we think someone is being fancy, when its simply that they are doing something we just don't understand. Put it this way, as someone who's been programming professionally for almost 20 years, I've never complained that someone overdid something. But at almost every job/client, I've wanted to quit because I've inherited a pile of "lets just get this working" code, that hardly anybody gets paid to go back and cleanup/fix later.

    • @Wouldntyouliketoknow2
      @Wouldntyouliketoknow2 5 лет назад +7

      This times a million.

    • @ceskygamerchallenge9198
      @ceskygamerchallenge9198 5 лет назад +5

      Cannot agree more with you. While over-engineered code might not be optimal, it's still acceptable. Under-engineered "lazy" code is just unusable garbage.

    • @ThePC007
      @ThePC007 4 года назад +2

      It kinda depends. If you work on code that is only to be used for one use case in one program (and not a library or something), then making it as simple as possible is much better than using 1000's of unnecessary design patterns and whatnot, because, in the end, we spend much more time reading and trying to understand some code than actually writing it. It makes sense to try and minimize the amount of time it takes to understand something at the possible cost of having to refactor it slightly in the future.
      Plus, if a piece of code can only do the one thing it is actually supposed to do, it is much easier to understand what it is actually used for in the program. (E.g. if it only works with doubles and doesn't use templates, then we know that it's never being used to work with integers.)
      If you're working on a library then make sure it looks the way you'd expect a library to look like (with proper documentation and all), because, well, that's what it is. You can no longer speak of "over-engineering" when the problem you're trying to solve expects you to do what you are doing.

    • @NickEnchev
      @NickEnchev 4 года назад +1

      @@ThePC007 The number of times I've heard someone say: "just going to get this out the door, so I don't care about design", only to then eat those words 6-12 months later is astounding. I've trained many junior developers over the years that consistently do this, and they end up having to get paid to rewrite/refactor trash code down the line. Its very rare for projects to just be "sample" code. Most people write code that they need to maintain long term, either for personal projects, or far more likely, for professional work. Your boss will NOT want to pay you to rewrite or perform major refactors on code you've already been paid to write. If you're ok with going back to a messy pile of code 6 months later to spend hours (on your own dime) figuring it out and refactoring it, feel free to waste your time. The only people who don't care about the quality are people who don't expect other to have to look at their code, which is almost always a mistake.
      "Plus, if a piece of code can only do the one thing it is actually supposed to do, it is much easier to understand what it is actually used for in the program." Why are you assuming it actually does what it needs to do properly, and is easier to understand? Those two almost always fall flat if that code isn't well put together. That's exactly why people talk about design and maintainability together. You can't even test your code properly in cases like that. Also, don't assume that design means using 1000 design patterns, that is not a real argument, nobody said to overuse design patterns. Design patterns have their place, and may or may not be needed right off the bat.
      All this being said, its very fair to just write code without worrying about anything if you're trying to get an algorithm working or create some proof of concept. The issue is that people subscribe to this "meh, whatever" mentality and end up pushing code like that much further into a project because they refuse to actually clean it up/design it early on. That is what I take issue with, because it happens all the time. As a consultant I'm constantly picking up code from other developers who had this shit mentality and sometimes drives me nuts.

    • @ThePC007
      @ThePC007 4 года назад +3

      ​@@NickEnchev You've probably misunderstood my comment in the most epic way possible.
      When I was talking about making the code "as simple as possible", I have actually meant just that, to make the code simple. I have no idea how that is supposed to mean that the code is supposed to be messy, which is the exact opposite of that I said.
      My comment was literally about making the code simple and therefore easier to maintain, and you are pretending that I said the opposite. I don't get it.

  • @martimorta1954
    @martimorta1954 7 лет назад +14

    - Documentation should be in Doxygen !
    - M_PI !!
    - RUclips comments can't be formatted in markdown !!!?

  • @20thCB
    @20thCB 7 лет назад +12

    Love it :-) BTW you forgot to implement RTTI hehe

  • @johnnydev819
    @johnnydev819 4 года назад +2

    David: "Getter and setters for every single field!"
    Every ORM in the world: *sweating*

  • @Vetrivel.Shanmugam
    @Vetrivel.Shanmugam 3 года назад

    I like your setup. Small, compact, distraction free.

  • @HE360
    @HE360 5 лет назад +8

    This is what people do on Stack Overflow and programming forums when they call themselves trying to help someone. LoL

  • @deadweight6877
    @deadweight6877 5 лет назад +24

    *One year later* Wtf did I wrote here ??, Where do I initialize this variable ?, How this function cannot be called by the others ?

  • @ΣοφόςΛαός
    @ΣοφόςΛαός 6 лет назад +4

    If you don't over-engineer, I can always find that little missing detail to put down your work. If you do everyrthing "right" I can still say "overkill". You lose... FATALITY.

  • @DataCraftBackbone
    @DataCraftBackbone 4 года назад +1

    i realy love your video's and this video show a very importen point maney developers do wrong, as you say "don't over-engineer your code" i see many new developers do this, and my expriens tell me, its coming with many years of developering after you have done a lots of mistakes, i really hope your video help a lots out there, i really love you videos :)

  • @yjk_ch
    @yjk_ch 4 года назад +2

    I think I’ve watched this video 1~2 years ago, but I realized I was over-engineering my code just few months ago.
    Since then, I am doing this now: No matter what it will become, write it in the simplest way possible first.