Programming is one of the most versatile skills on the market in this age. From being able to create company websites to knowing how to easily fix a redirecting error, these skills can be invaluable to an employer and yourself in many ways. However, staying the way you are will never let you be the best programmer you can be. Read on to learn how to improve your skills as a programmer.

Gather complete requirements. Take the time to write down what goals the end product needs to achieve, and who your user base will be. Clarity of thought at this stage will save a lot of time down the line.

For something small and self-contained, this might be just a basic flowchart or a simple equation.

For larger projects, it helps to break the job into modules, and to consider the following:

What task each module must perform

How data gets passed between modules

How the data will be used within each module

Although gathering and planning requirements can be tedious and much less fun than diving straight into coding, it is even more tedious to spend hours debugging. Take the time to design the flow and structure of your program correctly up front, and you may even spot more efficient ways of accomplishing your goals before you write the first line of code!

Comment your code liberally. If you think that your code might need explanation, comment it. Each function should be preceded by 1-2 lines describing the arguments and what it returns. Comments should tell you why more often than what. Remember to update the comments when you update your code!

Use consistent naming conventions for variables. It will help you keep track of each type of variable, and also what that variable's purpose is. This means more typing than simply x = a + b * c, but it will make your code much easier to debug and maintain. One popular convention is Hungarian notation, where the variable name is prefixed with its type. For example, for integer variables you might use intRowCounter; strings might use strUserName. It doesn't matter what your naming convention is, but be sure that it is consistent and that your variable names are descriptive. (See Warnings below).

Organize your code. Use visual structures to indicate code structure. For example, indent a code block that sits within a conditional (if,else,...) or a loop (for,while,...) Also try putting spaces between a variable name and an operator such as addition, subtraction, multiplication, division, and even the equal sign (myVariable = 2 + 2). As well as making the code more visually elegant, it makes it much easier to see the program flow at a glance. (See tips on Indentation below).

Test everything. Start by testing each module on it's own, using inputs and values that you would typically expect. Then try inputs that are possible but less common. This will flush out any hidden bugs. There is an art to testing, and you will gradually build up your skills with practice. Write your tests to include the following cases:

Extremes: Zero and beyond the expected maximum for positive numeric values, empty string for text values, and null for every parameter.

Meaningless values. Even if you don't believe your end user would input gibberish, test your software against it anyway.

Incorrect values. Use zero for a value that will be used in division, or a negative number when positive is expected or when a square root will be calculated. Something that is not a number when the input type is a string, and it will be parsed for numeric value.

Be prepared for change. In a realistic working environment, requirements change. However, the clearer you are at the start about the requirements, and the clearer your implementation plan is at the outset, the less likely it is that changes will be the result of poor planning or misunderstandings.

You can take an active role in improving the clarity of the process by presenting your requirements documentation or your implementation plan well before beginning to code. This will help to ensure that what you are planning to create is actually what's been asked for.

Structure the project as a series of milestones with a demo for each block, and manage the process one milestone at a time. The fewer things you need to think about at any given moment, the more likely it is that you will think clearly.

Start simple and work towards complexity. When programming something complex, it helps to get the simpler building blocks in place and working properly first. For example, let's say you want to create an evolving shape on screen that follows the mouse direction, and changes shape depending on mouse speed.

Start by displaying a square and getting it to follow the mouse; i.e., solve movement tracking alone, first.

Next, make the size of the square relate to mouse speed; i.e., solve speed-to-shape tracking on its own.

Finally, create the actual shapes you want to work with and put the three components together.

This approach naturally lends itself to modular code writing, where each component is in its own self-contained block. This is very useful for code reuse (e.g. you want to just use the mouse tracking in a new project), and makes for much easier debugging and maintenance.

A basic answer would be to "think more". Critical and logical thinking are honestly a result from thinking hard. Learn what "logical" would be to a computer; don't see the world in your eyes, but in the eyes of the computer. "Meta-cognate", so to speak. Sometimes something that doesn't make sense suddenly does 5 weeks later. Keep an open mind and always try to see new angles. Even if you can't now, eventually you will. The worst thing you can do is think you're unable to logically think, because then you'll give up before you even started.

Start learning with C language. By learning C, you can learn the basics of all the programming languages. Then, learn some object-oriented programming language, like C++ or JAVA, which will help you to learn the object-oriented programming techniques used in many languages. Once you have learned C and any of the object-oriented programming language, you can learn any of the programming language easily.

C# is a newer language with many new features such as namespaces and classes. One of the biggest differences is "Garbage Collection," which automatically cleans up memory when it's no longer needed. In C as well as C++, cleaning memory must be managed manually, so if you're not used to this, it can lead to "memory leaks."

Video.

By using this service, some information may be shared with YouTube.

Tips

Use an IDE (Integrated Development Environment). A good IDE will have a colour-coded editor built it, with code hints and code completion functions that make editing faster and less prone to spelling mistakes. It will usually feature debugger, as well.

Studying the source code of other programmers is an excellent means of improving your own skills. Work your way through their code, step by step, working out the flow and what happens to the variables. Then try to write your own code to do the same thing (or maybe even improve on it). You'll quickly learn why things need to be written a certain way and you'll also pick up some useful tips on how to write efficiently.

Make regular backups of your application code onto another hard drive or portable device so that you will have a copy if your computer dies or becomes unavailable. Keep at least one copy in a secure place.

Keep your code visually elegant, not because it's pretty but because it makes it easier to read. This is essential when you want to make changes six months down the line. Read more about code indenting.

After each bigger segment of work, take a break, do something unrelated, then review what you have written with a fresh mind. Rethink and rewrite it, making it more effective and elegant by using less code.

Have fellow programmers read your code. They may well know something that you may not have thought of before. Don't know any professional programmers? Find an online forum that's dedicated to your chosen programming language or operating system and join in the conversation.

If you go down this route, read and observe the forum etiquette. There are a lot of goodhearted experts willing to help out, if asked nicely.

Remember to be polite, because you're asking for a favour. Don't get frustrated if you don't understand everything at once, and also don't expect them to want to review 10,000 lines of code. Instead, ask simple single-focus questions and post just the relevant 5-10 lines of relate code. You're most likely to get a positive response that way.

Before you start posting, do a little research. Your question has almost certainly been encountered, considered, and solved already.

Customers and bosses aren't concerned with how your program works nearly so much as they are with how well it works. Think bottom line. Clients are intelligent, but busy. They won't care what kind of data structures you're using, but they will care if it noticeably speeds up or slows performance.

Separating (packaging) your reusable code from your application-specific code will, over time, lead to a large, debugged, and reusable library full of handy utilities. This will aid in writing more powerful and stable applications in less time.[1]XResearch source

Warnings

Copying and pasting others' code is generally a bad habit, but taking small portions from an open source program can be a good learning experience. Just don't completely copy a program and attempt to take credit for it. Don't copy code from another program unless you have permission or the license permits.

Save your work frequently as you go along or you risk losing hours and hours of work to a computer crash or lock-up. If you ignore this warning now, it's a lesson you will definitely learn the hard way!

Hungarian notation (indicating a variable's type as a prefix) should be used with caution. It can lead to inconsistency when edited, or particularly if ported to another language or operating system. It is of most use in 'loosely typed' languages that don't require you to pre-declare the type of a variable.