Showing posts with label Naming. Show all posts
Showing posts with label Naming. Show all posts

Tuesday, April 1, 2014

Introduced FormEmailService façade and struggling with names again

Following the advice given by One on a comment, I introduced a façade service that encapsulate everything about emails, FormEmailService with FormEmailComposer and EmailSender as collaborators. This simplified the creation of the IntroducedInformation class which was great.

I also followed his suggestion of passing the form object as a parameter to the sendByEmailAndRedirect method.

This was how it was used after that change:

Although the creation of the IntroducedInformation got simpler, I didn't like how it read anymore because an "information thing" was now sending a form.

In the previous version the "information thing" was sending itself using a "Yoda-like" language:

To keep the form as a parameter I decided to rename the class to so it was "something that does something on something" and not finding any better name I went down the road of "SomethingService" names:

Well, it's not perfect but at least I think it reads better than the version where the "information thing" was sending a form.

This is how the class looks now:

and these are its tests:
I keep thinking in a name for this that doesn't follow the "SomethingService" pattern, but until inspiration comes I'll settle on this one.

Thank you very much Carlos, Marcin and José for your feedback. I really appreciate it.

Monday, March 31, 2014

Finally some better naming but still with fragile tests

After sleeping on it I've found better names for the examples I've recently posted about (see preious post).

The obstacle was seeing it as an action on a form. Thinking instead on information that needs to be introduced and sent made the names flow much better.

This is the resulting class:
and these are its tests:


Finally, this is how it's used now:



I'm much happier with the naming now.

The tests are still fragile, but by using helpers in the tests the amount of places where the mocks are used gets reduced.