How to develop your programming skills

How to develop your programming skills
How to develop your programming skills
Anonim

Knowing how to program is one of the most versatile skills on the market today. From being able to build business websites to knowing how to fix a redirect error, these skills can be of value to an employer or to yourself in many ways. However, staying where you are at will never make you the best programmer you can be, keep reading to learn how to develop your programming skills.

Steps

Improve Your Skills as a Programmer Step 1

Step 1. Clearly analyze the problem

Improve Your Skills as a Programmer Step 2

Step 2. Take some time to think about how to solve this problem

Improve Your Skills as a Programmer Step 3

Step 3. Gather all the necessary items

Take the time to write down what goals the finished product should achieve, and who will be in your user base. Having lucid thinking at this time will save you a lot of time in the long run.

Improve Your Skills as a Programmer Step 4

Step 4. Write a careful implementation plan (or template)

  • If it is something small and independent, the plan could be a basic flowchart or a simple equation.
  • For larger projects, breaking the work into modules will help, as well as noting the following:

    • what task should each module perform
    • how information is transmitted between modules
    • how the information will be used within each module
  • While gathering and planning the prerequisites can be overwhelming and much less fun than diving straight into coding, spending hours debugging is even more painful. Take the time to design your program structure and flow well in advance, you might even find more efficient ways to achieve your goals before you've even written the first line of code!
Improve Your Skills as a Programmer Step 5

Step 5. Generously comment on your code

If you think your code might need some explanation, comment it out. Each function should be preceded by one or two lines describing the input arguments and what the function returns. Comments should more often be meant to tell you why rather than what. Remember to update the comments when you edit the code!

Improve Your Skills as a Programmer Step 6

Step 6. Use consistent naming conventions for the variables

This will help you remember what each type of variable is, and also what that variable is used for. This means that you have to write more than just x = a + b * c, but it will make your code much easier to debug and maintain. Hungarian notation is a popular notation, where the name of the variable is prefixed by its type. For example, for integer variables ("int" or "integer" in English) you can use intCounterLine. For character strings (or "string") you can use strNameUser. Whatever your naming convention, make sure it's consistent and that your variable names describe their role (see disclaimers at the bottom).

Improve Your Skills as a Programmer Step 7

Step 7. Organize your code

Use visual structures to show the structure of the code. For example, you can indent a block of code within a condition (if, else…) or a loop (for, while…). Also try to put spaces between the names of variables and operators such as addition, subtraction, multiplication, division and even the equal sign (myVariable = 2 + 2). This makes your code more visually elegant, in addition to making it easier to understand how it works at a glance (see the tips on indentation below).

Improve Your Skills as a Programmer Step 8

Step 8. Test everything

Start by testing each module individually, using the input arguments and values ​​you would expect. Then try input arguments that would be possible but less common. This will bring up any hidden bugs. Testing is an art, and you will gradually develop your skills with practice. Incorporate the following cases into your tests as you write them:

  • extremes: zero and beyond the maximum expected when it comes to positive numeric values, an empty string when it comes to text and "null" for all parameters.
  • absurd values. Even if you don't think your end user will put such values ​​as input, still test against them on your software.
  • incorrect values. Use a zero to test for a value that would be used in a division, or a negative number where you expect a positive or where you calculate a square root. Put something that is not a number when the type of the input argument is a string, and it will be decomposed into numeric values.
Improve Your Skills as a Programmer Step 9

Step 9. Train, train, train

Programming is not a stagnant discipline. There is always something new to learn but, perhaps more importantly, there is also always something old to relearn.

Improve Your Skills as a Programmer Step 10

Step 10. Be prepared to make changes

In a realistic working environment, the prerequisites change. However, the clearer you are from the start about your prerequisites and the clearer your implementation plan from the start, the less likely it is that changes will arise due to poor planning or failure. incomprehension.

  • You can have an active role in improving the clarity of the code by putting the implementation plan or the documentation of the prerequisites in the introduction of the code. This will help you be sure that what you plan to create is actually what is requested.
  • Structure the project as a series of steps with a demo version for each block, and move through the code one step at a time. The more you think about a smaller number of things at a given time, the more lucid you will be able to think.
Improve Your Skills as a Programmer Step 11

Step 11. Start simple and work your way up to complexity

When programming something complex, start by putting in place the blocks that are easiest to write and to operate correctly, as this can help. For example, let's say you want to create a shape that changes onscreen based on mouse movement, and changes shape depending on mouse speed.

  • Start by displaying a square and making it follow the mouse. This means you have to figure out how to make a move, solve this problem without anything else to start.
  • Then make the size of the square related to the speed of the mouse. So you have to figure out how to make size relate to speed, deal with that separately as well.
  • Finally, create the shapes themselves, the ones you want to work with, and put the three elements together.
  • This method obviously approaches modular writing of code, where each element constitutes its own independent block. This technique is very useful for reusing code (for example, if you just want to use cursor tracking in another project), and it makes debugging and maintenance much easier.

Advice

  • Use an IDE (acronym for Integrated Development Environment). A good IDE will contain a color-coded editor, with hints and code autocomplete features that make editing faster and less prone to typos. A debugger will also be present, in general.
  • Separating (or dividing into “packages”) between the reusable part of your code and the part specific to your program will allow you to have, over time, a large library of practical debugged and reusable tools. It will help you write more powerful and stable programs in less time.
  • Have other programmers read your code. They might very well see something you haven't thought of. Don't know any professional programmer? Find an online forum dedicated to the programming language or operating system you are using and join the conversation.

    • If you do this, read and follow the forum guidelines. There are many experts who will help you wholeheartedly, if you ask nicely.
    • Be polite because you are asking for a favor. Don't get upset if you suddenly don't understand, and don't expect them to be willing to read 10,000 lines of code. Instead, ask simple questions about one thing at a time, and give the corresponding 5-10 lines of code. You are more likely to get a positive response this way.
    • Before posting a question, do a little research. Someone has almost certainly encountered, dealt with, and resolved your problem.
  • Studying the source code of other programmers is a great way to improve your own skills. Go through their code, step by step, trying to understand how it works and what happens to variables. Then try writing your own code to do the same (or even write a better version of it). You will quickly learn why things should be written a certain way, and you will learn tips on how to write more effectively on the job.
  • It is neither your clients 'nor your bosses' business to know how your program works, but it is more interested in how well it works. Think about how your program is going to be used. Customers are smart, but busy. They won't care what kind of data structures you are using, but they will see if it improves or reduces their performance.
  • Tutorial sites are a great help as well.
  • Make regular backups of your software code to another hard drive or portable device so that you have a copy if your computer breaks or becomes unusable. Keep at least one copy in a safe place.
  • Try to have code that remains visually elegant, not only because it looks good but also because it makes it easier to read. This point is essential for when you want to make changes in six months. Learn more about code indentation here.
  • After every big work session, take a break, do something unrelated, then reread what you've just written with a clearer mind. Rethink and rewrite your code, making it more efficient and stylish using less code.
  • Find yourself an editor that highlights your code syntax with colors. It really helps to separate comments, keywords, numbers, strings, etc.
  • Change one thing at a time when you are debugging and then test the fixes you made before moving on to something else.
  • Do version management. Tools like CVS or SVN make it easier to track code changes and bugs.
  • Double proofread your code to verify writing and syntax. Even the smallest of mistakes can cause a lot of stress.
  • Keep archive copies of what you have done in the past. This is not only a good way to have references, but it can also allow you to reuse snippets later.
  • Use a debugger rather than putting things in your code to display return variables. A debugger is a tool that will allow you to step through your code line by line to see where the problem lies.
  • Chat with other programmers. Others can often be a good source of information, especially when you are starting out. Find out if there is a group of programmers you can meet near you, and join the group.
  • Start small, aim for goals you can most likely achieve, and work your way up to more complex things.
  • A good way to both frequently back up your work and keep a copy that is physically in another location is to use a versioning tool like git or mercurial and a free hosting service like GitHub or Bitbucket.

Warnings

  • It's usually a bad habit to copy and paste other people's code, but grabbing small portions of open source software can serve as a good learning experience. But don't copy software completely and then pretend it's yours. Do not copy code from other software unless you have permission or the rights to do so.
  • Frequently save your work while you work or you risk wasting hours and hours of work if your computer crashes or freezes. If you ignore this warning, you are sure to learn the lesson the wrong way!
  • In step 4, Hungarian notation (where the prefix indicates the type of the variable) should be used with caution. It can lead to inconsistencies in editing, especially if you are trying to port the program to another language or to another operating system. It is better to use it for 'weak typing' languages ​​which do not require upstream declaration of the type of variables.

Popular by topic