CuriouSTEM

View Original

Code Smarter, Not Harder

Do you want to have the best code? Believe it or not, there are strategies that you could use to make sure your code is readable, organized, and easy as possible to write. The readability of your code- how easy your code is to comprehend- should always be kept in mind when coding. One of the most important things you can do to increase the readability of your code is to write organized code. One of the most straightforward ways to accomplish this is to write comments. Comments are an explanation or annotation that you write in your source code. For example, some comments you might want to add to a function are the purpose of the function, any parameters, and any return values. Another way to maintain organized code is to be concise. You should avoid writing excessively long lines of code that hinder the readability or unnecessarily repeating lines of code. Remember: Organized code will help you in the long run as it makes it easier to debug and to understand.

Next, one way to improve your code is to get another opinion. When talking about your process with others, you can think verbally and receive constructive criticism. Code review or code inspection is when a peer reads your source code to assure the quality of your code. Additionally, pair programming is when two developers work on one computer and collaborate on the same design, algorithm, code, or test. Pair programming is another viable technique as two brains are always better than one. With two minds, you most likely can create higher quality code at a faster pace.

Finally, remember to use the internet to your advantage. If you ever get stuck coding, the internet is a resource that can help you. Most languages will have documentation that you can use if you ever have any questions regarding syntax. Additionally, in some cases, you can even use code from the internet. This process is known as open-source code. Libraries are collections of prewritten code that programmers can use to optimize programs. Most libraries also have directions (API) on how to use them efficiently. So next time you work on your projects, make sure to stay organized, collaborate when possible, and use the internet to your benefit so you can write code smarter- not harder.