---
title: "Comment by BarTech on \"Code Smell 46 - Repeated Code\" | Hashnode"
description: "Full agreement with general idea. But given example that should fix supposed duplication is a regression from readability perspective. TextReplacer()-&gt;replac"
url: "https://hashnode.com/posts/code-smell-46-repeated-code/5fcefccdded61e1bd07e93f1/comment/5fcfae54a38e1f208d80d940"
---

[Discussion](https://hashnode.com/posts/code-smell-46-repeated-code/5fcefccdded61e1bd07e93f1)

Comment [Code Smell 46 - Repeated Code](https://hashnode.com/posts/code-smell-46-repeated-code/5fcefccdded61e1bd07e93f1)

[BarTech](https://hashnode.com/@bartech)

[Dec 8, 2020](https://hashnode.com/posts/code-smell-46-repeated-code/5fcefccdded61e1bd07e93f1/comment/5fcfae54a38e1f208d80d940)

Full agreement with general idea. But given example that should fix supposed duplication is a regression from readability perspective. `TextReplacer()->replace()` API is awful. First it's more code not less and most important it's way harder to understand. I would classify this as clever code or overengineering. Refactoring like this make sense when repeated code have more logic, some local variables, in general you have to spend time to understand what it's doing. In this case abstracting and giving method descriptive name make total sense. In your example it's making simple code complicated.

[Maxi Contieri](https://hashnode.com/@mcsee)

[Dec 8, 2020](https://hashnode.com/posts/code-smell-46-repeated-code/5fcefccdded61e1bd07e93f1/comment/5fcfae54a38e1f208d80d940#reply-5fcfdf5a9916522a48417fef)

I agree with you. It is an over engineer example. I tried to find a better one and also shorter. Many examples i find in real world are too long to embed.

I might replace it with a better one soon.
