5 Programming ANTIPATTERNS for Beginners!

Поделиться
HTML-код
  • Опубликовано: 23 июл 2024
  • When you're new to programming you might fall prey to some bad programming practices. In today's video I am going to cover the 5 most common bad practices (or antipatterns) that I see with newer developers.
    🏆 ** Paid Coaching **
    Interested in joining my mastermind program and working together to get your software development career started? If you consider yourself an action-taker who is fully committed to putting in the work then book a call with me by going to andysterkowitz.link/call-00041
  • НаукаНаука

Комментарии • 504

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

    What "noobie" antipatterns would you add to the list?

    • @ilyushka21st
      @ilyushka21st 4 года назад +11

      Submitting code that breaks the project. Quite popular among junior and even competitive developers especially who work under pressure.

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

      Inadequate unit testing before submitting a big chunk.

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

      I don't know if that's a noobie one (probably is because I am one) but think/talk about web based apps and their modularity (without frameworks). Another thing is writing code in non-optimal ways like using standard loops instead of some built-in methods created for that certain purpose. In regards of web development I'd like to hear about browser support. I know all this stuff boils down to "spaghetti" but still I think it's worth a mention. Perhaps something like testing your code before pushing into production?

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

      Hey Andy, you have sparked me to pickup programming again, I want to learn Python, I took a class on JavaScript 8 years ago, I want to self teach myself programming, what you recommend I should do first?

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

      Endless loops! As far as I remember from my recent workplace as automation developer, in order to wait for the application to respond, I wrote some endless loops... Didn't think of them as endless loops when writing, because assumed that somewhen the tests will continue (when they met the condition in the loop), but when coming in the morning to see the result/s of the Sanity tests, I realized that there was a system timeout and I had to re-login and continue the test/s from where they were stuck (due to the endless loop/s)... Therefore I added some VBScript "Or" conditions that prevented the loop/s from being endless... :)

  • @yt-sh
    @yt-sh 4 года назад +700

    01. 1:55 *Ambiguous naming:* Of variables, functions: Name them uniquely and in a way they explain.Use the variable like 'commenting'.
    02. 4:49 *Magic Stings/Numbers:* If a value is repeated make it into variable/const. Replace the value with a var/const for context.
    03. 6:39 *Lava Flow:* Dont make chunks of code which will make crash entire program if changed, use Git for backup.
    04. 9:59 *Cut & Paste:* Dont use same code all over the place. repeated code -> refactor into modules, functions, classes -> one change of code should change everything rather than have to change the same code across different files.
    05. 11:48 *Poltergeist:* Make it compact & concise and with less shortcuts/paths/references
    To fully understand these, watch this video

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

      3: use version control &/or Git for program structure simplicity

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

      If you don't know these things, you shouldn't even be allowed to have a programming job.

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

      This should be pinned

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

      I wish copy-paste wasn't that often necessary. You work with an API that requires you, for every piece, say every GUI element it displays, or every event it handles, to obtain the context, obtain the instance of the API engine, instantiate a connector object compliant with its interface, configure it, declaring every field you never need as its respective default value explicitly, then apply the one single value you want to put in it and call the method that feeds it to the API engine. Or worse, generate an entirely new class which inherits after the API object and provides a dozen stub methods that do nothing because you don't need them, and one getter and one setter as required by the function you need. Dozens of files differing by 2-3 lines each from each other, just to satisfy API prerequisites.

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

      @@bjarnestronstrup9122 If only.

  • @ericgeorge8449
    @ericgeorge8449 4 года назад +58

    My coding philosophy (which explicitly addresses the 5th point, poltergeists):
    "Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery

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

    0:00 Self-Hype.
    0:52 What Is An Anti-Pattern?
    1:46 #1) Ambiguous Naming.
    4:43 #2) Magic Strings / Numbers.
    6:35 #3) Lava Flow.
    9:53 #4) Cut and Paste.
    11:43 #5) Poltergeist.
    14:17 More Self-Hype.
    15:11 Outro.

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

      Pretty much every RUclips toplist ever? :q

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

      Hmm . Version control doesn't really help lava flow, you need to either 1. Always stay consistent with the existing styles and technology or 2. Complete the features in the new technology and refactor the existing code to match before pushing to production..

  • @DanEllis
    @DanEllis 4 года назад +169

    These are all good points, but they're code smells, or just bad design or programming. An antipattern is a specific thing: a *known solution to a problem* that leads to a bad design. (See the entries on C2 and Wikipedia for more detail.)

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

      Thank you for saying what I wanted to say. These are not anti-patterns. Glad to see he is teaching people. sheesh

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

      Totally agree. This are bad smells not anti-patterns. Even though the video is really informative for begginers he himself is confusing concepts.

    • @daniel.lupton
      @daniel.lupton 4 года назад +4

      He also redefined a lot of these phrases. "This means X but to me the problem is really Y." Then don't call it X.

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

      @@daniel.lupton He's self-taught. When I got my first job, my code impressed a seasoned algorithms engineer from a top school. The hiring manager thought I was a complete idiot, since I didn't know the names of various sort algorithms - even though I could show the fastest, or lowest memory way to sort any given data set, and then explain why neither of those are a good idea on a given real world project. After working with the post-doc guy, I learned a lot of the terminology. Which makes it easier to have non-technical conversations about technical topics, but hasn't really changed my code at all. It's like an engineer trying to talk to a doctor. If you know exactly how it works but don't say it in Latin, screw you. :p

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

      I believe he's trying to say behavioural pattern rather than design pattern, but I would say your criticism is valid. It would have been much clearer to say something like bad programming habit rather than anti-pattern.

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

    I’m 25 years into my development life, and these are seriously great anti patterns. Yes, read Uncle Bob - but what Andy has here is still a nice, concise set of things for beginners. I’ve seen senior developers violate these anti patterns! Great video I will share with a beginner friend!

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

    The way you talk are really down to earth and helps me...as a self taught programmer to know that I'm not alone.
    Thank you. Subscribed!

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

    Great video. I'm self taught for the last 20 years, and I wasn't really sure what "Antipattern" really meant; thanks for the clarification. Number 4 is Don't Repeat Yourself (DRY) which is very well described in The Pragmatic Programmer.

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

    Here's a like and a comment for the RUclips algorithm because I love you and appreciate you, Andy.

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

    I expected the advice of keeping functions small.
    There was a study that found that programming errors became noticeably more likely whenever a function was longer than could fit on a developer's screen.
    When a function gets big enough to break that barrier, look for any kind of functionality that you could place into its own function.

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

    This was a very valuable video, tons of information being said here. Love the content Andy!! can't wait for the next one!

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

    Naming things is hard. I often find myself thinking about names and googling synonyms for minutes.

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

      One of the most challenging parts of programming for sure 😊

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

    This was really insightful Andy! Good stuff.

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

    See more of Andy's videos to find out about the purgatory anti-pattern! That outro is dope!

  • @johngeverett
    @johngeverett 4 года назад +21

    I've been a developer for over 4 decades. I'm telling you, this guy knows what he's talking about.

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

    Great video. I am also a self taught developer, been doing this for 40 years now. I am curious about your comment on testing in regards to lava flow. I have found that automated unit test specifically helps with this. When I am coding a new function, where an automated test is possible, I write the test first, then the function.

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

    It's a really nice feeling watching this a discovering I've stopped doing those a long time ago.

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

    I'm liking these things because everything you are talking about, has a big warning sign in my class. What do you think is the difference between a self taught and school raised.
    I'm doing online school and it's awesome because I dont have anyone to turn to amd ask for advise on the fly, so I'm forced to think even harder on certain things.

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

    I like your term "lava code" :) nice mental image of what's happening. I think the best thing is to try to complete projects as often as possible so you experience how bad these things are as quickly as possible.

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

    And it's a very good practice to have 'Programming Buddy', I mean to have someone to give them your programs to debug them, because sometimes we are too 'infatuated' with our creation that we can't see the shortcomings. Just like a mother who can't see their children wrongdoings. So to have coding buddy gives us the opportunity to see our code from another person perspective, which is extremely helpful to find bugs or improve our code.

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

      Or go away from your code for.a while ... like a day or two or a week. When you return, review your code again; it will be like you are seeing it for almost the first time with fresh eyes. You will see issues that you didn't see previously.

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

      @@BruceBigby good advice.

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

    I learned a lot from your vid and asimilate couples of things that often happen, even to me. Liked a lot, dude! Cheers on!

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

    Hey Andy are you still accepting calls. No times was no times available when I went to schedule

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

    If there is one single advice I would give new devs is to understand and master what SOLID means. Nice channel with good content Andy!

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

    Another good telltale for needing a named constant is if a value is tied to a business concept that's fairly unchanging, like a company code or location ID. Thanks for sharing!

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

    I find myself occasionally still doing the first two. I have been trying to unlearn that habit, but it's not that easy to get rid of, especially when you just want some code down quickly before your mind starts to wander and you forget what you were doing (I have trouble staying focused for long)

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

    Okay, sounds like programmers would LOVE "Table of Content" and "Index" like page from books.

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

    Great video for me as a beginner! Thanks a lot.

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

    Hello Andy,
    Are you still doing online call for people who wants to become developer?

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

    As someone who is largely self taught, has a computing degree.
    Naming. This is a tricky one, the Code Complete book that others mentioned (an excellent book, that I recommend every developer should read, I still pick it up occasionally). Anyway, that book has a whole chapter (around 30 I believe), in naming things. The goal of code is that it is clear and concise. Sometimes just naming something x is enough, like if a function only uses/ returns one variable because the name of the function already (or should) tell what x is.
    Another great/ essential book is Head first design patterns. Patterns are powerful tools that can be used to solve problems without having to reinvent the wheel. A mistake beginners make is that they try to use patterns everywhere even when a pattern is a poor fit. Things like DRY are adhered to like a religion when breaking code up further only makes it harder to understand. There's often many ways to do things, with some better than others and more complicated than simply right or wrong.
    Last tip is to spend time learning data structures, it may not feel like much fun, but it will massively help you in the long run.

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

    Thank you Andy! Extremely helpful

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

    I've been known to make too many code changes at once, and...have to backdate whole versions, testing source file after source file, after source file just to pinpoint what I broke.

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

    The easiest way to resolve the third pattern is to ensure you're decoupling your code as much as possible. Controlling dependencies is critical. If you have to cut and paste code, rewrite code so you don't have to, create a method that each part of the code can use, then you're only managing one method.

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

    first minutes this guy speaks so much i thought like this but when i understand the subjects it is very useful and good shot.please give some more example.

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

    I have been teaching myself C# via Unity almost daily for the past year. I have one strong recommendation. When starting out, and learning how your codes function, take the time to build small test programs. This will deepen your understanding of the code, and how to make it work well, instead of just work. I stumbled through Unity's low level networking API to get my software working, only to have what I did hinder my progress for over 4 months. I recently built a small test system to really understand what was happening during network connections, disconnections, messages, etc. and only then did I realize I had hobbled myself months earlier. Happy to say that my programs are running twice as well as they were before, simply because I took an hour or two to make a test program. If I had done so in the beginning, I would have saved myself dozens of hours of trial and error.

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

    Wow, it was very helpful.
    Thankyou ❤

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

    thanks men. i love people looking the big picture and giving such advice. i have kid. what is your advice for kds age arround 6 to12. learning programming

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

    11:01 numberButton(e) what is e? What happened with the first rule of this video?

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

    These are really great tips, thank you.

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

    What camera do you use ?

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

    Very valuable advices. Thank you.

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

    About Version Control: Do you recommend to squash the commits when merging? Sometimes my commits are kind of chaotic, especially if I'm trying to fix a bug, they sometimes look like this:
    "Tried to fix X, but still not fully working"
    "Fixed X"
    "Fixed Y which got broken because of last commit"
    I wonder if it is actually important to know the individual steps afterwards how a bug was fixed, or one commit "Fixed X" would be enough. I think "Work in Progress" commits like these kind of add clutter to the history and make it confusing to follow along.

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

      A commit message should say something about the code change, not "Tried fix X, but still not fully working". That doesn't say anything about the code change you have made. I use the conventions described in this blogpost for my commit messages: chris.beams.io/posts/git-commit/

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

    It's a big help for me!

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

    Is Bachelor of Computer Application's BCA is good course for learn cooding and as well as to enter in IT field ?

    • @Ram-fd9er
      @Ram-fd9er 4 года назад

      Which department not really important . Only thing important is you've to be passionate on your work . Nowadays self taught developers as are ruling the world . So be it , learn throughout the life

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

      @@Ram-fd9er Thanks for your helpful reply

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

    Learning about good practices and *security* it's always hard for me, I'm moving really slow

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

      Use some code scanning tools to help. Some tools even have advanced cut and paste detection that spot the issues that cutting and pasting can cause.
      Glad to see you are at least wanting to bake security into your code. Keep it up.

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

    Am 18 yrs am trying to learn coding,
    Please which programming language is the best to start with

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

    An exception to the long descriptive variable names is when you're writing scientific code and you're following a convention e.g. a position vector in physics is often just denoted by x. Also this helps with readability in complex expressions.

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

      Similar thing with loop variables. It's a very common convention to name these with i, j, k, etc.

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

      @@zombiedude347 Also counts are often denoted by m or n, e.g. number of items, dimensions or iterations.

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

    That first point is teached from the beginning in the head first books, and it's great, i hate when i see names that don't explain what they do

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

      It can be very frustrating when you are reading some code that doesn't make sense. I've been guilty of it in the past so I can't be too mad about it haha

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

    Is that a MSI GTX 1070 Ti ARMOR on the shelf in the background ? ;)

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

    I'm not a beginner, but I've been dealing with someone else's 3rd and 4th antipatterns in a lot of code lately and spending a lot of time on fixing them up.

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

    I remember i struggeld with naming. And i still do. Now i do it like iAddNumbers i for interger. Or aNames, a for array and so on.... but it is easy to think it is like math, where u usually have one character for variables. Good video.

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

      Please, please, please don't use Hungarian notation. It's unnecessary, very unpleasant to read and has so many limitations and drawbacks.

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

    I just started jr dev. from a company which uses perl/php/jquery. My first ticket is a simple bug that displays wrong error message. Digging the backend code has put me looking at 10+ nested if/else, for DAO coded in Perl. It was horrible code. And the thing is it was coded by the lead dev. I feel sad right after.

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

      Imagine all CRUD in if/else blocks.

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

    One anti-pattern I often see is parallel arrays/lists where related data is stored across multiple collections instead of one type/class to hold the data and then one collection to hold each set of data.

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

    Good content. By the way, do you work in front-end?

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

    Genius! I am a self taught programmer with now 35 years experience. This is EXACTLY correct. When you are coding it is all clear in your head. So you can follow all your shorthand naming etc. 6 months later your code will look like someone else wrote it. Dont follow these rules so others can read your code, do this for your own sake so you can understand it.
    And do good layout of your code so its clear. Don't put multiple statements on the same line to save a carriage return. I have a party trick of identifying the location of bugs without reading the code. I scroll it super fast so it is a blur. When I see a "lump" of multi-line code, 90% chance that's where the bug is. I don't even have to know the programming language. Crappy layout = confusing code.

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

    Judging by the code I've seen most developers write, naming functions is easy. Simply choose from this list. "Setup","Init" "Build" , "Load". What should the function do? Anything you want. Extra points for performing multiple unrelated tasks and extending your function across three or more pages.

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

    Is that a uni qlo hoodie? I just bought the t-shirt version for my son in blue.

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

    What I would like to add to ambiguous naming: Usually, the smaller the scope of the variable, the less specific the name has to be.
    In a for loop, it is totally okay to call the counter "i" instead of "index". As well, if a method is called "getCustomerList", you do not need to call the variable you return "customerList", "result" would be specific enough because the function name already says what the result is. Or if you have a swap method, it's totally fine to naming the parameters "a" and "b", the names "firstNumber" and "secondNumber" would add no meaning.

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

    Love your videos Andy

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

    CLIFFS: every programmer should watch Uncle Bob Martin Clean Code Foundations Episodes 1 2 and 3! Seriously, will solve most of these "rude code" anti-patterns. TDD and make it work then Extract Function like crazy FTW!

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

    I often have reverse cut and paste. I always try to not repeat code and always end up in a situation where I need a function to do the same thing as another funcion but sliiightly differently. But still different enough that I can't just add a variable or two and use the same function in both places. Also multifunctional functions are much more difficult to name.

  • @Mighty-Mag
    @Mighty-Mag 4 года назад

    Is there a mentor in the Tampa, Fl area? I’m learning Flutter/Dart. I’m strongly motivated. I need to get out of construction. I am starting a family and need to be a better father and husband example. Working hard isn’t a problem.

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

    Very nice video, congratulations. I would like to comment on the book example at around 03:10, for ambiguous names. The problem with the metaphor is that a book written with extensive vocabulary that makes you consult a dictionary frequently is GOOD, not bad. You not only enjoy the book (hopefully), but you also learn. Reading words you didn't know is positive. Ambiguous naming would rather be like an author naming all his or her characters with random strings of 20 digits, so each time something happens to someone you would have a hard time guessing who it happened to, without constantly looking up a table, and probably even confusing a character for another one, because they differ only in the 17th digit.

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

    leaving dead code just because i scare is the worst to deal with as a beginner programmer :D i believe will be better with more practice. amazing video thanks

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

    Which do you think is better: "#define EARTHRAD 6371e3" or "const double EARTHRAD=6371e3"?

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

      The latter is better.

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

    About Magic String / Numbers: Would you then agree that Javascript is badly designed? Because it is full of magic strings and numbers. E.g. window.addEventListener("click", ...) or if (response.status === 200) ...

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

    Thank you sir! I will check Git to manage bigger projects better. 👍

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

    When I was reading scientific journals in my one class in college I had to keep stopping every second to look up words lol

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

    Good variable names are more important the more long lived the variable. There is nothing wrong with using "I" or "N" for a loop index or a short variable name if the variable is only used in a few closely referenced lines of code.

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

      Using “i” inside a for loop is pretty standard practice. That’s one of the few places where I think it’s appropriate to use.

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

      @@AndySterkowitz n for a count, c for a character, p for a pointer-these are all fairly common and idiomatic, especially in string manipulation.

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

    I keep doing the lava thing to myself lately. Thank you for reminding me to branch. Won't happen again!

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

    Thanks - good advice

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

    05:47 or better: You could have those configuration constants in an extra class, so that you can mock this configuration for unit testing.

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

    Re: magic numbers: These can be the source of some nasty bugs, especially in embedded software. Hard coded numbers for memory allocation, for example, can remain dormant for a long time until that right circumstance comes up to break the software. Don't assume that the number is "appropriate" (like 21 for drinking age) or the "right size" (as with static memory allocation). Always code for flexibility and a dynamic environment.

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

      OTOH, don't be anal about magic numbers that are really, really self-explainatory and not likely to change over the next century. if(minute>=60){minute = 0; hour ++;} - are you seriously going to #define MINUTES_IN_AN_HOUR ?

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

      @@sharpfang yes, because if for any reason someone wants to change the frequency of execution or something or has any other random reason to change this number, because pattern switched from minutes in an hour to hours of a day and the smart junior developer goes all like "I got this, replace all is my friend" he overwrites the other thing were the 5 dozen egg crate capacity is hardcoded. Cost you nearly nothing, especially with good IDE, and makes life so much easier. Don't be the smart junior, don't be me 15 years ago

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

      @@patrickebert5748 So, you think that changing the frequency of execution is best achieved by changing the number of minutes in an hour. And a code that has minutes_in_an_hour=80 is a better code, and someone trying to determine why a function launches 9 times a day when it should launch 12 times will have an easier time debugging this.... because seeing if(minute >= minutes_in_an_hour){ minute=0; hour++;} will obviously make it clear the hour changes after 80 minutes...

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

    I'm not a seasoned developer so I'm going to stick around.

  • @benhbr
    @benhbr 4 года назад +97

    5:05 should be if (age >= 21) :P

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

      I see you just used an antipattern. Have a look at the "Magic numbers" section of this video.

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

      @@TheObliviJohn I think he sees that. His point is simple that the equal sign was missing because if you are exactly 21 you can drink in the USA

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

      if (legalDrinkAge < age) is better in case of mix '=' with '==' ;o)

    • @keeyan2166
      @keeyan2166 4 года назад +17

      @@jankomuzykant1844 this is being very pedantic but I prefer the variable on the left since it reads like that is the one that changes and you are checking for.
      Like in English we would say if you are over the drinking age. Not the drinking age is below you

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

      @@keeyan2166 With some experience it's O.K.

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

    Commenting as you code as well as always initializing README's are two other points I would touch on

  • @Alex-zr7wr
    @Alex-zr7wr 4 года назад

    Ok, after having read all of the comments, it sounds like clear organization is the achilles' heel for programmers (myself included).
    What are your biggest complaints or your best advice for organization?
    Thanks,
    Noobie programmer

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

      Give everything a meaningful name that describe what it does or what it's used for. If you don't know how to name something, you can probably do without it.

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

    I'm on an assignment where I pointed out that several files I was in didn't even need to exist if we just used a consistent naming convention to our environments. Huge chunks of code could be removed and streamlined and hundreds of lines of business logic for special cases removed by taking a more consistent approach.
    Then, for the first time in my life, I heard the term "DRY" being used almost derogatorily. The only time I ever got to hear a positive programming principle, and it's used by the lead in a negative connotation. "Code doesn't need to be too smart. You don't have to be too DRY".
    I thank god almighty I only have a few days left at this place. :D

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

    So the thing about naming: I like to use descriptive variable names when I'm dealing with identifiers that are globally visible, but if it's an identifier that's only visible within a small function, I tend to use shorter, less descriptive names.
    In general, the lengths of my variable names tend to be proportionate to the size of their scope.

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

      Why though? To save a little bit of time? You should write names as if someone else will read your code.

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

      @@lennysmileyface I still make sure that they're descriptive enough to be obvious. It's just that when I'm dealing with the global namespace I have to be more mindful about potential name collisions.

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

    I started doing html5 and CSS3 2 months ago, my first website had 1006 lines of CSS , yesterday I rewrote it, now the website does the same but it only has 406 lines in the CSS file lol, I'm sure that when I know what I'm doing I'll be able to make it even smaller.

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

    For me, variable names like $x, or $a, etc are temporary variables. For example, I might store database results there before I process it and then discard $a.

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

    About the naming, we get that from textbooks/teaching sites that give us examples and name a function myFunc().........

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

    I have something to contribute. As the worst programmer ever, this one is very important to me. Which is, don't just type type type type up a lot of code. Test it EVERY step of the way as you write it. Test every little thing as you add to it. Because what I'll do otherwise, is find there are 100 different bugs in it at the end, and debugging it is like guessing the combination of a 100 combination lock.... in other words, even if you fix a bug, your program won't work and you maybe can't be sure that the thing you just fixed was something that should be changed because what you just did didn't fix all of what was wrong with your program and maybe it should have been the first way before and you just made it worse.

  • @KineticCode
    @KineticCode 4 года назад +87

    TLDR=
    Read "Clean Code" by Uncle Bob

    • @shiskeyoffles
      @shiskeyoffles 4 года назад +24

      Too long don't read...
      But read an entire book??

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

      And then realize it's for developers that have unlimited resources and no project manager pressure 😉
      No, seriously. His books are great and understanding his opinions and common patterns he shows and why they make sense (to a certain extent, some things that uncle Bob mentions are definitely arguable) is important. Still, in the real world, you may not always be able to incorporate clean design decisions everywhere.
      Also what's considered clean is arguable. If you throw in generics everywhere just to satisfy DRY (don't repeat yourself) and then obfuscate the code with the generics and make it hard to understand for beginners may not be the best decision if you have a team of junior developers.
      I am a developer for over a decade now and I have seen very abstract code. The thing with code that abstracts everything nicely is that commonly only the people who designed it easily understand it.

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

      @@jacqueskloster4085 This is a really good argument. I'm also very susceptible to writing these "beautiful" abstractions which can't even be named right 🙄

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

      and/or Code Complete by Steve McConnell

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

      lmao if you know the most common design patterns you will understand those „abstract code“ with ease.

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

    I agree with all the points here and urge people to take them seriously.
    However, I would not call these kinds of quality problems "antipatterns", but for example "bad programming practices". I tend to use the word "antipattern" for common patterns of bad design, as in design patterns. I think the word was popularized by the Brown et. al. book in the late 90's.
    The distinction between problems in design and problems in code quality is a meaningful one. For example if a variable is named 'a' and it in reality means 'username', it's a code quality issue. Refactoring to change the variable name after review is easy. But if the variable refers to an object with such widely varying responsibilities and convoluted structure, that a good name for it simply does not exist, the issue if more fundamental to the system.

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

    You are trying to describe an unknown "polthergeist" thing with just another unknown "abstraction" thing. Is it wise to suggest mitigating something that is hard to understand with another unknown and hard to grasp concept, such as abstraction?

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

    5:21 "==="?? i never saw that, what language is it?

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

      Javascript and PHP have == and === operaters because they are loosely typed languages. It checks the value and the type. That is:
      var magicNumber = "5";
      var sum = 5 + magicNumber; //sum is now a number 10
      This is most obvious with things that "falsey". Take a look at this PHP as an example.
      $x = null;
      if( !$x ){ //null is equal to false.
      //This executes.
      }
      if( 0 == $x){ //0 is equal to null
      //This executes.
      }
      if( 0 === $x ){ //$x is not the right type, the identity fails.
      //This does not execute
      }

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

    As a self taught programmer of a couple years, I have two modes. I just try to get some part of my code working, focusing only on what it's doing. then once I either have it working or my brain is just too fried to continue, I spend a few commits doing formatting, adding comments, renaming things and otherwise refactoring. I have no idea whether this is good or not but I've never had another person to work with to comment on it.

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

      It could become an issue if you work on a project with multiple developers. Maybe set up a local repo and only commit to the group repo after the cleanup phases?

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

    I worked in an old C# application in which someone thought it was a good idea to use reflection to jump to methods that handled every UI state in a Web Forms app. The naming was bad, like "lb_42", and the IDE was not of any help. It just showed that there was a lot of methods without any reference.
    You never touch that code unless you have to rewrite the whole application!
    Professional software development can be such dirty work when handling legacy code that has historically lacked code conventions.

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

      Once took over a project where the vars were named like „cr_42_bp_csr_vt_3“. Supposedly abbreviations that were meant to tell the dev something.

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

    Thank you so much!

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

    5:08 That doesn't include "21", though - only 22 and above. Oops.

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

    That first one about variable naming seems to be the standard in Go.

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

      Allen Hundley this is also what I thought when watching the video

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

    Tips: one of the best programming concept or style is to write your constant variable in CAPITAL_LETTER, and the words should be separated by underscore (_) example: DATABASE_CONNECTION. Thanks Andy

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

    I have seen a lot of these on the code I'm working at at the moment. I've been trying really hard to get the other developers to follow best practices, test their code keep it DRY etc. But they keep on saying essentially "we have deadlines and it takes too much time to follow all of these practices and test our code" :(

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

      That's really sad.

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

      @@exrebok1 tell me about it. I'm getting ready to quit now. Just as soon as I find another job (due to many other reasons as well)

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

    What about C and C++ built in functions? They have shitty names too (for example atoi).

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

    So i am taking a Treehouse Techdegree. Do you think your coaching will help me?

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

      you should be sure to be involved in the forums there, you can learn a lot from helping others.

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

      @@javabeanz8549 i do help people on their slacks. I dont browse forum much

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

    Just a thought. I already had a feature to add which sends emails. I kept it simple enough by following KISS since nothing else was specified. Then, I was asked to send emails for another reason. The logic was almost the same, so I thought I could refactor the code to reuse smartly the code, but I thought, by doing that, I would have to retest the already deployed feature since there were no automatic tests. I think I recopied the function back then, though I would probably have made the argument to remake it if many more variants were to come.

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

    5:50 pro tip: constants should have UPPER_CASE naming, so you know immediately that variable is a const

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

    i have a degree in Computer Sciemce but also consider myself a self thought.

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

    So #4 Cut and Paste is interesting. Everything you say is absolutely correct, I couldn't agree more. I am a lifelong PLC software developer however and there is a caveat here. In my world the end user of the software also maintains and even upgrades/modifies as needed. It is commonplace that the end user also has a very basic to nonexistent understanding of PLC code in whatever form it is written (ladder,structured text, function block, etc.). This is typical because the people assigned this job at the company (end user) are maintenance (electrical, hydraulic, mechanical, etc) and not programmers, just they have "some" programming knowledge. Because of this lack of knowledge it is common for us in the industry to intentionally write code in long form (copy and paste). I have seen many times that a perfectly great software engineer not get repeat work with a customer because of complaints that the code is "terrible". When in fact all that really means is that the end user does not know how to deal with neatly wrapped up functions that can be called on many times and instead needs to see everything written in the longest, most painful form possible. I have had projects containing many thousands of rungs of logic (or lines of structured text if you prefer) that could have honestly been wrapped up into a few hundred rungs while still being very easy to understand and follow. It is unfortunate that this is the case because it becomes of choice of: Do you want to do what you know to be programmaticaly correct? or do you want happy customers, thus food on the table? It is not much of a choice.

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

    I've just started using GITHUB. That is a wholly independent and powerful subject. Do a vid on that. Love the chan.