I am developing a RESTful API in my project, but I do not have experience on that. To fill these gaps I've been watching some videos, mainly from Apigee, which are great.
One situation brings a lot of discussion on my project and I hope you can help me clear it out. The client using the API is able to create a user by posting to my /Users url, but it has some requirements as: name format, username availability, email availability, valid region and many others.
I can easily validate the name format in my client app, that would be easy. The problem is when it comes to availability (mainly if the email and the user name are available to be user or are already taken).
We have two different lines of thoughts on my team:
the first one would break each verification in a different url, something like
/Users/EmailAvailable and /Users/UsernameAvailable
ou
/Available/Email and /Available/Username
They claim that it would make the interface cleaner (more intuitive) and would also keep cohesion, since one method has only one responsibility.
The second line of thought is to have only one URL
/User/Verify
and it will verify either the username, email or both, depending on the JSON it receives. They claim that it would only require one trip to the server and that cohesion is not a problem because, since the URLs are not necessarily mapped to methods, they can divide the calls into methods that do one thing each.
They also claim that the interface shouldn't care about cohesion
My questions:
1- Are these arguments about cohesion from the second line of though valid?
2- How would you do? (Either one of those or any other that you know of)
thanks!
Best Answer