I got a requirement in my project to add another property to some class. Now I want to avoid changing the class because I figured it shouldn't be aware that he has this property (this property only has significance in the context of this project).
The way I thought to accomplish this was (Please critic this because I wanna know if there are simpler ways of doing this)
- Adding a new singleton class that has a mapping between objects of my class and the type of the property I wanted to add
- adding in this class an extension method (extension property?) to access the mapping and fetch the property.
Is there a simpler alternative? Is this just unnecessary complexity? Maybe I should just add a new property to my class?
Thanks!