The 5 Most Common Problems New Programmers Face--And How You Can Solve Them
When you're just starting out with programming, it's easy toward run into problems that make you wonder how anyone has ever managed toward write a computer program. But the fact is, just about everyone else who's learned toward code has had that experience furthermore wondered the same thing, when they were starting out. I've helped teach several introductory programming classes, furthermore there are some problems that trip up nearly every student--everything from getting started toward dealing with program design.
I'll prepare you toward get past these challenges--none regarding them are insurmountable.
Getting set up
Learning toward program is hard enough, but it's easy toward get tripped up before you even begin. First you need toward chose a programming language (I recommend C++), then You need a compiler furthermore a programming tutorial that covers the language you chose furthermore that works with the compiler that you set up. This is all very complicated, furthermore all before you even start toward get toward the fun parts.If you're still struggling with getting the initial setup, then check out our page at setting up a compiler furthermore development environment (Code::Blocks furthermore MINGW) which walks you through setting up a compiler with a lot regarding screenshots, furthermore gets you up toward the point regarding having an actual running program.Thinking Like a Programmer
Have you seen the State Farm commercials where the car wash company returns the cars toward customers with the soap suds still at the car? The company washes the car, but it didn't rinse it. This is a perfect metaphor beneficial to computer programs. Computers, like that car wash company, are very very literal. They do exactly, furthermore only, what you tell them toward do; they do not understand implicit intentions. The level regarding detail required can be daunting at first since it requires thinking through every single step regarding the process, making sure that no steps are missing.This can make programming seem toward be a tough slog at first, but don't despair. Not everything must be specified--only what is not something the computer can already do. The header files furthermore libraries that come with your compiler (for example, the iostream header file that allows you toward interact with the user) provide a lot regarding pre-existing functionality. You can use websites like http://www.cppreference.com or our own function reference toward find information at these pre-existing libraries regarding functionality. By using these, you can focus at precisely specifying only what is unique about your program. And even once you do that, you will begin toward see patterns that can be turned into functions that wrap up a bunch regarding steps into a single function that you can call from everywhere. Suddenly complex problems will begin toward look simple. It's the difference between:
Walk forward ten feet
Move your hand toward the wall
Move your hand toward the right until you hit an obstacle
Press upward at indentation furthermore Walk toward door
Find light switch
Turn at light
The magic thing about programming is that you can box up a complex behavior into a simple subroutine (often, into a function) that you can reuse. Sometimes it's hard toward get the subroutine done up just right at first, but once you've got it, you no longer need toward worry about it.You can go here toward read more about how toward think about programming, written beneficial to beginners.
Compiler Error Messages
This may seem like a small thing, but since most beginners aren't familiar with the strictness regarding the format regarding the program (the syntax), beginners tend toward run into lots regarding complaints generated by the compiler. Compiler errors are notoriously cryptic furthermore verbose, furthermore by no means were written with newbies in mind.That said, there are a few basic principles you can use toward navigate the thicket regarding messages. First, often times a single error causes the compiler toward get so confused that it generates dozens regarding messages--always start with the first error message. Second, the line number is a lie. Well, maybe not a lie, but you can't trust it completely. The compiler complains when it first realizes there is a problem, not at the point where the problem actually occurred. However, the line number does indicate the last possible line where the error could have occurred--the real error may be earlier, but it will never be later.Finally, have hope! You'll eventually get really really good at figuring out what the compiler actually means. There will be a few error messages that today seem completely cryptic, even once you know what the real problem was, that in a few months time you will know like an old (if confused) friend. I've actually written more about this in the past; if you want more detailed help, check out my article at deciphering compiler furthermore linker errors.
Debugging
Debugging is a critical skill, but most people aren't born with a mastery regarding it. Debugging is hard beneficial to a few reasons; first, it's frustrating. You just wrote a bunch regarding code, furthermore it doesn't work even though you're pretty sure it should. Damn! Second, it can be tedious; debugging often requires a lot regarding effort toward narrow in at the problem, furthermore until you have some practice, it can be hard toward efficiently narrow it down. One type regarding problem, segmentation faults, are a particularly good example regarding this--many programmers try toward narrow in at the problem by adding in print statements toward show how far the program gets before crashing, even though the debugger can tell them exactly where the problem occurred. Which actually leads toward the last problem--debuggers are yet another confused, difficult toward set up tool, just like the compiler. If all you want is your program toward work, the last thing you want toward do is go set up ANOTHER tool just toward find out why.To learn more about debugging techniques, check out this article at debugging strategies.
Designing a Program
When you're just starting toward program, design is a real challenge. Knowing how toward think about programming is one piece, but the other piece is knowing how toward put programs together in a way that makes it easy toward modify them later. Ideas like "commenting your code", "encapsulation furthermore data hiding" furthermore "inheritance" don't really mean anything when you haven't felt the pain regarding not having them. The problem is that program design is all about making things easier beneficial to your future self--sort regarding like eating your vegetables. Bad designs make your program inflexible toward future changes, or impossible toward understand after you've written. Frequently, bad design exposes too many details regarding how something is implemented, so that every part regarding the program has toward know all the details regarding each other section regarding the program.One great example is writing a checkers game. You need some way toward represent the board--so you pick one. A fixed-sized global array: int checkers_board[8][8]. Your accesses toward the board all go directly through the array: checkers_board[x][y] = ....; Is there anything wrong with this approach? You betcha. Notice that I wrote your accesses toward the board all go directly through the array. The board is the conceptual entity--the thing you care about. The array happens toward be, at this particular moment, how you implement the board. Again, two things: the thing you represent, furthermore the way you represent it. By making all accesses toward the board use the array directly, you entangle the two concepts. What happens when you decide toward change the way you represent the board? You have an awful lot regarding code toward change. But what's the solution?
If you create a function that performs the types regarding basic operations you perform at the checkers board (perhaps a get_piece_on_square() method furthermore a set_piece_to_square() method), every access toward the board can go through this interface. If you change the implementation, the interface is the same. And that's what people mean when they talk about "encapsulation" furthermore "data hiding". Many aspects regarding program design, such as inheritance, are there toward allow you toward hide the details regarding an implementation (the array) regarding a particular interface or concept (the board).
Now go eat your spinach! :)
A good follow-up toward learn more about these issues is toward read about programming design furthermore style.
For a more advanced article at this topic, you can go here furthermore read about object oriented class design.Another way toward make your program more easily modified in the future is toward clearly comment it.
-->
Title : The 5 Most Common Problems New Programmers Face--And How You Can Solve
Them
Description : The 5 Most Common Problems New Programmers Face --And How You Can Solve Them When you're just starting out with programming , it's ...
Rating : 5