Reputation: 13147
I have an existing site build in c# 3.5 using asp.net mvc 1.
There is a section of the site that requires additional behaviour. Basically there is a need to configure an object that is in one of the base libraries to have extended features. If these extended features have been specified on the object, then additional content/functionality should be exposed within the details page of this object.
In terms of extending my object with new functionality I was thinking of using the decorator pattern, creating an extendedobject with additional properties etc which I could persist to another database table. I would manage all of this within an extensions library.
My problems start at the controller/view level. All of the controller actions have already been written and are in the base library that I do not want to modify. I can make minor modifications to these - however, no breaking changes can be introduced, and all existing functionality should be maintained as the library is used elsewhere. I can however, create as many new controllers/services as I like.
To makes things more complicated, this extended functionality is not required for all of the existing objects within the site. The client will need to be able choose to convert certain instances of these objects to the extended type when viewing the details page for the object.
This makes my details page very messy. I now need to figure out if the object has been extended already, and if not show the controls which allows the user to convert it to the extended type. If the object has been extended then I will have to display out all it's extended content out onto the page. This would be oki if the functionality was isolated to a specific section of the page (yay, one renderaction!), but the extended content will be output throughout various parts of the page. It seems messy doing a load of different renderactions everywhere, which should only output different content based on whether it is an extended object or not.
I half considered doing a single ajax query, and then dynamically rendering each of the sections using javascript when the details page has loaded.
I don't want to break or change the existing libraries governing the base functionality of this site.
What is the best way to approach this type of problem?
Upvotes: 0
Views: 197
Reputation: 1703
Could you create an interface matching the existing functionality. Then implement the interface with the new functionality and use a factory to load whichever one is required.
I do realise this is a code change though but the new functionality could be in a separate project and the factory and interface wont be a massive change to the code.
just a thought
Upvotes: 1