Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to solve an issue with reusing components. I have some UI components (a mix of JS, CSS, and HTML) that are not specific to any application. These UI components need to be able to be used in multiple applications. One is a RoR application, the other is an ASP.NET MVC application. How can I maintain these components (e.g. with version control, distribution) and still make them accessible to the different platforms that need to consume them?

For example, ApplicationA and ApplicationB use UIComponentA, which is not natively a part of their projects or repositories, because UIComponentA lives in its own repository. How can these projects get the dependencies they need while keeping the components reusable and hosted in their own location? Does anyone have experience with a similar situation, and if so, how did you tackle it?

If you need further information, don't hesitate to ask, I will update this question.

share|improve this question
Interesting concept, across languages and platforms there are tens if not hundreds of such similar HTML, JS, CSS solutions however I have never heard of a multi-platform one yet. I am just not sure exactly what your question is however. What do you mean by maintain? How can we answer a question about how to maintain such a thing if we don't even understand the architecture behind it? – maple_shaft Dec 16 '11 at 19:46
Easiest solution is implement a templating / component mechanism that works with all these platforms. – Raynos Dec 16 '11 at 19:49
I guess that is the main thing, the client-side and the templating of the UI will be done on the client. But these pieces need to be shared between these different applications. What can help with that? – Eli Dec 16 '11 at 19:52
Raynos has the right idea. The more that's done on the browser side the more it can be platform independent. If you use the framework to send data and let the client render it via templating the client won't have a lot of dependency on the framework. You could even mix and match components that work that way with framework stuff if you need to use existing framework stuff. Maybe look at Backbone.js for some examples. – psr Dec 16 '11 at 20:01
I understand the technologies, I guess what I am more concerned about is integration pain points. For example, let's say the UI components are hosted in a git repo. RoR application is in mercurial, and the .NET in TFS. Should the UI components be on their own webserver, and the applications make calls to go get them to embed in their page? Is there some other mechanism to embed the UI repo in the application repo so the app can deliver the components and still pull updates? These are the problems I am trying to solve. – Eli Dec 16 '11 at 20:05
up vote 3 down vote accepted

I think you can look at any number of publicly available client-side frameworks like jQuery and YUI and see how they are deployed. Any particular project may be dependent on a specific version of the UI lib. It can either copy the relevant version to it's own repo or grab as part of the deployment process. Another option is CDN approach where the UI components are actually hosted independently and are just pulled in client-side.

share|improve this answer
So far I think this is a pretty good solution. – Eli Dec 16 '11 at 20:30

One option would be to host the packages (JS, CSS, Static Images, etc) on a publicly accessible URL and just reference them where needed by the url. This is how jQuery and all the big libraries do it.

share|improve this answer

From reading your question, the most significant issue seems to be "bolting down dependencies in a technology agnostic way". To be able to resolve this you could create a service facade that provides you with the reuasable elements as mentioned by @Mike Brown and also provide data and functionality by exposing some implementation of RestFull services. This introduces an extra layer in your system by which you isolate the top level(UI) components from the implementation of the components it depends on.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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