Refactoring Web Services

Hi everyone! I have a web service with multiple methods and I just want to ask if it is better to combine all the methods into one and put a parameter('action') to determine what controller to run.

What do you think is faster, maintainable and easy to extend?

Thank you!

Did you find this post useful? Show some love!

There is no silver bullet and it heavily depends on details.

I personally would go with several endpoints to have all the handlers clean and relatively tiny.

I would suggest to seperate them from start, it will help you in future as code base starts to grow. Try to think of SOLID Principles (en.wikipedia.org/wiki/SOLID_(objec...) when coding.

In my opinion, it is better to separate each methods according to its usage. It would be maintainable in the long run.

Ben Halpern DEV.TO FOUNDER

Hey there, we see you aren't signed in. (Yes you, the reader. This is a fake comment.)

Please consider creating an account on dev.to. It literally takes a few seconds and we'd appreciate the support so much. ❤️

Plus, no fake comments when you're signed in. 🙃

In addition Eldlabs' suggestion, don't forget 12 Factor App while writing web services.

Classic DEV Post from May 18

Go or Python and why?

So a friend of mine was considering either learning python òr go. What would be...

READ POST
Follow @albertdugba to see more of their posts in your feed.
Mervin
I'm a passionate web developer
More from @gentlemanoi
Refactoring If-else statement
#discuss #coding #learning
The Progressive JavaScript Framework
#javascript #beginners #webdev #programming
Trending on dev.to
So You Learned React, and Now You Work with jQuery...
#career #beginners #productivity
What are some good questions for a "State of the Web" survey?
#webdev #discuss
A beginners guide to finding a mentor
#programming #learning #selftaught #improvements
The Secret Life of Objects: Information Hiding
#programming #design #oop
Back to basics: Naming
#naming #javascript #programming #discuss
Write less code
#quote #programming #cleancode
Does anyone else feel bothered when people term us as coders instead of developers or programmers..?
#discuss
5 Reasons You Should Write That Blog Post
#career #beginners