Live data from Hacker News

Code Organization in Large AngularJS and JavaScript Applications

cliffmeyers.com

21–24 of 24 posts

Re: Code Organization in Large AngularJS and JavaScript Applications

#21
I'm building a rails+angular app at the moment, and sort of fell by default in the component-type folders. Reading this blog makes me think that you're right and topical folders are much better, but then an alarm bell goes off. If this is a good way of doing it, why isn't it the Rails way of doing it?

Does anyone know if the Rails core team ever discussed using this directory layout? I know that it would take a fairly big rewrite of some glue logic in Rails that we all know and love, but merely 'hard to do' often does not stand in the way of 'the right way' in Rails.. right?

Can anyone point out something that immediately stands out as possibly problematic?

Re: Code Organization in Large AngularJS and JavaScript Applications

#22
post #21

I'm building a rails+angular app at the moment, and sort of fell by default in the component-type folders. Reading this blog makes me think that you're right and topical folders are much better, but then an alarm bell goes off. If this is a good way of doing it, why isn't it the Rails way of doing it? Does anyone know if the Rails core team ever discussed using this directory layout? I know that it would take a fairl…

I thought the same thing.

In my minds eye I don't see a nice place to stuff views. Module specific ones could live inside the module but Rails has layouts and also typically has shared views.

Sinatra would be a good framework to play around with this structure.

Re: Code Organization in Large AngularJS and JavaScript Applications

#23

A nice example of a slightly larger AngularJS app can be seen here: https://github.com/angular-app/angular-app

Say, that is a good example!

I find the general layout suggested for Angular apps to be a bit weird. There are prominent articles by Angular devs that suggest splitting things into services, models etc. I guess it just follows the familiar pattern that Rails etc give you.

I've recently built a couple of large(ish) python web apps. I use Flask for the web frontend but instead of starting with Flask I built all the libraries / core code first and then use Flask to tap into that. It makes for a much better application structure. Instead of thinking about how you should be splitting into blueprints you really think about the application structure as a whole (and you remove dependencies on the framework). I'm _much_ happier with the results.

I'm refactoring the Angular frontend at the moment so the example you've pointed to is a timely piece of code for me to skim. Thanks!

Re: Code Organization in Large AngularJS and JavaScript Applications

#24
This reminds me of the beginning of Bob Martin's keynote[0] at Ruby Midwest 2011[1]. I don't agree with everything he said, but the code organization point is sound.

[0] http://www.youtube.com/watch?v=WpkDN78P884&t=6m39s

[1] http://www.confreaks.com/events/rubymidwest2011

Post reply on HN