loading...

Refactoring Web Services

github logo ・1 min read

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!

twitter logo DISCUSS (4)
markdown guide
 

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.

 

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

Classic DEV Post from May 10 '19

Why I ignore the hype (and you should too)

It’s been 20 years since I made my first website. I've been burned by the hype ti...

Mervin profile image
I'm a passionate web and mobile developer

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️