Work on an open-source project or at a company with someone who knows the answer to this question and has been doing it for many years.<p>A frustrating fact about coding is that you don't know what you don't know. You feel like an expert, and then someone else shoots you down by introducing you to a new security risk you've never heard of or a technique that's better than the one you've been using.<p>This risk is a lot lower when you have an experienced team around you. Whatever you <i>might</i> be missing, someone else has a chance of catching it.<p>It's also much easier to write production-level code when you use a language with robust typing and mature, widely-used, well-tested libraries.
Write the smallest usable chunks of code and turn them into functions/methods. Add input parameter testing, exception handling and have outputs clearly defined. Write tests for each of these small chunk of code. Group these small chunks into groups and build up modules. At each module level write test code that executes all the integrated paths and keep working your way up.<p>Of course what I wrote is a bit of an oversimplification but overall it is how I write real production code that must be reliable.<p>In general I usually wind up with far more test code then executing production code if I do this all. But like everyone I will get lazy on some of it, which is usually where I find some error later.<p>Also, this basic design lends itself to either a functional or OO style of coding. Modules need not be classes but classes can certainly help you build modules.<p>Find people that will give you feedback, even if they aren't in you immediate network or peer group. It is amazing how helpful people can and will be if you just ask, respect their time and be honest about your level of experience and understanding.
When you cannot work with other experience people or participate in open-source projects. Try these things.<p>1. Take a task and implement it in the most laziest way (like implementing everything in a single code file)<p>2. Try to make the implementation "look beautiful" (with proper indentation, etc)<p>3. Try to make the instructions in your code analyze the return codes, check the input parameters to functions, catch exceptions, split them into various files, functions, classes etc by adding more code.<p>Third step is where you will try to learn more from the programming language that you have chosen. See <a href="https://gist.github.com/nareshv/50fa0884d09622792e34" rel="nofollow">https://gist.github.com/nareshv/50fa0884d09622792e34</a> for example<p>Once you master the step-3, you will always do begin with these things when you start implementing your project.<p>Source: Personal experience.
If you have to ask this question maybe you haven't seen much "production" code. It's pretty variable. Open source projects can be a great help to see what's possible. If it's easy to understand and well used it might be pretty good.