A
A
Ali Kartoev2015-08-03 14:20:36
Java
Ali Kartoev, 2015-08-03 14:20:36

Is it worth looking at someone else's code, disassembling and then reproducing it yourself as a keepsake for study?

Will it benefit or harm? I'm trying to write the code myself, but so far it's not working out very well.

Answer the question

In order to leave comments, you need to log in

7 answer(s)
M
mamkaololosha, 2015-08-03
@mamkaololosha

There is one big disadvantage in this approach: you will never know why the author wrote that way. Code typically makes up ~25% of an author's knowledge. And it is possible that he came to just such a decision only after 10 different prototypes. Either learn the theory so that there is a complete picture in your head, or the way you want. But this turns out to be cramming and will only work on the exam.

V
Vladimir Martyanov, 2015-08-03
@vilgeforce

It's worth watching and understanding someone else's code, but not reproducing it as a keepsake.

D
Denis Ineshin, 2015-08-03
@IonDen

There is a huge difference between understanding and learning by heart. Get memorization out of your head forever, you are no longer in school.

A
Andrew, 2015-08-03
@Ashlst

Learn theory.
You don't need to learn from memory - it's pointless. You should understand how it works, note interesting implementation points, try to improve / simplify the code.

V
V Sh., 2015-08-03
@JuniorNoobie

Everyone writes what is useful. But this is if the knowledge base is more or less solid. Otherwise, you will spend more time in the search engine than in the wilds of the code. In general, it is better to find the source code of what you are familiar with, so as not to spend a lot of time understanding it. A simple toy, for example.

A
Alexey, 2015-08-04
@TheKnight

Do it differently. Write a set of tests that check the execution of the task solved by the code that you want to "memorize". Then write a condo, crutch, but your solution to this problem is a passing set of tests written at the previous stage. Compare these two solutions. Try to understand why the author did this and not otherwise. How is your solution better or worse? Draw conclusions about differences and similarities.
What is the plus - you learn to come up with your own solution for the problem. Unfortunately, not everything and not always invented for us and Google is not always omnipotent. What are the disadvantages - you can write disgusting tests out of your laziness and you can write no less disgusting code, designed only to pass these tests. For example, to chordcode the input data and the answers to them. True, as for me, in many simple tasks it is easier to write a normal solution than to hardcode data.
If we are talking about code style, then we should not rewrite the code from memory, but simply participate in the life of the corresponding project. You will be tapped on the fingers for the crooked style, don't worry.

B
belkin-labs, 2015-08-09
@belkin-labs

If the author is trustworthy, then I have never been shy to see how something is implemented. So, for example, you can learn a lot by understanding the codes of modern engines. There are engines that just force you to be on the cutting edge of modern technologies (I program in PHP and talk about blog and store engines) In one way or another, programming is a creative application of clichés and patterns. These clichés and templates for programmers can be different. You do so. Looked at the other - and he is better. And they replaced their current cliché or template.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question