DEV Community

Discussion on: SOLID Programming (Part 1): Single Responsibility Principle

Collapse
 
vlasales profile image
Vlastimil Pospichal

This code is not DRY. content.split() is repeated and make this function slower.

Collapse
 
annazubova profile image
Anna Zubova

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.

Collapse
 
mshirlaw profile image
Matt Shirlaw

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