views:

346

answers:

1

Hi there,

I am using a standard repository pattern with a service layer which calls the data layer..

I have some Utility classes i.e. one that deals with Sending email (method name = SendMail)

Where is the correct place to put this?

Inside the service layer as a method called SendMail

hence I have CustomerService which calls CustomerRepository

So in this case i create a new UtilityService which will hold all the business logic for utility classes i.e. Sendmail

Little bit confused where i should put these

Any help really appreciated

A: 

You can think of your sevice layer as having two levels first is a coordination / aggregation layer that calls the second layer which is the individual services, this will include the utility service.

In some cases this can be overkill since you get a lot of pass-through services.

Shiraz Bhaiji
thank you very much fro your reply, so are you saying that i should then setup a new class in my Service called UtilityService (similar to my customerService etc) which can hold my Sendmail and things like that..Hence from my CustomerService i can call to my repository and "ALSO" call my UtilityService from my CustomerService if i require SendMail?Naming conventions: I presume UtilityService is a good standard or should i even be more specific and call this EmailService Maybe getting to deep there?
mark smith
Yes, the customer service will call the Email service and the repository. You could call it EmailHelper to differenciate it from a service.
Shiraz Bhaiji
And to add to the above if you wrap the call to the repository + emailer in an TransactionScope if either of them fail then the whole process is roled back, not leaving the anyhting in an invalid state...
AWC
thanks fro your comments,
mark smith