|
|
|
|
|
by k__
3246 days ago
|
|
Some stuff I learned: Don't write/use abstractions you won't understand later. Often you start with 2-3 copies, try to merge them and end up using it at a place were it doesn't fit 100% anymore. Keep nesting low. Often it's faster to scroll over one big okay-ish structured function than to find all the clean tiny things around the the project. Same goes with Objects/Classes/Components etc. Stop using abbreviations and try to write code more readable and not as short as possible. IDEs help with autocompletion and code gets read more than written anyway. |
|
This so much. One of the bigger differences between academic and professional coding is software system longevity.
Premature refactoring is incredibly harmful to readability.
1. You have no idea what the future will require. You will always know more about the requirements in the future.
2. You have no idea how the current use and system will need to evolve. You will always learn more about this in the future.
3. You have no idea how long the current system will be used. Could be 20 years; could be a week (if it's an executive's pet project).
4. Time to MVP > perfect code in almost all instances.
Writing code with clean, documented potential refactoring points, but stopping short of actually pulling all those things apart has served me far better than the alternative.
If you have one function that may not be applicable to a future use case, and you refactor it into two, now you have two functions that may not be applicable to a future use case.
Develop a feel for what's "reasonable" in an initial write, and don't code yourself into an inflexible corner, but defer actual refactoring until it's necessary. Because then you'll have the benefit of knowing far more about the new needs and how the system is used.