johnlemon
johnlemon

Reputation: 21509

Good method name for 2 different actions

I have a method Send and a method Store. I need a wrapper for both but I can't find a good name for it.

What can you do in this situation to avoid calling the method SendAndStoreEmail ? Is there any trick for naming different actions like this in a facade class ?

Upvotes: 1

Views: 1144

Answers (2)

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 341003

I'd be happy with... Send()! Here's why:

MailService.Send() calls MailSender.Send() and MailStorage.Store(). MailService.Send() handles the process of sending e-mails. From implementation perspective this process consists of physically sending an e-mail and storing it. But from the user perspective of other developer using your code it just sends e-mails. Storing them is technical, irrelevant (?) detail.

Upvotes: 1

Roy Dictus
Roy Dictus

Reputation: 33149

It all depends on what information you want to expose to the outside world.

If you want to tell explicitly what your methods do, then by all means use explanatory names such as StoreAndSendEmail() (you'd want to store it first, then send it, so please respect the order of the actions in your names).

If you don't want/need to be as clear, you can use any naming convention you want, for example you may use a name such as ProcessMessage() if that fits your specific circumstances.

Or just call it SendItToBigBird() and see if you get reactions ;-)

Good luck!

Upvotes: 0

Related Questions