"Thinking like a programmer"

Source: Internet
Author: User

Introduction

"Thinking like a programmer" is a guide to training programmers in programming ideas. This book begins with a classic puzzle, and puts forward some methods of thinking commonly used in programming, such as Restatement, analogy, division, and subtraction. It also provides specific techniques such as using arrays, pointer dynamic memory, and classes to solve problems. The idea of large recursion and the idea of good and false in foreign objects are put forward emphatically. This book focuses on the development of the programmer's self-confidence, advocates the use of existing methods to solve the unknown problems, but also encourages the exploration of self-learning technology.

Three classic Puzzles

Fox, Goose, and corn cross the river: retell the problem in a formalized way to better insight into the problem. Programmatically lists all operations to discover "hidden" possible operations, which are freely combined to achieve the desired result. Recognizing that thinking is likely to be as productive or even better than thinking about solutions.

Tile Slider movement problem : Inability to plan a complete solution does not mean that you cannot take a strategy or skill to solve the problem systematically. The problem can be broken down into a small part, the simple version of the problem of the study found a common technique ("string"), to solve the simple version of the difficulty in order to increase the reduction problem step-by-step solution.

Sudoku Lyrics question : "Maximum constraint variable". Looking for the most restrictive part of the problem, although the constraints often make the problem difficult to start, but they can also eliminate a lot of choices, simplifying ideas. Search for those spaces that may appear with the least value in the crossword. If a part of the problem has strong constraints, it is likely that you should start from this section without worrying about spending time on tasks that might be reworked in the future.

Basic problem-solving skills

Planning : It is necessary to plan in advance, rather than to conduct a direct, non-directional attempt.

restate the question : in different ways or terminology, re-examine the problem and discover new ideas.

Partitioning (divide and conquer): Find a way to divide the solution of a problem into several steps or stages that can make the problem easier to solve.

start with what you know: When programming is about solving a problem, try to start with the part of your knowledge. When you use your skills to study a problem, you can better understand the problem itself and its ultimate goal.

Mitigation : When faced with a problem that cannot be solved, the scope of the problem can be reduced by reducing it. You can add or remove constraints to create a problem that you know how to resolve. The problem of reduction and the original problem still have quite a lot of commonality, will let us to the final solution further. The problem of mitigation allows us to understand exactly where the remaining difficulties lie.

Look for analogies : Analogies are the similarities between a current problem and an already resolved problem. The premise is that there are a number of solutions available for reference.

Test : The test is a controllable process. Let's say what happens when some code executes, then experiment with it to see if its assumptions are correct, and according to these observations, we can get some information to help you solve the problem. Another form of testing is similar to commissioning.

Avoid frustration : frustration is deteriorating, and it is likely that mild anxiety begins at first to become an intractable annoyance. Method: First make a plan; second, you can rest for a while.

"Thinking like a programmer"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.