Answer the question
In order to leave comments, you need to log in
How to avoid or control constant rewriting and improvement of your code?
It just so happened that every week I learn something that can be implemented in my personal project. Here is something that must have, as a result, is forced to rework, edit, or improve everything.
Example, I learned about getting rid of getters and setters, especially in DDD. Because they violate the basic principles. I had to rewrite the core, all methods were renamed, yes, it became more readable, yes, the logic improved.
Now it is much more clear what is happening, although there is more code, because instead of 2 methods, get and set, now there are 2-7+ pieces of methods that perform logical operations.
class User{
...
public function getRating(){...}
public function setRating($rating){...}
//стало
public function showRating(){...}
public function addRating($rating){...}
public function substructRating($rating){...}
public function hasEnoughRating($rating){...}
public function compareRatings($rating){...}
...
}
Answer the question
In order to leave comments, you need to log in
Andrew Stark ,
1) instead of rewriting everything every week, you need to take and spend the same week reading 1-2 books like "Code Complete" or "The Pragmatic Programmer: From Journeyman to Master". This will allow you to expand your horizons a little and give you some basic principles of "good code". This in turn will lead to the fact that you will initially write better code and you will have to rewrite everything less often.
Further, with experience, the understanding will come that not every article on Habré is the ultimate truth and you should not run headlong and implement something. You will understand why exactly you need this change. Develop your own point of view. Everything will stop being black and white. Every architectural question will become "philosophical" and so on and so forth. But this is with experience, so far you have to rewrite it,
2) if you are still learning, then in principle there is nothing wrong with this process.
if a restless perfectionist speaks in you, then it sucks, you will never finish rewriting. or until you gain the necessary experience (see point 1)
3) if you do it in commercial development, then everything is very bad
from the point of view of any business - it doesn’t matter how brilliant, simple and support your code. If there are no obvious bugs, then it will work in the general case in exactly the same way. And what you are doing is a waste of resources (time and money)
For wisdom says - "
If you translate it into our language, while you are rewriting the same thing for the hundredth time, competitors have already coded and stole our customers a long time ago. Therefore, I would advise you to take into account such a factor - "is this change burning right now." If it doesn’t light up, we’ll do it when it does, now we need to quickly go into production and bring our work to investors.
I wrote a little chaotically
If in short:
- at first we study more than we write
- there is no limit to perfectionism
- correctly prioritize your work
- wash your hands before eating
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question