Javascript Frameworks with Rails [closed] - ruby-on-rails-3

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Hoping someone can help clear things up for me.
I've been reading a ton about the new javascript app frameworks out there, backbone.js, batman.js, ember.js etc...
And I see a lot of instances of them using the frameworks on top of Rails.
Can someone explain to me. Doesn't this require a ton of duplication in order to use them? ie. do I need to completely duplicate each model and controller? And if so, do I need to make changes to both each time?
I see a great benefit for rendering templates on the browser, but I feel like I'm missing something important when it comes to using these on top of an already well organized MVC structure.
What is the benefit and is there really as much duplication as it seems?
I've read the question here
But it doesn't seem to address the duplication.
Thanks in advance.

The benefits are described in the question you linked to. They provide structure which is hard to achieve when you're client side does more than simply displaying data and reloading parts of the view with AJAX.
Andrew Dupont gave a presentation at MIX 11 about writing maintainable JavaScript. He describes his journey from a stinking pile of JS to a more maintainable code base. It is worth watching.
The duplication depends on how much you do on the server side. If your server is only serving data, e.g. Rails controllers providing a JSON API to access the models, you have to duplicate the models on the client side.
I am using Rails only for JSON access to persist the entities of my application, except some JSON views. The whole user interaction and CRUD happens on the client with Backbone & jQuery.
So far, I had only to duplicate the models in Javascript and create some controllers for accessing and saving the models on the server.

Related

Documentation on how to use REST WebAPI like a boss [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I've exposed a few methods and, while crystal clear on how they're supposed to be used, I'm sure that with time, the memory will fade and I'll be standing there like an idiot wonder why on Earth I haven't provided any help.
When we use WCF, there's the WSDL file. But I'm not aware of any corresponding functionality for WebAPI. Usually I add a Ping so that I can type in the URL window of my browser .../Service.svc/Ping, just to see that I a date back.
What would be an intuitive and (hopefully fairly) canonical approach? I'm thinking .../Help. Is there a better way?
Just pushing out help will only produce a huge string (XML or JSON formatted), which isn't very like-a-boss'y. Anonymous types can't be well handled without serialization. pushing out object typed entity breaks the connection.
I wish to have a built-in documentation on how to use the calls. The names themselves, of course, but also what values are treated (I had a case where the .../Donkey?scope={scope} pattern could be null or all and we though it was any, which took a while to figure out.)
You might checkout Swashbuckle which would allow you to generate Swagger documentation for your ASP.NET Web API controllers.
Anonymous types can't be well handled without serialization. pushing
out object typed entity breaks the connection
Are you really exposing anything like the above mentioned in your Web API contracts. I hope you don't.

Is Model serializers faster than Rabl? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am building a rails 3.2.14 web app and API. I want the API part to respond even faster than it does.
My question is this:
I am currently using Rabl gem. Is it better (performance wise) to use Model serializers?
Is there something I can do to speed up requests (perhaps with middleware)?
How can I measure the performance of my API? Is there a tool or a service for that?
Thankful for all input!
Regarding 1) and 2)
Personal preference and prior experience favors RABL. It helps segment JSON views from my code logic. You can get a lot of reuse with partials and other logic within RABL template and this is why I favor it over serlializers. You can take full advantage of Rails.cache in either, and again for me, RABL makes this easier to manage in complex caching approaches ( like russian-doll ).
This is a good write up on caching with serlializers ( http://robots.thoughtbot.com/fast-json-apis-in-rails-with-key-based-caches-and).
Take a further look at ( https://github.com/nesquena/rabl/wiki/Caching-in-RABL ) for caching techniques. I've greatly increased performance on heavy APIs by simply using caching.
For Item 3). I use NewRelic specifically for API performance improvements. You can load test an API, and review the performance to a great lelve of detail in their Dashboard.

"Reverse Engineering" App Architecture [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I inherited an old app, written in C#/.NET 2.0. (un)Luckily there was no documentation - not even comments. So as I'm adding enhancements to the application based on new requirements I'm also building a mental model of what the app does and how it does it - architecture in other words.
I was wondering what tools exist out there to "deconstruct" the app and go from raw code to something higher level? The app's not really heavy in OO - in fact one of the objects used is called a "function". It's mostly just a bunch of methods - a lot methods that seem to jump out of nowhere.
I want to translate the raw code to some sort of requirements doc stating what the app does and how it executes. What's the best way to do it? Are there any apps out there that can help me? Maybe templates of what I should/should not include? Maybe books/sites that you recommend? The goal is to provide documentation for me and for future developers maintaining the app.
Personally, I would start with Robert C Martin's Agile book, and Eric Evan's book on Domain Driven Design. Those are theory books, but Uncle Bob's book specifically talks about revamping code to be manageable, just like your situation.
It's pretty essential to layer your software so you can start to remove dependencies, which will make everything very simple and easy to maintain.
I am a database guy, so I started with a good ORM like Entity Framework or Fluent NHibernate. I prefer websites, so I went with ASP.NET's MVC 2, then started writing all the parts of those books, namely a data Repository, Services to pull data and Control to push it. MVC is a very nice separation of data concerns and "View" concerns which are your screens. Before long, you would have very clean and easily maintained software.
If you are using VS 2010, you can see a menu with the name: Architecture. Using this tool, you can create a dependency graph of your application, you can use it as described in the following:
Link

What's the best way to generate a REST API's documentation? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I'm looking for a nice way to generate documentation for a REST API. It doesn't need to actually connect with the code or anything, but it'd be awesome to be able to write the documentation as text files, point the tool at it, and generate some docs from it.
Anyone out there have any ideas? I know I'm being a bit vague, but, to be honest, I'm not quite sure what I'm looking for here--mainly an easy way to manage documentation.
According to Roy:
"A REST API should spend almost all of its descriptive
effort in defining the media type(s) used for representing
resources and driving application state, or in defining
extended relation names and/or hypertext-enabled mark-up
for existing standard media types."
Self-descriptiveness is one of the benefits of REST.
While not REST, I used Sphinx to document an XML-RPC API that consisted of an API reference and a tutorial. Sphinx adds some handy directives to ReStructuredText to get pretty much what you asked for: a collection of ReStructuredText formatted-text files that Sphinx turns into HTML and PDFs, complete with an index and table of contents. Sphinx is easy to use and well-documented; I don't think it would be an exaggeration to say you could get started with it in about ten minutes.
Some RESTful systems are actually able to write their own API. Have a look at RESTx, which does just that: You write your components and then create new web services by sending parameters for those components to the server (either as JSON or via a web form). You then get a URI back for those parameters. Accessing it calls the component with the parameters and you retrieve the results.
At any rate, the components as well as the created RESTful web services get an automatically generated documentation, which is browseable and can be retrieved either in HTML or JSON format.

What documentation is helpful when supporting an application? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I am going to be taking over from a developer here at work soon. Hence, I'll be supporting all the applications that he has written over the last few years.
My question is, when supporting an application that you probably don't know much about, what kind of documentation is most helpful to get a handle on how to fix problems, extend functionality, modify functionality, etc? I'm thinking it would need to give you an overview of what the software does, what interfaces it has to other software, what databases it uses, usernames, passwords, and so on.
Is there such a thing as a software support document? Referrals to any templates would be most helpful.
BTW, unfortunately, there are no requirements documents, specs, etc! So, really my question is, if my colleague had a day to write a single document for each application so that I could (more easily) support it, what would that document be and/or what would it look like?
I would ask for primarily some sort of flow chart/schema of the way the app functions.
I would want to be able to know how each file interacts with other files (and the database). So this way, you'd know where to start to fix a bug or add a new feature, etc.
So to do a quick, text mockup of it:
Index.php -> Login.php -> Dashboard.php
Index.php:
Has login box. Submits login into to login.php
Login.php:
Verifies data with database entries, shows error on fail or sends to Dashboard.php
Dashboard.php:
Once logged in this acts as a main menu
Something along these lines? For basic documentation I'd think this is the way to go.
Hope this helps. Good luck!