YFeizi
YFeizi

Reputation: 1528

Design pattern for network connections and requests

Im developing an app that have alot of web requests. Such as download or upload files , REST requests and etc.
I want to save all of this functions in a class like a helper and only just import the class and call functions that i need them in my activities. something like a custom library for web requests i mean.
Is there any Design pattern for this? (I hope i explain my idea well)

Upvotes: 0

Views: 1215

Answers (2)

localhost
localhost

Reputation: 5598

Consider using these libraries:

You can use custom IntentService class to hanle all networking there, starting this service from UI and passing apropriate ACTION to perform.

And of course i would suggest you watch this video from Google I/O 2010 and use REST Pattern A described there in EVERY network app you make.

Upvotes: 2

Alexandru C.
Alexandru C.

Reputation: 3395

You could use the Chain of Responsibility pattern for building up requests and then executing them. See some details here.

Of course, using just this one pattern would not be enough. It should be used in conjunction with an Observer, Factory, Proxy and maybe some others. Just start developing with SOLID in mind.

Upvotes: 1

Related Questions