Calling a built-in method in different functions doesn't mean that the code in not DRY. You could argue that the code could be optimized without repeating split() call, but as we know, premature optimization is the root of all evil. I would not try to optimize it further without having a big picture of the whole code in mind. Besides, the point of the article was to show an example of single responsibility, not optimizing for speed.
Since the article is about the single responsibility principle I think it is overly harsh to attack it based on one function being repeated. It would be easily refactored if performance became an issue. The article does a good job at getting the main point across. There's no place for that sort of attack on dev.to
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This code is not DRY.
content.split()
is repeated and make this function slower.Hi Vlastimil,
Calling a built-in method in different functions doesn't mean that the code in not DRY. You could argue that the code could be optimized without repeating split() call, but as we know, premature optimization is the root of all evil. I would not try to optimize it further without having a big picture of the whole code in mind. Besides, the point of the article was to show an example of single responsibility, not optimizing for speed.
Since the article is about the single responsibility principle I think it is overly harsh to attack it based on one function being repeated. It would be easily refactored if performance became an issue. The article does a good job at getting the main point across. There's no place for that sort of attack on dev.to