A
A
aleksey2016-12-30 23:44:44
Java
aleksey, 2016-12-30 23:44:44

How to learn to implement algorithms?

I've been working as a programmer for quite some time, but I never learned how to implement algorithms. For example, I have some description of an algorithm in natural language and I need to implement it, say, in Java. Usually I implement a rather cumbersome construction, which is not simple and elegant, and I don’t have the ability to separate the main from the secondary and put it on the shelves. The result is a very complex vinaigrette.
Advise me how to straighten my brain. :)

Answer the question

In order to leave comments, you need to log in

14 answer(s)
E
evgeniy_lm, 2016-12-31
@evgeniy_lm

Statement "I've been working as a programmer for a long time, but I never learned how to implement algorithms." contradictory. A programmer is someone who knows how to implement algorithms, he is paid money for this. Those. some part of this statement is wrong (maybe both)
But that's not your problem. By itself, the "implemented algorithm" is a purely theoretical, meaningless substance, approximately the same as "a spherical horse in a vacuum." This is what students do in computer science classes. In real life, the programmer is paid by the customer (employer) for solving his problems. Those. the programmer must study the problem and break down the problem into a sequence of algorithms. What happens as a result is called a program, and the process is called programming.
В вашем случае получается что вы не решаете проблему (не пишете программу), вы в нее даже не вникаете, а пытаетесь писать бесполезный, ни кому ненужный код.

S
sim3x, 2016-12-30
@sim3x

Практикуйся

F
FoxInSox, 2016-12-30
@FoxInSox

Напрягитесь.

A
Alexander, 2016-12-31
@fireSparrow

0. Practice.
1. Read about OOP and design patterns.
2. Study other people's good architectural solutions.
3. Learn refactoring techniques and practice refactoring your own and other people's code.
For example, it is very clear and detailed about refactoring here:
https://refactoring.guru/en/refactoring/what-is-re...

F
Frozen Coder, 2016-12-31
@frozen_coder

Read books on algorithms, on code purity (Martin's Clean Code is like a bible), study someone else's code - senior colleagues and the openSorce community, practice - implement simple algorithms, read Martin's kata, go back to your code and think about how to improve it. Quite a long time - how long is that? Have you overcome 10 thousand hours of programming?

C
cap_nemo, 2016-12-31
@cap_nemo

It is necessary to pour green tea from the southeast of India, collected in mid-March by 19-year-old Indian virgins on a clear night at 3/4 of the moon.
Drink this tea every day for 3 years. After that, you need to hammer a 50 mm nail into the board, turn it with the tip up and sit on this board. The board must be made of sandalwood. If the insight on how to program does not come by itself, then I suggest thinking about the following:
And if you are really interested in programming, then I recommend that you notice for yourself:

  • There is no limit to perfection. Pay attention to your results. Maybe they can be improved?
  • There is always a new methodology or paradigm emerging. What's stopping you from coming up with your own? Natural languages ​​are thousands of years old, if not more. And synthetic ones (for "real" programming) are not older than 70 years. Until programming languages ​​achieve the necessary flexibility, many programmers will have their brains stiffened by constructions like GOTO ;-)

V
Vitaly Stolyarov, 2016-12-31
@Ni55aN

And what about the graphical representation?
For example, draw the input data and the expected result, and depict several options for solving the problem, and then explore: check how many steps need to be completed, which of them complement each other, how intuitive it is

D
Derevianko Alexander, 2016-12-31
@dio4

I highly recommend https://www.ozon.ru/context/detail/id/128304/

B
Beginner, 2017-01-03
@otetsgoogla

Codewars.com is a great site, first you do it yourself, then you watch how others have done it

U
utyfua, 2016-12-30
@utyfua

If vinaigrette comes out, then it is worth breaking it into smaller subtasks and solving them separately.
In theory, everything should be in its place if everything is done normally.
The main thing is not to get carried away because there will be one function to call one function and return its result ..

X
xmoonlight, 2016-12-31
@xmoonlight

Draw an object dependency diagram.
Then - you will understand.

A
Andryukha, 2017-01-06
@syrov

What you described is more likely to fit depression, and not problems with your code for the algorithm. Otherwise, try to take your code for the algorithm and describe specifically what is wrong with it. Is it slow (why)? Lack of knowledge of Java (did you give it to someone
for feedback)? Bad style (like a feature that is too complex and difficult to read on your own after a while).
Probably the main thing for good coding of algorithms is to love it (programming). Maybe you just pulled up a boring topic for you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question