Skip to content

Front End Directory layout and more #51

@franleplant

Description

@franleplant

Hi!
I have been looking at Synth and I think it's awesome, the Back End side is pretty neat and simple, in fact you read my mind because I was planning to work on something similar.

There are a couple of things that I think that Synth needs to improve in order to live up to its potential, in particular, things related to the Front End, in order of importance:

1. Proper Angular.js Directory Layout

There has been a lot of discussions about Angular.js Directory Layout, in fact the Phone Cat official Angular.js tutorial uses the current Synth Angular directory structure, but the reality is that when working with non-trivial Angular apps this layout becomes obtrusive and just messy.

That's why a lot of smart people, even the Angular Guys, have been proposing alternative layouts that are module oriented instead of abstraction oriented:

My experience with Angular.js supports the Module Oriented directory structure, it fits better with the way of thinking and creating apps and it encourages better practices.

I think that Synth should go for this structure instead of the current abstraction-oriented layout.

Corolari: Implementing this structure will probably need Synth to integrate a more complex build system for which I encourage Browserify, I also can provide help with it.

2. Template Cache instead of Script tags

Angular.js has a built in mechanism to solve the Template Caching that currently Synth is solving with the <script id='path/to/template.html' type="text/ng-template">, which is more sophisticated and less obtrusive to the HTML document: enter Template Cache.

There are, also, components for both Grunt and Gulp that automate this process:

Please note that this are not the only ones, just the first that Google showed, but they do work seamlessly.

3. Preloaded Data should not be a Global Variable.

I think that the Preloaded Data is a great Idea, but I think it should not be a Global Variable, for starters it's really obtrusive for the HTML when you have a lot of data and it feels like Synth is getting a side track to implement this.

I believe there is a better way of solving this: Angular Service:

//common/preloadedData/preloadedData.js
angular.module('synth.preloadedData', [])

.factory('PreloadedDataService', function () {

  var preloadedData = { ... filled in the server ...};

  return preloadedData;
});

In this way you are not going Around angular in order to get this feature done.

4. Test integration by Default

I know this has its complexities to implement, but I strongly believe that Synth should come right out of the Box with testing in mind, it should have at least Front End and Back End test boilerplate and opinions about it. And if you are as crazy as I am with testing Synth you have Integration testing and High level testing with it, the Angular.js default is Protractor.

Other notes

I think that in some point Synth is going to need some type of Build System to delegate all the task that regularly needs to do, for which I strongly suggest Gulp instead of Grunt. And this are my personal reasons, but there are a lot more out there:

  • Gulp.js is faster (it uses memory instead of disk as intermediate storage, which is Grunt behavior)
  • Gulp.js tasks are easier to create and maintain: When the tasks get complicated the Gruntfile can become a real mess and a pain to maintain.
  • Gulp.js feels more natural, and has more relation with Make than Grunt.

End

Synth has a lot of potential, and I'd be glad to submit pull requests implementing this in my spare time, I'd like your feedback, let me know what you think!

Fran

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions