0

So lets say we are creating a simple "modular system" framework.

The bare bones might be the user management. But we want things like the Page Manager, the Blog, the Image Gallery to all be "optional" components.

So a developer could install the Page Manager to allow their client to add a static home page and about page with content they can easily edit with a wysiwyg editor.

The developer could then also install the Blog component to allow the client to add blog entries.

The developer could then also install the Gallery component to allow the client to show off a bunch of images.

The thing is, all these components are designed to be independent, so how do we go about ensuring they don't clash? E.g. ensuring the client doesn't create a /gallery page with the Page Manager and then wonder why the gallery stopped working, or the same issue with the Blog component, assuming we allow the users to customize the URL structure of the blog (because remember, the Page Manager doesn't necessarily have to be there, so we might not wan't our blog posts to be Date/Title formatted), likewise our clients aren't always going to be happy to have their pages under pages/title formatting.

My core question here is, when building a modular system how to we ensure that the modules don't conflict without restricting functionality?

Do we just leave it up to the clients/developer using the modules to ensure they get setup in a way that does not conflict?

2 Answers 2

1

namespaces are the usual response to this. A namespace limits the scope of the components internals (objects, methods and variables).

Different languages implement namespaces to a greater or lesser extent

php: http://www.sitepoint.com/php-53-namespaces-basics/

javascript: http://www.kenneth-truyers.net/2013/04/27/javascript-namespaces-and-modules/

Usually you can specify which component you mean by specifying the namespace, e.g. mycomponents.mylistcomponent specifies the mylistcomponent in mycomponents namespace. Most languages provide a way of skipping specifying the namespace all the time e.g.

in c#:

using System.Objects

will look in the System.Objects namespace for any objects you declare

3
  • Yes, this is fine from the code perspective, but taking the concept of namespaces to the end clients usage in the modules would be to enforce that any blog posts must be at /blog/... and any posts from the Pages module must be under /pages/...
    – Hailwood
    Apr 23, 2014 at 0:50
  • 1
    You're talking about building something like a CMS? Then it's up to you really, have a look at Umbraco.com perhaps - one I'm familiar with - it has a component system.
    – daven11
    Apr 23, 2014 at 1:02
  • You won't find a solution that doesn't involve either collisions and breakage or a central authority deciding where things go. Your modules aren't independent of each other since you've given them access to a mutable shared resource (the path mappings).
    – Doval
    Aug 21, 2014 at 11:26
0

You can't have both without restricting your user:

allowing users to create the URLs freely AND having collision-free URLs for each module.

If you want to allow users to create URLs, you may check if the entered URL is already in use through doing self-queries but that would still result in having the user restructure the URL catalogue in case there has been a misconfiguration (like in your /gallery example).

You could create URLs based on module name automatically i.e. /gallery-one for an entry one for module gallery and then offer user functionality to add non-colliding URL rewrites but this may lead to seriously confusing .htaccess files.

1
  • Oh, just saw it's 8 month old. You probably found a way in between :-D
    – SaschaM78
    Dec 19, 2014 at 13:20

Your Answer

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

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