5

I've created a pretty simple templating framework and have default implementations for some of my interfaces used for passing around information. I store these in MyFramework.Default namespace

However, I am unsure of where to place example implementations, such as a template that creates a concrete class. This template seems like it would be useful to people who use my framework, but I am not sure if it belongs in a separate assembly, or perhaps a namespace within the framework.

If it's a namespace, is there any convention for its name?

5
  • What is the language?
    – Apoorv
    Aug 8, 2012 at 14:54
  • I don't quite understand: by "example implementations" do you mean examples of how to use your framework, or implementations of interfaces that people using your framework might want to make use of? Aug 8, 2012 at 14:55
  • @MonsterTruck Sorry, thought it could be language agnostic, its C# and I've added the appropriate tags
    – James
    Aug 8, 2012 at 14:55
  • @Baqueta the latter, basic implementations that most people might want to make use of, but at what point does it become just guessing if its useful, and I'm just making people drag my basic implementations around?
    – James
    Aug 8, 2012 at 14:56
  • You might want to rename "example implementations" to something like "standard implementations" to avoid confusion... Based on the 2 current answers I'm not the only one who got confused! Aug 8, 2012 at 15:55

3 Answers 3

1

There aren't any hard rules that I know of, but the common practice in C# would be to put your standard implementations into the same package as the interface. For example, IList and List both live in the system.collections.generic namespace.

If the implementation is sufficiently specialised you might want to put it into a sub-package. The main thing though, especially if your framework has a significant number of packages, is to be consistent.

Try to think about it from the point of view of someone who's going to use your framework: ideally you want them to be able to discover your classes without having to refer to the documentation.

1

Separate Assembly?

The answer here depends upon how you intend the examples to be used.
If they are templates that can then be directly reused by others within the framework, include them in the assembly.
If the intent is a copy and paste type exercise, put them in a separate assembly.

Namespace

Here, I would suggest that you use a separate namespace regardless of how the examples are to be used. In general, you would expect the users of your framework to have their own namespaces surrounding their work and integrating with your framework's namespace. It will make the example more valid by following that model yourself.
Likewise, reverse that advice if you really intend them to extend your framework's namespace.

1

Your example implementations should be in your unit test assembly (you really should have one, it is the easiest way to test any kind of general library you are building). Examples of using a library will often serve well as some kind of test, and vice versa. Since your unit test assembly is linked against your testing framework (which you normally don't want to deploy), it must be a separate assembly.

Concerning namespace I totally agree to GlenH7.

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.