5 RULES to Write Better Code

  Рет қаралды 44,665

Andy Sterkowitz

Andy Sterkowitz

Күн бұрын

In this video I go through 5 different rules I use to write code that is easy to understand and maintain. These all come from my favorite book: Clean Code by Robert C. Martin.
CodePen Link for Digital Clock: codepen.io/andysterkowitz/pen...
📄 ** DOWNLOAD MY FREE STUDY MANUAL **
To download my FREE Self-Taught Programmer Study Manual PDF go to: andysterkowitz.com/study-manual/

Пікірлер: 163
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
This is one of the longest and most information dense videos I've put out in quite a while so I'd love to hear your thoughts on it. Leave me a comment and let me know if the video and the examples helped you out.
@logixindie
@logixindie 3 жыл бұрын
It shows. Really solid advices, we appreciate it!
@wolfiexii
@wolfiexii 3 жыл бұрын
Thumbs down - comments are king. I fire developers from my team for being terrible at documenting their own code.
@wolfiexii
@wolfiexii 3 жыл бұрын
The second thumbs down - YAGNI - is equivalent to don't think ahead and plan for flexibility and changing requirements. This is another huge failure of cookie-cutter devs that gets them fired from my teams.
@guitarman813
@guitarman813 3 жыл бұрын
Very good and useful video. Well worth the longer-than-usual duration. 😀👌
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
@@guitarman813 thanks!
@MrPDTaylor
@MrPDTaylor 3 жыл бұрын
Take a look at some of Google's open source code. Some of their variables are complete sentences.
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
Love that!! :-)
@iandrsaurri625
@iandrsaurri625 2 жыл бұрын
I agree with everything except the commenting thing. Everyone who tells me that their code is "self-describing," I usually cannot read that code. It is usually terrible. People who comment a lot, I have noticed also follow the other best practices because, they care A LOT about readability
@joshb.9380
@joshb.9380 2 жыл бұрын
Some of these suggestions I've kind of picked up during my studies or intuited, but I definitely appreciated the confirmation that my thought process was on the right track! I'll renew my focus on keeping my code more readable.
@mexiangel1994
@mexiangel1994 2 жыл бұрын
i actually went back through some of my code and was like yep that function has a noun and not a verb as a name. lol very helpful because as a begin you don't know the correct way to do all the things until someone point it out. it like speaking or writing another language there are just some formal things that need to happen. thanks for the video
@davidgagnon3781
@davidgagnon3781 2 жыл бұрын
These rules are classic. With the right procedure names and variable names, your code becomes self documenting.
@aaRept
@aaRept 3 жыл бұрын
Fantastic video! Thank you very much for putting in the time to make these.
@BearDigitalStudios
@BearDigitalStudios 3 жыл бұрын
I agree! Name your variables properly will help. It has caused so many headaches for other people reading my code. Wished if I had this advice a few months ago😥. Thanks, Andy - keep at it this was helpful👨‍💻
@thorntontarr2894
@thorntontarr2894 2 жыл бұрын
I did enjoy this set of 5 rules because they solidify how I write except w/t comments. I now understand your point of how comments can get in the way or be harmful and if the previous 4 rules are followed, then #5 is easy to understand. I learned a lot with this video and will start now getting them into my rhythm of writing.
@darkomarkan
@darkomarkan 3 жыл бұрын
One of your best videos, very concise and helpful. Would like to see more videos like this with advices and practices in programming, maybe some project walktrough :)
@benjaminasher1054
@benjaminasher1054 3 жыл бұрын
All useful tips, thanks! Particularly find that descriptive variable and function naming makes code just flow so much more naturally, both during writing and for later readability!
@kabiskac
@kabiskac Жыл бұрын
twentyFour as a boolean made perfect sense to me instantly, I have no idea what military time is...
@benjaminnelson70
@benjaminnelson70 2 жыл бұрын
Okay so I understand both sides of the comments vs. no comments argument. I would like to see a video of appropriate times for a comment. I also think its a ridiculous premise to fire an individual for not commenting. If you have a complicated app that you feel the dev should add comments to then instruct them to do just that. Andy I see and agree with its a more practical approach to rename variables and functions that essential tell you what they do for the app. Thank you for your efforts and instruction. I myself have just decided to reorganize my life to attempt to be a programmer after a 9 year set back.
@acopperlily
@acopperlily 3 жыл бұрын
Yes, absolutely, I am the type of person who benefits from explicit examples, so I found this format to be extremely helpful. Even though I haven't learned any JS (not yet, but soon), the code was easy to follow as a student of Python and C. Thanks for the tips!
@Goaty1704
@Goaty1704 3 жыл бұрын
Hey Andy, really great content! Although I‘m no beginner by any means. Watching you explain principles and you being so relatable in your videos made my day! ❤️ Maybe a video on Unit testing and common patterns would help junior devs to be more keen on this topic
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
Thanks, will do!
@acopperlily
@acopperlily 3 жыл бұрын
Another vote for unit testing!
@daniellelindblom7753
@daniellelindblom7753 Жыл бұрын
This is really informative and helpful. Appreciate the examples!
@haronclement
@haronclement 3 жыл бұрын
copy&paste from stackoverflow: The idea behind "self-documenting" code is that the actual program logic in the code is trivially clear enough to explain to anyone reading the code not only what the code is doing but why it is doing it. In my opinion, the idea of true self-documenting code is a myth. The code can tell you the logic behind what is happening, but it can't explain why it is being done a certain way, particularly if there is more than one way to solve a problem. For that reason alone it can never replace well commented code. .
@yandhi4202
@yandhi4202 2 жыл бұрын
10:38 "mon is that for 'hey mon'?" 😂
@an93lofdeath
@an93lofdeath 3 жыл бұрын
Clean code is a good book to read for more like this.
@huhtj4234
@huhtj4234 2 жыл бұрын
Yes sir, going into my Junior year and I read the book Clean Code this summer. Definitely aligns well with a lot if not all of the points.
@22RH544
@22RH544 2 жыл бұрын
Very small downside to short functions is that function calls might not be free (depending on the compiler/interpreter) and might introduce slowdowns when called millions of times in a loop. I see many people write functions with a single line of code as the body of the function... In my opinion that should not even be a function.
@HansBezemer
@HansBezemer 4 ай бұрын
Exactly my point. Building and breaking down stack frames is not free - far from it. But it is a consequence of people thinking that they have so much horse power under the hood that it doesn't matter. That's why I still like a preprocessor to be part of my stack. You can wrap small functions into a macro, so they get inlined. I also pointed out elsewhere that the whole clock wrapping (including 24/12 toggle) could be put in a single statement (hour = isMilTime ? ((hour + 11)%12) + 1 : hour % 24;) and the whole isMilTime toggle could be expressed like "isMilTime = !IsMilTime". No need to make a function like that. I'd write it like: #define ToggleMilTime(a) (a)=(!(a)) Same readability, no need for a function.
@aldrchase
@aldrchase 2 жыл бұрын
Really great video. Thanks broski
@nyghtwyng
@nyghtwyng 2 жыл бұрын
The best thing about variables is that size of the name doesn't matter at runtime. Before you compile the code, sure, the longer name takes up space, but once compiled, the size of your variable name is irrelevant to the code. For comments, I typically use them to break up the code visually, more of a roadmap than necessary information. For instance, I might group all of my Public Methods under one comment and Private Methods under another. Totally spot on about descriptive functions and variables though. I remember working on a project getting my degree in graphic art/game art, and trying to help fix a program that wasn't working. Spent a half day trying to figure out what the variable "s" was used for; turned out, nothing at all relevant to anything going on. I think it was an unimplemented speed parameter, but as the guy coming in after someone else coded, I had to work that out for myself.
@o0bscure
@o0bscure 3 жыл бұрын
i love those kind of videos, keep them up man :)
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
Thanks Mohamed...will keep it in mind!
@myth5002
@myth5002 2 жыл бұрын
This was actually pretty useful, thx :D
@rafaelrodriguessilva9994
@rafaelrodriguessilva9994 2 жыл бұрын
Great video!!! Thanks!
@lacis9546
@lacis9546 Жыл бұрын
twentyFour tells me a lot more than military time. But I agree with your concept to use clear, telling names even if they tend to be long. 2:07
@immersivestudyandliving4272
@immersivestudyandliving4272 3 жыл бұрын
Helpful tips, thanks!
@Xarzith
@Xarzith 3 жыл бұрын
Thank you for a few very good advices! I admit that I still fall into couple of these in my projects (namely the naming and overcommenting) These are great pointers for starters, though I do disagree in comments in couple of things... First off, I love comments when planning in the code editor. I often add the functions/methods I know I'll need and simply use comments to write the functionality in pseudo code or simple few word lines. These won't be saved in the final function, but offer a great way to plan ahead how each function works. Secondly, I wish to bring out editor related assistants (like Javadoc style comments and summary tags in C#, for example) when creating larger projects or libraries. While it's true what you said about the importance to update these when the functions/methods are updated, it's a great tool when you and the other devs are using the same IDE or editor with IntelliSense or similar as these do provide tool tips for the user. Of course these two examples are related to workflow and larger projects for maintenance, not for people just getting into coding or doing some smaller project that can easily be read if the function, method, variable names can be used instead. I'd also wish to bring out the namespaces as a solution (or extra challenge) for the naming concept. Namespaces are a great tool for larger projects and commonly left along for smaller ones. The naming of namespaces takes an extra step from naming variables, functions and methods as these are one new world - in a sense. Lastly, I'd encourage people who start to learn how to code or try to start their careers as devs, to pay some time to learn how to plan their projects. There are many ways to do this and the easiest is pen&paper (just as we used to D&D in the past *smirks*) - I'd suggest familiarizing yourself with concepts like: - learning class and sequence diagrams with UML - roadmaps and milestones - Scrum/Agile/DevOps Personally, I like planning with comments in the source code for smaller projects, doing UML for larger ones and tracking the project and it's process with tools like Trello or Jira.
@ShashotoANur
@ShashotoANur 3 жыл бұрын
These videos are so insightful.
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
Glad to hear that Nurul!
@adamhowley8037
@adamhowley8037 2 жыл бұрын
More of this!
@delaboadum972
@delaboadum972 2 жыл бұрын
Very informative, I've learnt something here
@WifeWantsAWizard
@WifeWantsAWizard 7 ай бұрын
(4:05) I'd like to mention that while this is not a Unity project, some IDEs have required function names and "Update() { }" happens to be one of those functions where if you change the name it will break your whole project. The same with "Start() {}". (15:18) In case anyone needs it (in C#): public static int sumOfAll (int[] inputArray) { int sumToReturn = 0; foreach (int thisOne in inputArray) { sumToReturn += thisOne; } return sumToReturn; }
@13thravenpurple94
@13thravenpurple94 8 ай бұрын
great video thank you
@seekingcodemastery3813
@seekingcodemastery3813 2 жыл бұрын
I have a python background so looking at the example of the function that was doing all those things my first thought was put that function into a class and break-up all that functionality into modules. That could offer more flexibility in terms of adjusting the module maybe, adding or subtracting things inside the module. Just a thought.
@milakim5139
@milakim5139 3 жыл бұрын
Insightful. Thank you
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
Cheers!
@martijnb5887
@martijnb5887 7 ай бұрын
isMilitaryTime does make even less sense to at least a non US audience, as normal time is 24h and 12h is just US time. The fact that twentyFour is a boolean made is meaning clear, though not sufficiently explicit. Apart from the example, the point is very valid.
@chessclub92
@chessclub92 Жыл бұрын
Thank You
@jesseburstrom5920
@jesseburstrom5920 2 жыл бұрын
Connect classnames to filenames also each class have many files obviously. Also Nullcheck gives restrictions to class variable creation other than _(private signifier) make sure to initialize all variables with standard. Then add functions to reinitialize. Always create objects explicitly (due to null safety but also neat to have intent in code have object dot!) Camel non camel is good for variables. Split code in different categories and make them be as self contained as possible. Use simplified programming like always do if then with {} and stick to it as far as possible don't use shortcuts just simple code gets the job done and is simpler to read no surprises ok?! and many more rules to make the code uniform and simple as possible to read. I have project been rewriting it last 6month almost no new features just better structure... Great tips great video!
@alex-suciu
@alex-suciu 3 жыл бұрын
YAGNI - definitely need to learn that one 😅
@nikolakosanovic9931
@nikolakosanovic9931 3 күн бұрын
1:55 It made sense to me instantly I would probably name it is24
@moshemaor1731
@moshemaor1731 Жыл бұрын
Hello Andy. Thanks for your imformative and clear video. Although most of the points I new before, It is nice the hear them a from a professional. I write programs for myself, but I am not a professional developer. In addintion, I have some easy questions to ask: 1. Which font did you use in the code of your demonstration? I like it. 2. I guess you use Visual studio, me too. I managed to change colors to most important object, but could not find, where to change Background and font color for Menu, Properties and solution explorer windows. Thanks for your help and all the best. Moshe.
@sinhue
@sinhue 3 жыл бұрын
Great info bro! 🤟🏼😎
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
Appreciate it!
@johncerpa3782
@johncerpa3782 3 жыл бұрын
Great video
@asagiai4965
@asagiai4965 2 жыл бұрын
Functions is not always a verb though or sometimes it is hard to come up with a name. If not a verb much better to say the output of the function as a name or something.
@imyasuka
@imyasuka 7 ай бұрын
That was a roller coaster, a devastating one, first of all twentyFour is perfectly understandable in a clock project context, it's also perfectly recognizable as a time format in any other context besides in America, changing it to isMilitaryTime not only makes it unrecognizable for people who don't know what military time is, it makes it unrecognizable for the rest of the world. That is an argument not only for the initial rename, but for the fact that names can always be ambiguous. Next, the main/update function, a function of such a generic name is always destined to do multiple things and you can't expect it not to, you ended up changing it's name to renderDate which didn't describe what it was doing so you fixed your own problem by extracting all that is not renderDate from it and moving it to the now new main function that is anonymous gaining an additional layer of nesting in the process. Now, why anonymous? Hello, it doesn't have a name and setInterval certainly doesn't describe what it is doing, it's also doing multiple things, huh? Wouldn't that mean that anonymous functions shouldn't exist according to these guidelines, because to me it definitely would. And lastly, comments, the problem with then in the given project was not the comments themselves, it's that it was overpopulated with them. When there is a lot of comments there is no doubt the descriptive quality of them will go down, it will also go down when you drastically change the function it's describing like you did with the update function. Yeah, comments that focus on something become outdated over time as the subject of focus changes, but really shouldn't they? They are needed when you want to read some piece of legacy code, maybe even your own after 3 months to get a more clear idea of what a thing is or what it does, which level proper naming typically can't reach, of course they are gonna get dated if you directly change what they are describing. The point of this rant is that clean code is inconsistent because all code is inconsistent. Stick to what you understand best or what you agreed to stick to if you are working in a team, because such vague standarts won't live up to the standarts, to the conrete ones.
@lararawf6100
@lararawf6100 Жыл бұрын
Good bless u
@Beachalex1
@Beachalex1 2 жыл бұрын
While it's true that one doesn't need to (and probably shouldn't) comment every single LOC, I find comments really useful when working in teams or with big projects. You'll come across the other people's code quite often. They write functions, import libraries, and make database calls that will yield results that you might use in your part. It's just impractical to log all the db call results, read the docs of libs that you won't be directly using, or read though the entire function every single time. If your colleagues are nice enough to write some comments about thier funcs (what it takes and what it will return and in what format and data type), it will make your life a lot easier. Without them you'll probably have to figure it out yourself or give them a call if you're WFH.
@devgatling
@devgatling Жыл бұрын
good shit!
@BusinessWolf1
@BusinessWolf1 2 жыл бұрын
thanks
@SkamanSamTyler
@SkamanSamTyler 3 жыл бұрын
I really like this video, but I think a little terminology would go a long way: semantic naming, command pattern, etc.
@pierreabbat6157
@pierreabbat6157 3 жыл бұрын
The order is year, month, day, hour, minute, second. If someone wants it in day/month/year order, set a flag as you did for 24-hour time.
@salkjshaweoiuenvohvr
@salkjshaweoiuenvohvr 3 жыл бұрын
Good stuff in this video. I'll take to heart the advice on comments
@Cele1161
@Cele1161 3 жыл бұрын
Same :)
@childchernobyl998
@childchernobyl998 3 жыл бұрын
Good video. Thanks mon!
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
Glad you liked it!
@user-sc6vy4tw6m
@user-sc6vy4tw6m Жыл бұрын
I've seen people name a function or an object method that returns a string, a number, a boolean, or any other non-function values with nouns or with verbs. Both ways seem reasonable. Curious about what's your take on this?
@bb579774
@bb579774 3 жыл бұрын
Thanks for shredding my code! 😅
@dopavelli
@dopavelli 3 жыл бұрын
started my first dev job three months ago and can definitely relate to most of this :D :D especially the Y.A.G.N.I. :D :D
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
I used to obsess over everything when I first started as well :-)
@henriparviainen4398
@henriparviainen4398 3 жыл бұрын
When I saw variable twentyFour I instantly knew what it was trying to accomplish. If I would saw isMilitaryTime variable, I would think wtf is military time?
@mrmiyagi5
@mrmiyagi5 2 жыл бұрын
Military time is when you click the button it deploys the military :). American colloquial lingo...24 hour clock rest of the world.
@PutineluAlin
@PutineluAlin 2 жыл бұрын
Agreed I would name it "isTwentyFourHoursTimeFormat" No joke you end up naming the variables in german format with long sentences or you know just add good comments to help you identify everything including a first paragraph of text comment that explains everything like a journal. Sadly this is the only way to retain information once you finished the code.
@solprovider5385
@solprovider5385 2 жыл бұрын
Good. Bad advice before 2 minutes in. Good others are correcting the nonsense. Is12hourTime() or useAmPm() suggest time format uses silly USA-only system. Functions should be understandable by international programmers. Datetime should use a format (or language-country indicator) not a collection of functions. This is as bad as have NameFirst and NameLast fields instead of NameFull, NameLegal, and NameShort fields. Think ahead. Think. When creating function signatures, the next morning, try to use the function without looking. Then fix the signature to match what you expected it to be.
@nyghtwyng
@nyghtwyng 2 жыл бұрын
@@solprovider5385 And yet, you understood what he was trying to convey. The example was to get you to think of an appropriate naming convention for your variables. Personally, I have yet to work for an international team, and wouldn't waste two seconds researching NameFull, NameLegal, and NameShort, because it would make no sense the the US developers working on it. Not every team outsources internationally. But, if you are working on an international team, that makes sense. I would simply counter that as a good programmer, you should be taking into account everyone involved. Of course, I'm a programmer who believes the end user should have input on the functionality of the product being developed, which occasionally makes me odd-man-out when it comes to programming. ;)
@solprovider5385
@solprovider5385 2 жыл бұрын
@@nyghtwyng I am American. I understood because beginner mistakes are common. Tutorial videos should teach good development, not replace worst mistakes with barely better mistakes. You do not need an international team to have NameFirst and NameLast cause problems with Indian, Hispanic, and even European names. - A large American company HR entered an Indian name 3 ways creating 3 records, corrected by deleting one and terminating another. Years later, the employee still had paychecks disappear. - Same company had Vincent Peter LastName III who preferred Pete and rarely used suffix. Medical insurance system failed to match his name and assumed he was no longer employed. Business has input into functionality. Business should not decide implementation. Every software development team needs one Great Solution Architect to avoid mistakes.
@reyreyalldayday5708
@reyreyalldayday5708 2 жыл бұрын
yeh my code is crazy. post bootcamp react, deprecated everything lol 3 different ways of styling and random stitched together hooks. but it works!! kinda ha
@akaemeikechukwu7082
@akaemeikechukwu7082 3 жыл бұрын
Superb explanation but comes with experience. Also, the download kept failing on me. I don't know if someone else has a similar Problem downloading your Material.
@felixmusau7594
@felixmusau7594 3 жыл бұрын
Helpful
@michaelgreene6441
@michaelgreene6441 2 жыл бұрын
Hypothetically if I have a function that is inside or a module is it acceptable in your opinion to allow that module to assist in the shortening of the name? For example “./controllers/thingBeingControlled” “function get() function del()” I’m realizing it would then be more self documenting to call it with Module.get() than just with get()
@solvedfyi
@solvedfyi 2 жыл бұрын
just give it a better name than get and del, extra characters cost nothing
@PerTrygveMyhrer
@PerTrygveMyhrer 7 ай бұрын
Military time would have confused me, where I live no one uses am and pm
@mivids100
@mivids100 3 жыл бұрын
Some good tips, and I’m guilty of breaking more than one of Andys laws lol
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
It happens...I probably break them from time to time to :-)
@joshadams8761
@joshadams8761 2 жыл бұрын
This video is so good that I recommended it to coworkers.
@unduloid
@unduloid 2 жыл бұрын
Hmm... since when is "toString" a verb? Also, writing very short methods tends to lead to the creation of a lot of methods that hardly do anything. Trust me: while debugging, the last thing you want is to hop between zillions of tiny methods that add nothing to the clarity of the code. Structure is key here. I would also like to introduce a sixth rule: Take as much time as you can and think things through. Don't fall for the myth of the programmer who is "ten times faster." I often have to deal with code written by such so-called super-programmers and find myself rewriting most of it because it tends to be a mess. I can especially tell when a programmer is an Uncle Bob worshiper, because I find myself merging methods together to make the code more readable.
@OttoAkama
@OttoAkama 3 жыл бұрын
In my CS classes, variables where names foo and ba, and the lecturers also used a and b. I think our Physics classes and text books had better story telling than CS books and classes. Maybe CS books and lecturers could bring more story in their lessons and begin to help with better variable names.
@web_mansoor
@web_mansoor 2 жыл бұрын
Sir what does the 5th Rule(Y.A.G.N.I) actually means could you explain it a little please...
@kinstar
@kinstar Жыл бұрын
You Aint Gonna Need It
@joaoganchinho4125
@joaoganchinho4125 3 жыл бұрын
Hello Everyone! I am an Industrial Engineer but i would really like to change to programming, but the town i Live in Portugal does not have much Jobs available. Do you think someone with no experience can land a job? Even if it starts as an unpaid internship?
@Beachalex1
@Beachalex1 2 жыл бұрын
Definitely yes, Sir.
@ademineshat
@ademineshat 3 жыл бұрын
Everything said was true until the comments section, I think comments are good for freelancers, most of the time when I go back to my code sometimes it helps! But as Andy said, sometimes it's disturbing, I change the code and then I should change the comments too 😅
@msascuinonducorduco
@msascuinonducorduco 3 жыл бұрын
I want to be a developer but it's difficult for me to be in class especially as a Deaf student when things are going much much faster, I just want something I can do at slow pace so I can practice and become better. I'm comfortable with HTML+CSS already, I just want to dip my feet in JS and possibly NodeJS, any tips?
@davidbhaskara6880
@davidbhaskara6880 2 жыл бұрын
Udemy, good courses with subtitles
@gold4963
@gold4963 2 жыл бұрын
These are awesome tips, and you've articulated them very well! It may just be me, but you seem a bit too close to the camera...?
@AndySterkowitz
@AndySterkowitz 2 жыл бұрын
Noted!
@iceman442ho
@iceman442ho 3 жыл бұрын
I think I have made all of those mistakes this week.
@ZelenoJabko
@ZelenoJabko 8 ай бұрын
24 hour is not "military time", it's normal time. While AM / PM, especially things like 12:40 PM, is a "joke time".
@stefan3191
@stefan3191 3 жыл бұрын
Personally I don't know what is meant by military time and standard time for me is the 24 hour format, so I'd prefer twentyFour over isMilitaryTime. So at the moment you renamed the variable to isMilitaryTime it made sense to you, but if someone else comes there it may not make complete sense.
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
There's always the risk that it will happen and for many variable names it is just inevitable that it will happen. The idea behind it is to spend some time and think through it so that it reduces the risk of confusing yourself and others in the future. You can always change the name later on after thinking about a more specific name but at the end of the day there are no perfect variable names.
@purduetom90
@purduetom90 3 жыл бұрын
@@AndySterkowitz I would have used an enum named something like "TimeDisplayFormat" that had two choices: "standard" and "military" or if those two names don't help clarify, the values could be "twentyFourHour" and "twelveHour"
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
@@purduetom90 if there were more than 2 states of the clock then I would agree. In this case since there are two states of the clock then a boolean is a clean solution IMO. Appreciate you sharing this!
@lordsombo
@lordsombo Жыл бұрын
militaryToggleButton would confuse me even more seeing that we don't call it military time. A better name would be ```is_twentyFourHourSystem```
@apmcd47
@apmcd47 8 ай бұрын
Actually TwentyFour is probably better than isMilitaryTime because outside of the USA we won't necessarily know what Military Time is. Better to have renamed it isTwentyFourHourClock because now you have a name that means the same thing to everyone.
@carlballenas1656
@carlballenas1656 3 жыл бұрын
Can i Continue Programming even I'm suck at mathematics???
@DukaSoft
@DukaSoft 3 жыл бұрын
The NEED for math in programming is a myth. Obviously it depends what the job is, but you can totally do programming while not being that good at math :)
@pavlg3944
@pavlg3944 2 жыл бұрын
Great video, just some thoughts : 1) kzfaq.info/get/bejne/p6iVl6eJyJfKhZc.html timeFormatToggle is enough i think, but may be if this variable is best omitted and chain called if not used anywhere else. 2) kzfaq.info/get/bejne/p6iVl6eJyJfKhZc.html toggleTimeFormat(); or alterTimeFormat();.
@chudierdak8711
@chudierdak8711 Жыл бұрын
"Hey mon"
@benja303
@benja303 Ай бұрын
- Variable names - Functions Should be short - Functions should do one things
@ArrowCodes
@ArrowCodes 3 жыл бұрын
Are you a full time youtuber or is this your side hustle?
@ralphadediji8303
@ralphadediji8303 Жыл бұрын
Hey Andy, can you airdrop me some of your knowledge for me been a new subscriber to your page or let's say 'in-particularly', ME? Lol. You're a really good teacher on this one. I started watching your video about 5-4 hours ago and i have been getting some wisdom, understanding what to it takes to be a programmer. Thank you for your time to make me understand that.... Your Subscriber. Dare {3ch0}
@asagiai4965
@asagiai4965 2 жыл бұрын
The problem are programmers or companies who don't want you to write comments but their codes are atrocious.
@kingofichigo
@kingofichigo 6 ай бұрын
Some of my variable names are basically sentences 😅
@Gyaaaaaaan
@Gyaaaaaaan 3 жыл бұрын
what is a seasoned programmer? Do they have salt in their head? Just kidding. I love the tips. It is actually what I needed to implement right now.
@arazmammadov9276
@arazmammadov9276 3 жыл бұрын
Actually you made it more complex in the comments section.. lol
@pierreabbat6157
@pierreabbat6157 3 жыл бұрын
Don't call it "military time". Call it "twenty-four-hour time". "Military time" refers to saying "fifteen hundred" instead of "fifteen o'clock". I'd call the variable "isTwentyFourHour", and I had no trouble figuring out what "twentyFour=false" in a clock program is supposed to mean.
@johngibson4874
@johngibson4874 3 жыл бұрын
I disagree with your stance on comments. Comments should be used to explain why something is done a certain way. Developers need to document their code more not less. Think about how frustrating it is to ise a library without documentation.
@gri34psous
@gri34psous 3 жыл бұрын
A comment that is only just pseudo code of the following code is not only useless, it can be harmful. Whenever someone modify the code, there is a risk of unsyncing the code and its comment. It can unsync as far as meaning the exact inverse. In think that we should not comment how the code works, cause the code explains it by itself, but instead we must comment to explain the big picture: The reason for the existance of that code.
@pqsk
@pqsk 2 жыл бұрын
I hate when people think 24 hour time only refers to military time. many countries use 24 hour time.
@AndySterkowitz
@AndySterkowitz 2 жыл бұрын
That's a fair point! On dev teams we have discussions like this all the time and if someone brings up a point like this I'd be open to changing my mind.
@avashurov
@avashurov Жыл бұрын
twentyFour was a better name since that's how it's called in the rest of the world
@stealthoverflow
@stealthoverflow 3 жыл бұрын
"If your'e a new developer, there's chances you're writing code that is sub-par/sub-optimal" woah woah woah, now that's offensive
@Beachalex1
@Beachalex1 2 жыл бұрын
Is it ?
@MrPDTaylor
@MrPDTaylor 3 жыл бұрын
First
@jonathand435
@jonathand435 3 жыл бұрын
I think you need a little more info about comments. Comments are useful to explain thinking, not function. You might use a sub optimal solution for a good reason - a useful comment would explain the thinking and save the next person going through the thought process. I
@beaconbecay1648
@beaconbecay1648 3 жыл бұрын
Lol, I could understand the twentyFour straight away …
@ksubota
@ksubota 3 жыл бұрын
yeah, but good luck to undestand what it is without a context and not knowing it was initialized with a boolean value
@strictnonconformist7369
@strictnonconformist7369 3 жыл бұрын
Experience is dogmatic rules often are barking mad. 15 line function limit is often too short for clarity and can make things harder to read at times. Long list of closely-related checks or initialization? Often more readable in longer functions. Composition root is an excellent example where it makes sense to go longer. Also, depending on context, error handling is easier in longer linear functions. A refinement may be: avoid nested lengthy functions as they’re prone to getting even harder to read than shorter nested functions. Sometimes even 3 levels deep (3D-related code) is easier to understand with all the levels visible at once, as an example.
@jkladola
@jkladola 6 ай бұрын
isMilitaryTime makes no sense. As that might be your regional term. As a Indian developer, I can make more sense on twentyFour or isTwentyFourHour. That's it, after that 2.15 minutes into your video and I stopped watching it. Many developers might not know what the hell is military time, due to their regional language barrier.
@bob-ny6kn
@bob-ny6kn 3 жыл бұрын
"this(dot)this" - regardless of never leaving the function, stop teaching/using "this"
@_d0ser
@_d0ser Жыл бұрын
soydev
@vivalavida7839
@vivalavida7839 3 жыл бұрын
I am a Chinese I turn on 1.75x speed to listen to the videos longer than 10 mins 😆😆😆
@AndySterkowitz
@AndySterkowitz 3 жыл бұрын
Whatever works :-)
@purduetom90
@purduetom90 3 жыл бұрын
This isn't stack overflow where you're expecting to see the answer to your question in the first browser page.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 100 М.
7 Habits I've Picked Up From Senior Software Developers
11:45
Andy Sterkowitz
Рет қаралды 207 М.
Como ela fez isso? 😲
00:12
Los Wagners
Рет қаралды 26 МЛН
1 класс vs 11 класс (неаккуратность)
01:00
БЕРТ
Рет қаралды 4,4 МЛН
100❤️
00:19
Nonomen ノノメン
Рет қаралды 37 МЛН
КАРМАНЧИК 2 СЕЗОН 5 СЕРИЯ
27:21
Inter Production
Рет қаралды 577 М.
Top Signs You're NOT Ready For a Programming Job
8:38
Andy Sterkowitz
Рет қаралды 140 М.
How to Learn to Code FAST (Do This or Keep Struggling)
11:00
Andy Sterkowitz
Рет қаралды 685 М.
Write BETTER Code! 7 Tips to Improve Your Programming Skills
11:25
Andy Sterkowitz
Рет қаралды 200 М.
Naming Things in Code
7:25
CodeAesthetic
Рет қаралды 1,9 МЛН
Learn CSS Positioning Quickly With A Real World Example
8:32
Slaying The Dragon
Рет қаралды 569 М.
5 Signs of an Inexperienced Self-Taught Developer (and how to fix)
8:40
Junior Vs Senior Code - How To Write Better Code
22:13
Web Dev Simplified
Рет қаралды 1,1 МЛН
How I Learned to Code in 1 Year
12:06
Andy Sterkowitz
Рет қаралды 10 М.
Stop using ELSE statements - Try this instead
4:20
Friendly Neighborhood Coder
Рет қаралды 15 М.
Godot Room Transition Camera (Fixed Position)
2:58
Einvard GameDev
Рет қаралды 32
Fiber kablo
0:15
Elektrik-Elektronik
Рет қаралды 8 МЛН
How Neuralink Works 🧠
0:28
Zack D. Films
Рет қаралды 32 МЛН
iPhone 15 Pro vs Samsung s24🤣 #shorts
0:10
Tech Tonics
Рет қаралды 9 МЛН
What’s your charging level??
0:14
Татьяна Дука
Рет қаралды 7 МЛН