I'd generalize this and say that whenever you have a structured string like:
urls
emails
phone numbers
SQL queries
Mailing Addresses
???
That you need to extract or inject info into (not just store or copy), then you need some sort of Builder pattern or Editor pattern to do so. You can use a third party library or build your own if it doesn't exist.
But the advantage of treating it as a library is that it can evolve over time and your code isn't riddled with N half baked implementations.
About 16 years ago I was presented with a situation in which we had a major application that was building SQL statements on the fly, and creating my own SQLBuilder really was able to make to code far more maintainable since so many parts of the code where editing SQL in different ways.
SQL editing has since fallen out of favor, and ORMs basically provide that function now. But the principle remains.
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.
I'd generalize this and say that whenever you have a structured string like:
That you need to extract or inject info into (not just store or copy), then you need some sort of Builder pattern or Editor pattern to do so. You can use a third party library or build your own if it doesn't exist.
But the advantage of treating it as a library is that it can evolve over time and your code isn't riddled with N half baked implementations.
About 16 years ago I was presented with a situation in which we had a major application that was building SQL statements on the fly, and creating my own SQLBuilder really was able to make to code far more maintainable since so many parts of the code where editing SQL in different ways.
SQL editing has since fallen out of favor, and ORMs basically provide that function now. But the principle remains.