Conflict resolution strategy

Nov 11, 2010 at 1:31 PM

It is really great to see how easy it is to override a theme element (view, shape method, etc).

But, what happens if two unrelated modules have shapes with the same name (but different meaning)?
Is there a feature like "namespace" in C# to give a scope and avoid ambiguity?

Same issue may arise with content types/parts having the same name...

Another related issue is: What if there are two modules that can handle a feature like messaging? (Say: Orchard.Email & Orchard.Sms)
If they are both enabled, will the message be processed twice? Or will one of them be chosen?

Coordinator
Nov 11, 2010 at 7:55 PM

There is no formal namespacing throughout Orchard actually. The reason for it is that we prefer to work without that constraint and count on developers to do the right thing. Apply the amount of namespacing you want to the naming of your shapes. If you are making something fairly generic, make the name generic so other modules can possibly build on the same thing that you built. If you are building something specific, make the name specific.

The reasoning behind that is that if you look at some of the platforms that have been succesful recently, such as jQuery, there is a much more relaxed attitude towards naming. In jQuery, plug-ins are not namespaced and conflicts are very rare and easily worked around. Conversely, there are platforms that have failed in part due to complex namespacing ("real" XML and XHTML for example). HTML 5 is explicitly rejecting the idea of namespaces.

As for different modules handling the same thing, it depends on the usage. In the case of messaging channels, yes, you want all the channels to process the messages. In other cases, you'll want only one. It really is up to the code that exposes the hook. Both scenarios can be achieved by either taking a simple dependency or taking a list of dependencies (Autofac handles both). When a single one is asked for, the resolution is made in order of dependency: the feature that has the most dependencies takes precedence, so for example if you want feature B to take precedence over feature A, modify its manifest so that it depends on A.

Nov 12, 2010 at 4:49 AM

I see. I am still a bit concerned... If Orchard becomes nearly as popular as I think it will be and gets a lot of modules, it may happen that an end-user (non-technical person) will install Orchard, add two modules from the gallery that were never tested together before and get a weird result due to these clashes. He will have no idea of what is going on, let alone fix it.

Regarding the features, I assume that if two features (from two independent modules) have the same amount of dependencies, then the one selected is random. Correct?
Is there a way for the end-user to make Orchard pick a specific one?

But, maybe these are things that don't happen often in reality (like people assuming at first that using SVN would result in too many conflicts when committing) :)

Coordinator
Nov 12, 2010 at 6:50 AM

We can deal with that when and if it happens: jQuery has thousands of plug-ins and that hasn't been a problem. Besides, namespacing is no guarantee of compatibility.

If you have such a conflict, you can edit the manifest and establish a dependency to determine which will be taken. But most of the time, it's easier to just take the module you want and remove the other one (unless it's a core module).

You are right that this never happens :)