How can I better understand how to solve a specific problem?

Today I am quite fluent in several different languages, but it seems to me difficult to find the best way to solve specific problems. What are some ways to improve the quality of solving programming problems.

+4
source share
17 answers

Experience. Solving something completely new is difficult. The best way to solve problems is to try to find the problem that you solved earlier, and that seems to be, and adapt the solution to the new problem. Therefore, until you have experience with many different problems, it is difficult to solve new problems that you encounter. Visiting such sites and reading questions and their answers is a great way to find out how others solved the problems they encountered.

+10
source

Basically, "just do it." When you need to make a choice, just make any choice (other than flipping a coin).

Once you have something that works, then lean back and scratch your head about what you did wrong, and how to do it better.

If you have absolutely no idea how to do this, just solve part of the problem completely and continue.

I suggest checking out this book . They are not the best guy on the block, although they want us to think that they ... but they did a good job with Basecamp.

+4
source

When you have a hammer, everything starts to look like a nail.

So, make sure that you are well versed in algorithms and data structures. When you study them, think about which approach a particular algorithm uses.

+4
source
  • Ask someone else. Someone in your office, on Twitter or SO, or even with your wife. People without technical knowledge often come up with simpler solutions.

If you decide it yourself, try one of the following:

  • Do a quick search for another person or project who tried to solve your problem. If they have a blog, documentation, or source code, you can find out about their implementation.

  • Come up with at least two solutions and choose the best one.

  • Imagine you have 15 minutes to solve the problem before the civilized world is destroyed by Nuclear War / Skynet / Seinfeld's constant endless repetition, you might think of something much simpler that gets 99% of the work done.

+2
source

alt text

The book is a set of heuristics for solving problems. Read about it on Wikipedia . Buy it on Amazon .

+2
source

Solving current problems. Practice makes perfect.

If you have time to speak several languages ​​fluently , I assume that you did not spend a lot of time doing any real work. If you have a job, it may be time for a new one. If you are still in school, are you interested in starting a project for yourself or contributing to the one you use regularly?

This can help you find out what problems you have with difficulty.

+1
source

Go find free source code or a free project where you can get excited and contribute. I learned a lot by signing up for the code for my favorite video game mod.

+1
source

Experience.

The study is really only going so far. Find something fun and small. Do it.

+1
source

One way that seems to work for many people is to choose a book, such as Programming Challenges , as a guide and focus on solving problems of a certain type. For example, if you are weak in an area such as graphics problems or dynamic programming, find a set of problems for the online judge and work through them. You will begin to recognize patterns and be able to classify problems.

+1
source
  • Google for an answer. Most likely, someone else solved the same problem or a similar problem earlier.
  • Ask like that. :)
  • Read some tutorials or online articles on design patterns.
  • Problems can have many solutions, some simpler and more complex. Do not make you think that there is only one solution. Just go with the simplest solution that makes the most sense in the context of your application.
  • After many years of experience, you will be able to come up with your own solutions to most problems. :)
+1
source

Research Algorithms !

Find and hold as many examples as possible, books on programming topics or otherwise, etc.

Problem solving skills can also be improved by playing tactical games.

This helped me solve problems and get better (not necessarily good) when solving problems:

Chess and igo

+1
source

I like this general method:

  • List possible solutions with their strengths and weaknesses
    (This will make you briefly grope them all)
  • Choose the best and make your design on it
    (If you find a heavy obstacle, reconsider other options)
  • Run

Most importantly, at every step, find out

+1
source

The best way is probably to study the master form, if this is an option. Especially if you can find someone familiar with the problems of your addressing.

As a rule, the more tools we have, the more opportunities to solve the problem. I agree that it is important to always code and always deliver something that works (albeit inelegantly). But I think that we need to increase our skills / knowledge in many areas:

  • Language skills (knowledge of the language (s)).
  • Programming paradigms (imperative, object, functional)
  • Infrastructure knowledge
  • Algorithms
  • Patterns
  • Data structures
  • Methodologies (Agile, DDD, BDD ,? DD)
  • Instruments
  • etc.

You can get a lot of skills at work right on time, but I usually have a pet subject anytime I try to get a deeper understanding, usually it means getting a book and reading it on the cover.

+1
source

Work through your project through Project Euler and look at solutions to other problems. Almost every problem will be solved in a way that would not have occurred to you, and usually with greater efficiency.

+1
source

I think that there is much more than raw experience associated with becoming a good problem solver - because I saw problem solvers with a lot of experience.

Here are some tips, but you can find a lot more on the Internet.

  • Look at a number of problems and find out what they have in common. The greater the community with which you understand the solution to a problem, the more you can apply it to other problems.
  • Try to find approaches that Good Problem Solvers use to solve the problem. But do not assume that someone has a monopoly on problem solving.
  • If you read Richard Feynman's book , you will notice that he considers many different routes to get to his goal. Do not narrow your approach prematurely
  • Be positive. Suppose you can find a solution to anything. Your state of mind matters. Enjoying the problem-solving process makes it easier.
  • Do not bang your head against the wall. If you don't seem to be making progress using one approach, try a different approach.
  • Always look for more ways to solve problems and much more in the process of solving problems.
  • Get ready to work. He can still work hard to solve some problems.
  • The more different areas of study you know, the more points of view you have. I have a strong mathematical background, and I find it very useful for many problems. Physics, music, or any other point of view may be useful.
+1
source
  • Problems solving problems.

  • Take algorithms or a discrete math course.

0
source

Here are some tools that I have used in the past to help me understand a specific problem and its solution. I do not always use them today, but they helped me learn to think about how to destroy the problem and come up with a solution.

  • Class-Responsibility-Collaboratio n (CRC) cards One card for each class, describes the responsibility of the class and other classes with which it collaborates. Using cards, you can place your design for a solution and see where you have too many connections or too much responsibility. They allow you to think about design in an easy way before you execute code.

  • Use cases Either actual structured use cases that describe how the user interacts with the system, or even shorter stories or stories. I still use stories, although I write them down on the wiki instead. This allows you to interact informally with the system. Stories are mainly placeholders for conversations that you need to have with the client about what needs to be done. Using the collected stories, you begin to understand the overall purpose of the code. You can also start to see how everything interacts and what works with other things. This is really the beginning of the design.

  • UML Diagrams - especially Interaction Diagrams . For a while I used a lot of them. It really helped to understand how everything works together under the hood. I am still informal, some complex interactions so that I do not miss anything important. Passing through many of them really helped me think about how my objects interact, and now this is a kind of second nature to think in terms of interactions.

  • Class diagrams are a really high level of code representation. They allow you to see your code structurally, especially if you can break the diagram into components or layers of the architecture. I mainly use them now to explain the code to other people when necessary. At startup, they provide pretty good visualization, though, if you're struggling with a bird's eye view of the code.

The best advice I can give you if you try this is to follow the "rules" until you really understand what is happening. Once you feel that you have a better understanding of what they provide, you can use them or not or change how you use them to keep only what is good and let other things go.

0
source

All Articles