re: Stop coupling logic with your HTTP layer! VIEW POST

VIEW FULL DISCUSSION
 

Great article!

In my case, I find it very useful to have a second line of public methods.

Imagine something like reacting to an article. I'd have:

  • A basic react_to_article(user, article, reaction) that does exactly that, provided the user and article exist.
  • An http_react_to_article(auth_token, article, reaction) that takes care of token-based authentication before calling the first one.
  • A cli_react_to_article(ssh_key, article, reaction) that uses public SSH key as an authentication method.

My point is, some things are related to the communications protocol and some others are pure app behavior, and having the latter isolated allows you to:

  • Have an admin panel with a completely different approach to permissions (based on the role at the company for instance).
  • Have development tools that create features relying on a public API (that shouldn't change).

Those are my 2 cents on this.

code of conduct - report abuse