For example, say I have a service that kicks off some operation, such as running a cron-job. Then, it returns whether it not it was successful.
The code might look something like
var service = new MetricSyncWakeJob(...);
var jobStarted = service.performSyncJob();
if(jobStarted) {
notificationService.notifySuccess("Operation was successful.");
} else {
notificationService.notifySuccess("Operation was NOT a success.");
}
Is it ever worth wrapping up such code or this something akin to eager-abstraction? If so, how would you do this this? What a Facade
work here?
i.e: UserInteractiveMetricSyncWakeJob
which can kick off the job and fire the message automatically?
It's not the job of the service to kick off this message -- otherwise, it could just be put there. I guess the class could look like this...
class UserInteractiveMetricSyncWakeJob
UserInteractiveMetricSyncWakeJob(INotificationService notifcationService, MetricSyncWakeJob wakeJob)
It seems overkill to do this -- yet, copy & pasting the same "handle this response" code seems bad, too.