Answer the question
In order to leave comments, you need to log in
What is the difference between good code and bad code if both work?
Good evening!
My question has some background. While doing a tutorial, I turned to the toaster with a question about a callback function, with which I wanted to refine my script. After looking at my code, one of the experts here wrote that I should not try to learn javascript, like everything is so hopeless.
I completed the task myself, as best I could. Everything works in accordance with the conditions of the assignment. But I understand that after completing the task, I did not learn anything new, but got out with the help of what I already knew.
Please tell me, in essence, what should look like a competent code (pure js) that performs such a task?
What should have been applied?
Task: make two timers that can be set in minutes by pressing the + and - buttons. By clicking on the inscription count! the countdown starts from the value of the first timer, when it reaches zero, the second timer starts and also goes to zero.
jsfiddle.net/mvr1976/52kfwppt/2
Answer the question
In order to leave comments, you need to log in
Send such experts at once.
And if in essence, no one writes the perfect code right away. As I understand it, you are at the beginning of your journey and such code is quite normal, but with many hours of practice, you will begin to notice “some kind of irregularity” in such code. All these ridiculous names of functions and variables, constant copy-paste, lack of structure and code form.
So more perseverance, practice and reading other people's sources.
I took the sword. To the left hand. Hit the knight who was wearing black armor on the head. But didn't hit. And he hit. And hit. I died.
I pulled the sword out of its scabbard with a smooth movement, suddenly, with my left hand, and without a swing hit the Black Prince, aiming at the head. But he evaded me with an inhumanly fast movement, and hit me back. Its shining steel pierced me, spraying blood, and I fell on the stones, losing consciousness and with it my life.
For example, a real Hindu writes a text footcloth for 20 kilobytes in PHP, if and enter in bulk, the code can be complicated and made shorter by 5 kilobytes, and repetitions can be removed.
But it is more convenient to read the code in this form, in a long form.
There is no perfect code. Every programmer has his own pattern of perfection in his head. But terms are a real unit of measurement. And if your code works by the deadline, then you will get the loot. If your code is "perfect", and the deadline has already passed, then someone else will get the loot.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question