YaleSTC / reservations

Manage equipment loans & reservations. Who can borrow what, for how long?
yalestc.github.io/reservations
MIT License
139 stars 58 forks source link

Rewrite front-end in JS framework (and back-end as API) #1061

Open mnquintana opened 9 years ago

mnquintana commented 9 years ago

Although this is likely a long ways off, we should seriously refactor the entire front-end with Ember, and rewrite the Rails-side of things to be a back-end API. I think we're hitting a point with Reservations where we have Ajaxed a lot of individual pieces of the UX, but it's slowly becoming nightmarish to maintain. Rails + jQuery are not good at managing complex front-end UI interactions that don't require a new page request.

For instance, I'm pretty confident that #718 would be significantly easier to implement if we were using a JS front-end framework. We chose to refresh the entire catalog when making a change 2 years ago because it was a lot easier than trying to figure out exactly what component(s) changed and only updating that/them.

(Why not Angular? Ehhhh wellll, I have a lot of feelings about Angular. We could always talk about it some other time.)

orenyk commented 9 years ago

So do you think that it's worth punting on #718 until this happens? It's not the biggest deal, but it is pretty confusing for patrons.

mnquintana commented 9 years ago

Uhhh probably not worth waiting for this, I was just using it as an example of something that would be easier if we'd had Ember this whole time.

orenyk commented 9 years ago

Ha, fair enough. I'm sure there are lots of examples :)

squidgetx commented 9 years ago

ya i was actually thinking about this myself earlier, I would even consider this a pre-export task depending on what our standards are for pre-export I guess. But seriously rails API + js frontend (I second the motion against angular, though we should consider all our options ie React, backbone, etc.) is really the way to go for future maintainability.

Also we can start right away on converting the back end to an API just adding in the necessary respond_to blocks to return the proper JSON.

If the project had more manpower I would set this actually to the next highest priority after the most pressing bugs mostly because doing this would resolve/render irrelevant like half the currently open issues and make future maintenance a lot smoother. Of course the problem is that we don't really have enough competent rails AND js devs to make it happen on a doable time scale :(

mnquintana commented 9 years ago

I have been learning a lot about various JS frameworks for work, so it's possible I'd be able to get this going over break (I think I'm being waaaay too optimistic about break haha).

@squidgetx I'm still evaluating a lot of JS frameworks for work, but I suspect that React and Backbone are not quite what we're looking for. React is super interesting, but it isn't a full front-end framework the way Ember is - they even bill themselves as just the "View" in MVC (although I know people have built things around it that basically make it the full MVC). It's totally possible that we could use React with Ember / Backbone, although that would probably be overkill. Also, FWIW, Ember is planning on stealing React's best ideas anyway. As for Backbone, I think it's a bit too bare bones, and I think we could easily end up with a similar mess, just without the Rails ERB crap. But this is all still very WIP.

orenyk commented 9 years ago

This sounds like it would be amazing, but "Pre-Export" is set up to package up the current code base for use outside of Yale and such that it's minimally prepared for outside development. I would consider this a major feature (e.g. v4.3.0) but it would be amazing to get it out. I'm still recovering from Hackathonukah but will be reviewing all of this stuff over the next week.

mnquintana commented 9 years ago

I'm realizing now that this would totally break a good portion of our test suite, so we'd need to rewrite a ton of tests.

orenyk commented 9 years ago

Ha, that's a good point. Especially since our integration tests (see #416 and others) all lack JS functionality :-P.

squidgetx commented 9 years ago

Well it would break a large portion of our test suite since it would probably change a lot of how the application works. Half of our controller code is hacks to accommodate a too-complex frontend (I'm looking at you, reservation#checkout and #checkin).

squidgetx commented 9 years ago

Another thing that this would enable is real separation between backend and frontend tasks that would be seriously amazing. It would be a lot easier to imagine what steps would need to be taken to implement a feature and I think that a lot of the murkiness ends up in controller bloat code, since without an API/client structure the controller is the glue between backend/frontend. For instance #516 would simply be reduced to 2 tasks; backend: create one method that takes the cart and outputs a JSON array of associated EMs. frontend: figure out where to call this method and how to display its contents. Honestly think this should be next priority after 4.3.0, though idk how much we will actually be working on the project after that.

mnquintana commented 9 years ago

@squidgetx Totally agree

orenyk commented 9 years ago

Yea, a complete re-architecting of the app would be quite nice :-). We'll see how the semester progresses, maybe we can try to fit this in in our 'free' time :-P.

mnquintana commented 8 years ago

@squidgetx @orenyk Having worked with React now, I've totally changed my mind – I think React is the way to go whenever this re-architecting happens.

orenyk commented 8 years ago

@mnquintana thanks for the update! Do you mind briefly outlining what made you change your mind and things we should look out for if/when this happens?

mnquintana commented 8 years ago

Sure! :smile:

And more stuff I didn't mention in this article: https://blog.formidable.com/using-react-is-a-business-decision-not-a-technology-choice-63c4641c5f7#.nfjhlmq0a

The downsides?