Tips for New Programmers
Re-compile, Re-run, Repeat... oh, and Research!
by D1J1T — in Programming — Updated: Feb 12, 2015 at 11:59 am
The goal of this article is to offer tips for new programmers.
This article will NOT cover programming language syntax specifics or attempt to teach any programming language in particular. Rather it is meant to give tips to those learning a language for the first time in order to save them time.
Why are you programming?Is it for a class? For a job? For fun? To complete a personal project or website? Note that I started programming for fun and still do, though also for work.
Programming for a class - If you are a person who just has to pass a programming class and never have to look at line of code again, there is no need to read on past this one section. The best advice that I can offer you is to simply get through the class and do the following: 1. Learn the basics of what you need to make the grade and obtain extra language- specific help online and from your classmates. (Disclaimer: I'm not saying to cheat or to turn in another person's work. Don't.) I will add, however, that learning how to program requires using and testing with "good" code initially. No one in the history of programming has typed out a standard "Hello World" app, without looking at example syntax first. How could we?
2. Setting up your IDE can be one of the most frustrating initial tasks, but it is also half of the battle of many programming assignments. Once you think your programming environment is setup properly, use what you know is working code. Ensure that you can compile and run without errors. If you can get what you know to be a good working code example (syntax error? Did you miss a semi-colon perhaps? Check to see that it's typed EXACTLY as the example) compiled and running, then you're doing great! 3. The only reason to "re-invent the wheel" is to do so to learn a language. If your instructor wants you to code a bubble sort, despite it's been done a million times, find a good example to mimic. Type it out yourself. (sure, use the book example, or an online example) I know it's painful to type initially and so much easier to copy/paste. Feel free if you already know the language, but if you don't, just type it out. (Note: Sometimes copying and pasting code can actually cause errors from unforeseen whitespace, different encoding types, etc.) The purpose is to get a simple project compiled, running, and displaying properly. You'll probably get a syntax error, more than likely you'll get 7. Read those error messages (as cryptic as they may be) and attempt to fix the first one, then re-compile.
4. Save a copy of that code that worked first, then alter it in some way and experiment with it. Start by changing the string "Hello World" to "I wish I didn't have to take this class", re-compile, and see if it runs or if you get an error. Maybe it didn't like the ' in "didn't" because of nested quote types? Who knows? You're error messages will attempt to direct you to the line(s) it doesn't like. However, sometimes you must go a step further and debug a bit on your own. Perhaps your syntax is correct. Have you considered the possibility of logic errors? Just because the program compiles and runs, doesn't mean it's going to do what you meant for it to do. Remember when that math instructor said "Check your work?"
5. Once you're familiar enough with the language specific syntax, alter it to complete your specific project. DO reference the language APIs often, save backups often, re-build and re-run often. Comment your code throughout. Trust me, your instructor will like to see well commented code.
6. This is probably the most important bit of information: Look at your code line by line and be sure that you understand what every line is doing, the control flow of the program, the difference between a keyword, a variable name, a function, class, etc. If I point to the second "word" on line 23 that says " fetchID(pid); ", can you tell me what "pid" is? What fetchID is called? What is the purpose of the parenthesis and the ; ?
Do not attempt to memorize every field and function in a library. Focus on understanding the basics of the language. You simply will not learn how to be a good (language x) programmer in one semester, especially if this is not your area of focus.
Programming for a job - Did your employer all of a sudden task you out to program their website in your spare time while doing the company payroll, or does your boss already expect that you are proficient in the necessary programming languages? If the former, ensure your employer knows the time involved to learn and implement the solution may be significant. If the latter, and you have programmed a bit, you can skip ahead to potentially find more useful tips. If you haven't experience in the language(s) however, though you claimed them on your resume, you of course need to learn the languages quickly... Time to start reading/viewing tutorials over dinner...
Programming for a personal project/website - You have a passion for your project and need to use programming as a tool to enhance it. Expect to be as passionate about programming as you are with your project in general if you want to produce a program that reflects the passion you have for your project. If you don't, or simply find that you dislike programming, (worse yet computers in general), consider hiring a professional or else you may find yourself wasting hours of time that could be better spent. If budget is a concern, sure, try to do it yourself, research free services, get free online training, and know that it can be done if you have the drive to make it happen.
Programming for fun - If you're already a skilled programmer, one like myself that codes for fun, then the best advice I can give you is probably to get outside and take a walk every now and again. Be sure to bathe daily, exercise, stop eating Cheetos for dinner and attempting to program while handling other important calls and tasks. By all means, spend some time with your significant other and kids. If you don't have a significant other, get one. (Note: You can't program one. Don't try, I know you're tempted.) "But I'm sooo very close to finishing this app!" You already know as well as I do that no app will ever be perfect or complete. Maintain the balance in your life; it's important, more so than the current application you've been obsessing over to "finish."
Many have heard a story of Archimedes discovering displacement as measurement of volume while being in the bath (after his wife more than likely told him he smelled bad) and then jumping out, running around naked screaming "Eureka!" I can't speak on the accuracy of this story, however, I can tell you that I've wasted hours programming at times, only to walk away frustrated and while eating a good meal, or bathing, or taking a walk, or simply doing something other than staring at the computer and attempting to fix a problem, have had the solution simply hit me, out of the blue, almost like magic! A similar reference comes to mind in Men In Black III ? I think: the elder agent says "Let's get some pie" (in the middle of an emergency), the younger agent is frustrated with the idea, but concedes, and in turn while eating the pie, has a "Eureka" moment and discovers the value of a vital clue. Remember that you're not a machine, and even if you are, you could always use a reboot and have your registry properly cleaned too.
Programming for fun and inexperienced programmers - So you've started playing with code and see its creative value. You have a million ideas floating about your head and want to implement them all today. You know that the languages you're familiar with, along with your skill, can do it! You're excited because you've played with a bit of code, seen some results, and enjoy seeing the results of your efforts. You see errors in applications and know they could be soooo much better. You've played that video game and if you had programmed it, you'd have included the feature "x." You would, and you can even, but not without a lot of work.
It's great that you enjoy programming; many, probably most people don't. If you are among the few that do, perhaps you'll consider these tips to save you some time and frustration.
1. Have a plan, especially if you want your project to succeed. When I was first learning Java, I used a basic "Space Invaders" type game template to make an RPG. I had a lot of fun doing so and learned the language. If this is your goal, do it! If you're not simply trying to learn however, and attempting a project for money or another important purpose, plan it out. For every hour you put in not actually programming, but rather planning your code structure and specifics, you will save at least three times that in actual code. Your code will also be faster and more efficient. You won't get so far into your code and realize that you should have created a specific class for this object type (or subclassed one). You might discover than a certain function should be programmed differently or you should have made an interface to handle certain things. Worst of all, you may eventually realize that you must alter several places in 50 files to include that new feature that you just considered. Think ahead. Will the dimensions of the GUI, sprites, or backgrounds change? Will I maybe port this to mobile/other systems?
2. Don't attempt to write everything at once without testing. Follow the old adage, "Divide and conquer." When you are just starting to program, you should be taking baby steps, re-compiling/running regularly and of course backing up your versions of functional code on a regular basis.
3. Use a good IDE, but don't limit yourself by it. Know your keyboard shortcuts, and not just the IDE specific ones. If you're working on windows and don't know ctrl+c and ctrl+v, consider taking a step back to learn some basics in order to save you time in the future.
4. Experiment. You won't blow up your computer by typing improper syntax. If you don't experiment, are afraid of the computer, you won't learn much and simply, in my opinion, will never be a good programmer. Through experimentation, I've discovered, and eventually used, techniques that I wouldn't have if I didn't simply stumble upon them. Experimentation will increase your knowledge of the language and potentially grant you more creative insight.
5. Reference the API when needed. Reference Google when needed. Stack Overflow is your friend. The Internet in general is your friend. There is no way to memorize every pre-written framework function, library class field, etc. Reference them, and before you know it, you'll remember that function and won't have to reference it.
6. Always expand your knowledge, research, and be a student. You can code. Great. Learn more.
7. Don't re-invent the wheel and do be that "lazy programmer." Unless you're attempting to learn a language's syntax, use open-source code to your benefit. Trust me, you'll spend plenty of time editing it to suit your needs. Why re-write a standard string function, much less the C language?
8. Know what you don't know. If you're still struggling with common syntax errors, go back and take some tutorials specific to the language. If you're getting past them, do you fully understand all of the features of the language? Are you writing spaghetti code? Are you wasting time by not making use of a certain powerful feature?
If you find these articles to be helpful, I could always use another cup of coffee! Social media likes/+1s are also much appreciated. Thanks for reading!