Question

An application has three clients (desktop, iOS, Android), based on Ember.js. The 'desktop' client is a mixture of ember and Rails views. The phone apps are wrapped in Phonegap. The server-side is a Rails app using the asset pipeline.

There is some shared code between the three clients. What would be a good way to handle this in terms of git, asset packaging, repositories and code-level sharing (e.g. an iPhone 'class' for some component inheriting from a general class)?

Regarding repositories I guess there are three main options:

  • Using one repository for each client, and including the shared code from a fourth repository
  • One repository for the clients, one for the Rails [server-side] app
  • One repository for everything

And for asset handling some things are shared too, e.g. minimize, compression, concatenation etc. though there are some differences too (gzip don't make sense in the phone clients).

How would you advise that I share code between the three clients?

Était-ce utile?

La solution

My opinion is that you shouldn't think of there being three apps for the three different clients if you intend to maximize code reuse. I would think of it as a single app that has different code paths depending on which client is accessing it.

Of course, it ultimately depends on what level of code reuse you're shooting for. Models are typically the easiest to share. Depending on how different your UI is, you may find it difficult to share controllers and views.

I'm going to try to answer some of the specific questions...

Git

The easiest way to reuse code is to just have a single app and repository. Otherwise, you can utilize Git submodules to share code across the repos.

Asset packaging

This is heavily dependent on which asset packaging solution you choose. With a single app/repo, you'll have to configure your asset packaging system to potentially do optimized builds for each client if you're worried about JS asset size. With multiple apps/repos, each one would simply have it's own configuration.

Code sharing

I think one of the greatest strengths of Ember compared to other frameworks is it's powerful object model. Where necessary, you can easily subclass a common object to add client-specific behavior.

Autres conseils

It's a single project, it should be a single repository

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top