Write BETTER Code! 7 Tips to Improve Your Programming Skills
Вставка
- Опубліковано 3 лип 2024
- I've compiled seven programming tips for anyone who is new to coding that will help make your code more readable and easier to work with. These tips are based on some clean code principles but I've tried to distill them into a simple concept for beginners.
P.S. Apologies for my face being blurry. The focus was not set correctly. Hopefully it's not too distracting! :-P
** DOWNLOAD THE FREE REPORT **
For my free report on the five best programming languages in 2019 (for beginners) go to: andysterkowitz.com/report - Наука та технологія
30+ years of coding - and I still needed to hear this...
can i learn something from your experience :)
@@phatkongkhun Gonna wait a few more years, but those days are definitely coming nearer...
You're old
Your age??🤔🤔
@@vivek5807 54
Great video! Your tips encapsulate my all-time favorite quote:
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." - Martin Fowler
Preach it! Right on 😀
@@AndySterkowitz :D
Guess I'm a crap programmer, I can't even understand my own code a week later :P
tell that Yandere Dev
Good tips man! Definitely a good watch!
1. Avoid abbreviating variables (pw => password)
2. Limit function arguments (aim for 3)
3. Simplify conditional expressions
4. Declare variables close to their usage
5. Avoid unintended consequences in functions
6. Functions should do one thing (avoid long functions)
7. Stop writing zombie code
there should be another one at no 8. Don't repeat yourself!
+1 for you but it would be even better with timestamp links
Write good comments! Practice commenting while coding your program. It really helps explaining your code to someone else when you comment
No, don't leave commented code in a release version of the source code. There's nothing wrong with commenting out code for testing purposes.
@@HealthInspectorz Yes, but don't over do it or you'll find that maintaining the comments can become a second job.
if (true == true) {
return true;
}
I never saw so good code like this in my life.
I've seen this more times than I care to admit:
if(someCondition)
return true;
else
return false;
Return true==true; stop making these ugly if else statements!
I use python.
I am a beginner
I write very short codes that make the same result as very long ones
Like my teacher
She made a 50 line code that I made in 28
My teacher liked mine a lot
Bem inesperado encontrar um jogador de RotMG num vídeo de programação. KKKKKKKK
Yes.. For newbies only..
*quickly deletes zombie code*
Definitely good tips!
lel XD
**guilt intensifies**
I have been coding in C++ for 5 years and I gotta say your video is great and really covers all the essential tips. I didn't know about the last two tips! Very resourceful.
Hello what kind of project have you worked on?
Holy crap. These were *really* useful tips. I've been coding since high school, but I still find myself making the "mistakes" of tips 1 and 6. This one will have to be shared.
Yes Andy, yes, I always enjoy your videos, advice and your honest take on programming techniques.
Hey man I’ve been subscribe for a few months now but just started watching you videos. I wish I started watching a year ago, you videos are very clear and to the point and offer a lot of info of very important info that is commonly over looked!! Thanks!! Your videos are a huge help!
"Signal to noise ratio"...good audio analogy. A great way of explaining a code file being too "busy"/distracting looking. Never heard it explained like that before, I like it.
YES. Simple tips with immediate pay-off, bite-size and highly nourishing. Thanks for the quick feast!
Loving the videos, Andy! Keep up the great work, and keep being an inspiration!
One of the absolute most valuable videos! Thank you so very much and keep up the good work Andy!!
This was such an incredible thought out video.
Amazing content Andy!
This is by far one of your best videos since it had clear, tangible examples with code visualizations added to get your point across. Please make more content like this since your newer stuff is a bit loaded with fluff.
Im being programing for many many years and still found it usefull, thanks so much
Nice video, man! UA-cam recommendations can be a blessing, after all. Earned a new sub for the quality! 😁
Besides the nice tips your room is fucking dope! Especially the bright laptop and you with the dawn (!?) in the background is sooo amazing!
I really appreciate your coding tips. Thanks for getting us on the right path. Finding great info on your site. Thanks and keep up the great work.
Cheers!
You earned yourself a new subscriber! Keep uploading such videos! :D
Thanks Andy I matured from videos and I want say thanks again from the tutorial purgatory video you did I started to get some change and am now improving fast
I can confirm that these tips are LEGIT! Good video.
Amazing tips! Thank you Andy! :)
Fantastic video! There are definitely some new points I have learned. Thank you!
Excellent advice! Thanks so much
Thank you sir for this video, I have been waiting a long time for this
Well written. well explained, nicely edited, and dude! that background! Nice.
Love the tips, and examples!
Thank you very much; this was a very informative video to watch. The necessity of clear, concise code and the rest of the points made were really good to know, as a beginner coder. Thanks again.
Great tips, thanks andy!
Thank you that was very helpful, especially the part with long functions. I sometimes have tendencies to overcomplicate things.
Never gets old, these tips are immortal :) Thanks.
Yes, I am (was) trying to make heads / tails from my thousand line function. I wanted to add a new feature but no clue where to do this.
Now I am talking apart the pieces and places in sub functions to see the logic a bit clearer.
Nice and very informative tips. Please give us more. Thank you for sharing!
you are like the "Helpful Coding Andy". Really helped!
I enjoy so much your videos!
you are awesome! you have really inspired me too work hard on coding and become a software developer. you also have inspired me to work hard in different aspect of my life thank you so much keep it up.
I love your videos, keep it up man!
Great video, few of these tips are new to me and realy helpful.
Quite Helpful! Thanks
I've been programming since the 1970's. You nailed it. Well done! I particularly enjoyed your observations on zombie code and practice, practice, practice. I would add, and have added to numerous coding style documents, some of these:
0) NEVER, EVER, EVER use the TAB key! I worked at one company where a guy set his tab stop to 2 spaces - so what looked good to him went far to the east for everybody else.
1) learn and use the coding style of the corporation for whom you work,
2) use a consistent coding style,
3) use consistent code formatting - e.g. always indent 2,3, or 4 spaces,
4) make your code as easy to read as possible (e.g. for a long list of assignments, line up all the equal signs,
person[firstName] = "Bob"
person[middleName] = "Andrew"
person[lastName] = "Smith"
person[phoneNumber] = "1-555-123-4567"
person[Street_Number] = "9827"
person{Street_Name] = "West First St."
person[City] = "Toledo"
person[state] = "OH"
person[zip] = 49208
)
5) Make your code readable and maintainable. Don't be afraid to do the right thing:
if ( x == 1 )
{
func1( args1...)
}
else if ( x ==2 )
{
func2( args2 )
}
else if ( x == 3 )
{
func3( args3 )
}
becomes
if ( x == 1 ) { func1( args1 ) }
else if ( x == 2 ) { func2( args2 ) }
else if ( x == 3 ) { func3( args3 ) }
which is infinitely easier and faster to read, understand, and maintain.
5) Don't make files with hundreds of code lines
make code files that contain associated functionality: employee_details.code, company_product.code, taxes_federal.code, taxes_state_WI.code, taxes_state_IL.code, taxes_local.code, taxes_SS.code, taxes_medicare.code
6) Read books, papers, and online articles on good programming style.
7) Read the code of senior staff.
8) Force yourself to look at the code you wrote 6/12/18 months ago and try to figure out what it does. This is a great way to learn how to write better code.
That was so helpful, many thanks :)
Thank you. Very useful tips.
Thank you for those tips, great advices, always good to get a reminder of what we should not do to keep a clean code base!
Great video, simple tips but with deep value
Fantastic tips.
beginner coder here and this video was fantastic, I was committing all these offences barring like 1 (I don't abbreviate my variables) thanks for improving my practice!
Great tips. I am a junior web developer and looking for tips to improve my coding, while searching I suddenly found your video. Your tips are really helpfull. 🌟👍
This is SUCH a good set of tips. If everyone followed these... Man. That would be amazing.
Very useful advice and info in this video. While I'm not a complete beginner in programming, I'm currently trying to find better ways for writing cleaner code for my latest Java project. I'm glad to say based on the above that I don't make a lot of these mistakes mentioned. But regarding the last three tips mentioned, I'm prone to making errors on those. From now on therefore I will aim to amend these errors and get into better programming habits overall.
Great tips!
Awesome video! I also recommend to use the SOLID principles!
I find your tip #4 to be interesting. It directly contradicts what I was taught in school. My professors wanted all of our variables declared at the top of their relevant functions, although they also demanded descriptive names and comments for each.
Sometimes it's considered as a good practice, e.g. when declaring properties in classes. Otherwise when declaring constants, or just simple variables that will be used right from the beginning of the process.
Some language demands it. In a class I would always declare my variables in the top of file. But I a function I would declare it as close to there it used.
That might come from "older times". For example in C (not C++, but pure C) you actually had to declare all the variables before you could do anything. If they got used to it, it feels natural for them now.
@@kiddhkane That makes sense. The language that was used at my college was C/C++. This was probably because the CS department was part of the Electrical and Computer Engineering college at the time. We had a lot of engineers (including me) who were learning to program for the purpose of using it in embedded computer control systems. It was likely that my professors were old C programmers.
I was told to teach students this by a really old professor. He was a fortran/C guy. He also told me not to declare variables within the body of a loop because it uses more resources, which is just plain wrong. Maybe compilers back in his day were poorly optimised.
a very great video, explaning like a pro
ty man, very good and useful tips!
Im studying IT for 3 years now. Some of theese tips were mentioned. But man this really helps out a lot. I’m gonna write them down until i internalized them!
Super useful tips!
though these things seem common sensiscle..... they are so rare in code bases. great video!
Great tips thank you 🏴👍
Great video with great experience of coding 👌👌👌
Thanks for your teachings! :-)
I am definitely guilty of too many function arguments, great video
Hey Andy, you do great videos, I enjoy the consistency and flow of the videos. One piece of feedback I would suggest is to place timestamps as you are talking about certain topics. If you could write a brief, too it would be excellent.
Good tips!
Great! Thanks a lot.
You have an amazing view. I wish I had a similar office
Great, great points here.
Good work bro..
Really helpful. Thanks bro..
Tremendously useful
These are good tips to keep in mind! You should check out the book code complete if you want more examples of better code practices.
I'm about to master coding within a few months the for the tips keep up the good work
My biggest piece of advice is to embrace comments (not zombie code). The first thing I always do before beginning any difficult program is write a paragraph / list at the top describing exactly what I plan to do. Then I can go back to this original plan whenever I get lost
This is also super useful when I come back later and have completely forgotten what I was doing
I also use in-line comments to describe what I am doing whenever I am doing something that might be even a little confusing, especially to somebody with less programming experience. A good example is regex - it's super confusing if you don't understand it, so I always pop a comment in describing exactly what the regex does
I also do this, its very helpful to frame your thoughts and break down a complicated piece of code into a set of steps you are intending to follow. Can also be helpful in decomposing your code into functions! highly recommend this practice.
Imo, better to use a issue tracker for your todo list
The problem with comments is that it is practically duplicated code. If you need to change the code later, you need to change the comments later.
You can write a document describing what you are planning to do,but your code should be written in a way you don't need comments in the code to understand it.
What about descriptive function names and small functions? Say you have a regex that looks for pattern A. You could create a function that is called getPatternARegex() that returns the regex. No comments, and perfectly clear what the function does. I find that you can use small functions instead of comments in many scenarios.
@@tomixtomi12 Depends on the complexity of what I'm doing. It takes a lot longer to create a brand new function (especially when using jsdoc) then to just throw in the regex and move on. It's also the case that regex _should_ be known by most programmers because of it's extreme usefulness and commonality
In some cases, especially for _particularly_ complicated regex, a standalone function makes a lot of sense
Hej. Very nice video. And good advice(s) :) I would like to point out the need for guard(s) in code, as well as rudimentary error handling.. :)
I'm familiar with CleanCode and I've been a software engineer at Microsoft for 3 years and at first I was like "meeh why is this beginners video on my recommendations?" Haha DUDE! All these tips were super useful and well explained. I learnt a lot from you. Thank you
I wish more "advanced" programmers could see this video. Subscribed
Great vid!
Good stuff, can relate.
Preach it brother!
Thanks, again.
very useful!
I'm literally just starting out and I could understand most of this. Your videos are very informative. Please keep creating content!!
fantastic video, I have learned somethings...
As a bit more seasoned junior, I attest to all the tips in this video. You will benefit a lot from keeping your functions short with minimal arguments, abstract the task at hand which makes it easier to develop tests and creates software easier to debug.
If I were to add one thing it would be to encourage early on test development. While you’re writing a function, in parallel or even before: try to write code that tests your new function that expects a certain output. When you get this down, you’ll integrate with the test framework in your language of choice much easier, your tech lead will thank you for having a Test-driven development approach.
You forgot to mention that another reason why people use dead code is for debugging or testing purposes. Some people leave dummy implementations of certain things in order to check them much faster when debugging a different issue.
The solution to that, to avoid this dead code, is to use testing classes with implementations of the classes you need to inject (dependency injection), and thus leave testing-specific code only within the scope of your testing root folder.
Edit: Sorry - I usually see the negative as I take the positive for granted - but the tips given were great and it's really important for beginners to get rid of these bad habits as soon as possible, so good video!
Thank you sir
i luv the tip on zombie code!
Very good video, but I have one notice for you ;)
2nd tip, 3:18 - variable should be named "userData", and it should be structure with data (or simple class if structures are not available)
best vid ive seen of yours
Good tips.
Thanks boss, im on my road to self taught
those are excelent advices for us beginners
I think it would be useful if you let the window with the advice on screen or maybe show it again at the end of every advice, maybe for a second version on more advices?
thanks again
I just started a new python course !!! I just did my hello world lab can’t wait for second lab!!!
More like this please
As far as I see it from my perspective - everything that helps you with managing code even a little - is very handy and worth of effort. Because coding is so quickly brings you the stage, where project is gientic. Your level of attantion just WILL reach it limit and it is very painfull (like to wait for loading almost for evey action). And the worst case is visual scripting.
great tips. I have been a developer going almost 12 years and number 1 and number 7 are my 2 big pet peeves. another big thing I hate is database tables that are related that dont share the same column name. in one table its user id and the other table its username, but for a given user it stores the same value (johnsmith).
Having a standard and logical convention for naming your variables is helpful not only for other people who might be reading your code, but also helpful for yourself. Like if you're trying to remember specifically what was the name of that variable. If you don't want to have to go look (wasting precious seconds) you can just think, "well, what WOULD I have named it?"
Very good video. One remark: In example #3 (return conditionals) the improved code contains a typo. It should be "person.age >= 21" (not personAge >= 21), just like in the longer code.
good practical tips
Great tips! I love the part about Zombie Code. I didn’t know it had a name but I’ll start calling it that!
It's actually called spaghetti code. But this guy isn't s computer scientist
I learned that sometimes rewriting code is a good idea and fewer lines is better.