He/Him; Senior Software Developer, IT Swiss-army-knife, 3 programming blades, 1 hardware, 1 networking and infrastructure and a corkscrew. The tweezers have long since been lost. (Recent ADHD diag.)
I use extensions a lot on sealed library classes to add Quality Of Life things. One example is creating cleaner methods for adding parameters to SQLClient ClientCommand objects as one liners instead of multi-command monstrosities. (ok, they aren't that big, but do look unclean)
I think it's different (safer) in C# though, right? Like you need to add using <namespace> for the new methods to be accessible. So it's not true monkey patching, which is generally dangerous and best avoided.
He/Him; Senior Software Developer, IT Swiss-army-knife, 3 programming blades, 1 hardware, 1 networking and infrastructure and a corkscrew. The tweezers have long since been lost. (Recent ADHD diag.)
Indeed you would need to use the containing namespace. And are likely safer as it would be pretty hard to modify the behaviour of code outside of your intended changes. (I think you would have to try very hard to have any affect outside of your explicit calls to the extension methods)
I won't claim to know much about TRUE monkey patching, but wikipedia's Extension Methods and Monkey Patching articles do reference each other in suggestive ways. ;)
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.
C# allows this,
you can now use this as
I use extensions a lot on sealed library classes to add Quality Of Life things. One example is creating cleaner methods for adding parameters to SQLClient ClientCommand objects as one liners instead of multi-command monstrosities. (ok, they aren't that big, but do look unclean)
I think it's different (safer) in C# though, right? Like you need to add
using <namespace>
for the new methods to be accessible. So it's not true monkey patching, which is generally dangerous and best avoided.Indeed you would need to use the containing namespace. And are likely safer as it would be pretty hard to modify the behaviour of code outside of your intended changes. (I think you would have to try very hard to have any affect outside of your explicit calls to the extension methods)
I won't claim to know much about TRUE monkey patching, but wikipedia's Extension Methods and Monkey Patching articles do reference each other in suggestive ways. ;)