7
gitpush
7y

rant == false && help == true
I usually don't like posting non rant stuff here but I need help.
How do you usually design your service communication class?

I am working on a mobile app which contains talking to a REST service, I usually put all network calls in one class. Down side if it becomes a big class it becomes a pain to maintain. Any thoughts?

For a backend service I usually go with Repository design and it is working out well for me. But for mobile Apps I'd like to see if there is a better approach

Comments
  • 2
    Just a suggestion, but maybe make a framework out of it. (Framework as in iOS frameworks. Haven't worked with Android, yet). Or maybe a NetworkManager superclass with lots of APIManager subclasses, divided by category, that contain functions that make the calls. (The NetworkManager is there just so you don't have to write the logic to actually make the request and parse the data).
  • 2
    Never mind me, already got my answer here: https://developer.android.com/topic...

    Thanks for your help @notSoSerious :)
  • 2
    @gitpush I would combine both those functionalities in the same class and name it "NetworkInterface" or something just so that the classes don't look too small 😝. But each of us have different preferences. So long as it works, and you think future you will be able to understand it, you're good👍.
  • 2
    @notSoSerious I hope future me understands present me lol it is for a side project, lets hope for the best :D
Add Comment