5

I'm planning to build a shared librarie toolbox for my customer. The idea is to factorize reusable code in a single utility framework.

Some of the classes can run on Sandboxed solution, other requires farm solution. But as the sandboxed compatible classes can also run on farm solution, how do you recommand to structurate the project ?

I assume I'll end with two projects : MyCustomer.SharePoint.Common and MyCustomer.SharePoint.Common.Sandboxed.

When class are compatible with sandboxed solution, should I :

  1. duplicate the code (does not like it)
  2. Link the code between the two projects (using Visual Studio Add existing item dialog, add as link option)
  3. suggest the consumer developer to reference Sandboxed assembly even in farm solutions
  4. Another option I don't know yet ?

1 Answer 1

3

I would advise you to have two separate assemblies:

  1. MyCustomer.SharePoint.Common
  2. MyCustomer.SharePoint.Common.Farm

Assembly 1 involves code relevant to both sandbox and farm solutions, while the second assembly is specifically for farm specific code.

As the first assembly will be used by both farm and sandbox, you can leave it at MyCustomer.SharePoint.Common. (Assuming you have the same namespaces) This will help you identify code which can be shared, and code specific to farm features.

Obviously this is a suggestion for clear coding practices, and there are different approaches you could take.

I advise against duplicating code if possible (a bit off topic, but one example where you can't reuse the same code is in a silverlight solution and a WPF solution), and linking source is going to be a nightmare.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.