I feel, that MVVM and REST being considered together can produce a solid and reliable pattern for programming for many years. (My intuition says me that we SHOULD consider them together). Also it seems that it should be a proper abstraction for Asynchronous operations in ViewModels and Controllers - like a composable asynchronous data dependency graph (with support of transactions) - thing that operates at higher level of abstraction than c# 4.0 parallels (closer to busines logic).
Are there any investigations, or best practices on that?
MVVM + REST - ?
MVVM + AsyncModels - ?
REST + AsyncModels - ?
MVVM + REST + AsyncModels - ?
I'm afraid your question is a little vague to give a really clear answer, but I will give you my thoughts.
If you are talking about using MVVM on the desktop (or JS in the browser) and REST on the server then then I think this is a very viable approach, as long you consider the Model as the media-type that is returned from the Http request.
If you are talking about implementing RESTful endpoints using MVVM then I tend to prefer a straight MVC pattern.
I'm really not sure what you are asking with regards to AsyncModels. Are you inferring that the model asynchronously load their own data from REST endpoints? Are these "asyncmodels" a replacement for the M in MVVM or are they in addition.
It would be much easier to give you a valid answer if you could tell me on which physical tier you expect these various components to run.
I completely agree with you in that MVVM + Rest together are a perfect combination.
Maybe the problem for this to get more interest is that his natural target are Silverlight applications, and the framework they are promoting there is RIA Services.
I personally prefer to get data from a Rest server, and to have my MVVM Model objects correspond to Rest resources.
I don't know any investigations about this, but sure is an interesting topic. About the async operations i would suggest using couroutines, based in IEnumerable. I know 2 frameworks that use that:
1) caliburn
2) the Dream Rest framework, but (for what i know) is not silverlight.
Related
I have been reading about the articles on the web about the benefits of graphql but so far I have not been able to find a single benefit of it.
One of the most common benefits mentioned in those articles are below?
No Overfetching with GraphQL.
Reducing number of calls made from client side.
Data Load Control Granularity
Evolve your API without versions.
Those above all makes sense but it is not the graphql itself that provides these benefits. Any second layer api written in java/python or any other language would be able to provide this benefits too. It is basically introducing another layer of abstraction above the data retrieval systems, rest or whatever, and decoupling the client side from that layer. After you do that everything you can do with graphql can also be done with any other language too.
Anyone can implement a say scala server that retrieves the data from various api's integrates them, create objects internally and feeds the client with only the relevant part of the data with total control on the data. This api can be easily versioned and released accordingly. Considering the syntax of graphql and how cumbersome it is and difficulty of creating a good cache around it, I can't see why would you use it really.
So the overall question is there any benefits of graphql that is provided to the application because of the graphql itself and not because you implement another layer of abstraction between your applications and your api's?
Best practices known as REST existed earlier, too.
GraphQL is more standarized than REST, safer (no injections) and syntax gives great flexibility in the area of quickly changing client needs.
It's just a good standard of best practices.
I feel GrapgQL is another example of overengineering. I would say "Best standards and practices" are "Keeping It Simple."
Breaking down and object and building a custom one before sending it to the client is very basic.
I use Angular2 with django rest framework on back.
Is it a good practice to consider designing a rest API that meets exactly front implementation use cases. routes, which fields to include... ? This makes front project far more maintainable than interacting with a general API that gives all data access possibilities without caring about font needs (some overhead include: unused fields, double front models for UI + for API).
I am struggling with the concept SOA. Lets say there is a big project which contains a lot of specific business logic and resources. From what I've found SOAP and REST makes sense, SOAP for the business logic part and REST for the resources/CRUD part.
The idea that I have in mind is to use SOAP as a public entry-point and use the REST as an internal API for SOAP (because it should not have business logic), this way I can utilize the strength of both structures.
The problem here is that writing detail/overview requests will probably be in REST and SOAP services, which isn't good for maintenance.
Should mixing SOAP and REST be avoided or can they be used in the proper way of how I described it?
EDIT I will try to make a more specific case. I also came across a good article http://www.infoq.com/articles/tilkov-rest-doubts. Which will resolve a lot of problems with using business logic in REST, by renaming the models differently.
For example if you have an order with products and you have discount on it can be calculated after (creating) POSTing products to an /order URL for example. And the discount is visible after GETing the product on /order URL. This fits perfectly in REST.
However when for some reason you can't have product x and y in the same order, this seems a bit difficult to do in a REST service. Because you will have to give proper error message like 'x and y can't be in one order', this is exposing business logic and seems to fit better in SOAP. Is there a way to do this is REST and if so, is it better to do use REST in this case?
A broad question, perhaps too broad. Of course it depends on what you are building. If you provide some more details, platform, targeting what kind of devices, etc you will get a better answer.
However, consider building RESTful api's for everything, public + internal. I'd suggest checking out ServiceStack https://github.com/ServiceStack/ServiceStack/wiki/Why-Servicestack docs which discuss an approach for api's. Even if you don't use their toolset, the concepts will help you build your own web api's.
I'm writing an AngularJS application that's communicating with an API, and right now that API is following the REST architecture.
I know the basics of REST, but I've still not understood if REST only covers the CRUD operations? For example, if I'm building a community website and I want to make it possible for people to add each other as friends, is this covered by REST in any way? What about search queries? If not, is there any other architecture that's recommended to follow, or should I roll my own?
Also, should I even be using REST for a community website? There are a lot of cases where it seems like it's not the optimal design, but when I google around I only get results saying that REST is the best practice. For example PUT /api/user/:id wouldn't be very useful, since the only user you're able to update (unless you're an admin) is yourself.
It all depends, REST is just an architectural style and (in many forms unfortunately) is used all over the world. I also follow REST rules in all type of applications but try to stay at the second level of Richardson's Maturity Model. Why? Since I consider HAL, HATEOAS and all the API discoverability as an unnecessary buzz - unfortunately documentation is still very important.
What you need to consider while designing an API is if it's going to public or not. If it's not, you can probably whatever you want/need (of course this is not good idea). If it is going to be public the consistency starts to play a great role - API needs to be designed in such a way that it will be both intuitive and easy to use. E.g. this is not good idea to introduce new endpoint every time you need a new operation - thus following CRUD REST rules seems to be reasonable option. When it comes to to going beyond CRUD - yes, I've created APIs with verbs in endpoints - but it was almost always the last resort and to be honest I don't feel guilty.
I think the question is a bit too broad, but I'll try to answer.
REST only covers the CRUD operations?
No, it covers other operations as well. You have to transform your operation into a HTTP method and a resource. The resource can have identifiers: URIs. An URI with a HTTP method compose a hyperlink. This hyperlink can be followed by the client. You can attach the operation name, etc... to the hyperlink as meta-data, so it can be used by the client to recognize the operation. At least that's how it should work.
What about search queries?
General queries are not supported currently, because there is no standard RDF vocab which could be used to describe a general query. There are non-standard workaround, you can use them or for example a SPARQL endpoint. More fixed queries can be used with URI templates.
Also, should I even be using REST for a community website?
As far as I know facebook uses it for 3rd party clients, so you can develop a facebook application using their REST API. Another advantage that it scales better than SOAP. If you don't need these features currently, then you can use something else you are more familiar with.
I am working in a RESTful application and when I was reading about REST, I found that REST is an Architectural Style and not an Architecture but I do not understand the reason. Thanks for your answer.
Sorry for my English, it is not my native language.
An architecture is prescriptive, often giving blueprints for solutions, and defining the core building blocks. For instance, "client-server" architecture defines a client, a server, and the roles those two components play.
An architectural style provides a framework for thinking about solutions - in the case of REST, the concept of resources addressable through a URL, a vocabulary for manipulating those resources, statelessness etc.
This is important, because the question "is this a client server architecture" can easily be answered - is there a client, does it connect to the server, are there clear responsibilities for each? The question "is this a RESTful solution" is much harder to answer - it requires you to see if the solution follows the mental model of REST.
REST provides guidelines for designing distributed systems, mainly "hypermedia" systems. This is based on the work of Roy Fielding. To make it clear between the "architectural style" and "architecture" you can think of the "architecture style" as a set of principles to design "concrete architectures" (or concrete implementations). In the case of REST, you can see for example that several concrete implementations were defined, for example java has developed its own implementation of the REST architectural style: JAX-RS (https://jax-rs-spec.java.net/ , https://jax-rs-spec.java.net/nonav/2.0/apidocs/index.html).
Hmm, I don't know exaxtly, but I think, it because REST describes only, that should be resources, represented by unique URLs, and actions for them, represented by HTTP-verbs and request data.
But data format, are resources objects or not - decision of developer.
Maybe, even HTTP is not necessary.
I don't know why REST is called an "architectural style". For me, REST is just a protocol for doing synchronous calls (in most cases). In the programs, you still have action based methods (like getAccount, transferAmount, createUser etc.) All these methods can be implemented using REST. Or SOAP. Or some other protocol. And all of them assume some data model.
So, in my view, REST is neither architectural style nor an architecture.