I'm in the process of designing a facade ApiClient class that would abstract some CRUD operations between a local database and a remote one (through a REST web app).

Said ApiClient class depends on 2 other implementation classes (let's call them local repo and remote repo, whose responsibilities are to interact with the local database driver and with an http client, respectively.

That being said, some resources (let's call it ResourceA) are to be saved locally after being retrieved from the network, but it cannot be saved TO the network. An example of this would be the retrieval of a list of ResourceA and save each item locally, but there is no creation of ResourceA nor update it to the server-side.

Up to this point, the local repo should implement a save(ResourceA) operation, but remote repo shouldn't.

So the question is: should those 2 classes be an implementation of 2 different interfaces (local repo interface and remote repo interface), or both of them should implement a single interface, but on save operation remote repo should throw an invalid operation exception?

1 Answer 1


It's unclear from the question if remote repo doesn't support add/update operations at all or only for specific types. In case of the first option, I would go with 2 interfaces: IReadonlyRepo, IWritableRepo. In case of the second option, I would go with the exception approach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.