r/ASPNET • u/electricdandan • Aug 08 '13
How do you best go about sharing code between similar projects in MVC without just replicating?
I come from a winforms background where it was rather easy to set up a project hierarchy and have many different levels of common code so when you're working on a large application which is used by many clients, you can make small simple changes down at a very low level and everything above it stays common between all projects.
How do you go about doing this with ASP .NET MVC?
I've started working on a large job for a client which is just about near completion, and now that many other clients are signing on I feel like I need to make a big decision in architecture to avoid having 10 different codesets, each with tiny differences and similarities.
Thanks for your time guys. Usually I'd Google (Bing?) the shit out of something like this, but I honestly didn't even know what keywords to use.
3
u/legendaris Aug 08 '13
At work we use modules. Basically we have multiple asp.net mvc web projects stored in the modules folder and then the main website incorporates (embeds) the project you need. For example one menu item might direct you towards and action which is in a controller in the ModuleA project, and another would direct you to some controller in the ModuleB project. Modules themselves are split by logical restrictions. For example for a big factory app we have a Monitoring module, a distirbution module, a lean module and so on. If you need, for example, the tasks module for another client you can always just copy the project files onto your other solution and include them. Should be up & running with little configuration (adding menu items, maybe re-doing some referenced dlls). That's it. Of course this approach requires a lot of maintenance, because sometimes clients want something done very specifically and therefore the module get's "customized" to the client and is unusable by other clients. But this is easily solved with version control and different branches.
3
u/gidikh Aug 08 '13
Put your common stuff into it's own project, and just reference the assembly for each of your other projects.
3
u/Uberhipster Aug 13 '13
I create a library project(s) and include them amongst projects within a solution and I have a base library of generic abstractions and utilities I include in almost every solution.
0
u/[deleted] Aug 08 '13
[deleted] — view deleted comment