Joe
Joe

Reputation: 83

Method required by Interface not always meaningful

From a C# class, I have access to a set of WCF web services that talk to a mainframe via Verastream Host Integrator. It is basically fancy screen scraping. The web services are all about either retrieving or updating data - no business logic - and so my thought is to build a data (transform?) layer using a repository pattern.

All that being said, my repository classes all implement an IRepository interface that requires a Retrieve() and an Update(). For the tiny percentage of repository classes that face a service with a retrieve, but no update, what do I do as a best practice? Do I just leave the Update method throwing a NotImplementedException(), and if so, how do I communicate to anyone who uses my class that Update() is not broken, but not to be used.

Upvotes: 0

Views: 38

Answers (1)

Matías Fidemraizer
Matías Fidemraizer

Reputation: 64943

Do I just leave the Update method throwing a NotImplementedException()

Use NotSupportedException instead.

how do I communicate to anyone who uses my class that Update() is not broken, but not to be used

There's something called documentation!

In addition, NotSupportedException is a good indication of that Update isn't supported for some given service implementation. It's not broken but not supported.

Upvotes: 2

Related Questions