Would creating a method "template" (by passing some method to the template method) be considered bad design?
<p>I had a difficult time determining a good title, so feel free to change it if necessary. I wasn't really sure how to describe what I'm trying to achieve and the word "template" came to mind (obviously I'm not trying to use C++ templates).</p>

<p>If I have a class that performs some action in every method, let's pretending doing a try/catch and some other stuff:</p>

<pre><code>public class SomeService
{
    public bool Create(Entity entity)
    {
        try
        {
            this.repository.Add(entity);
            this.repository.Save();
            return true;
        }
        catch (Exception e)
        {
            return false;
        }
    }
}
</code></pre>

<p>Then I add another method:</p>

<pre><code>public bool Delete(Entity entity)
{
    try
    {
        this.repository.Remove(entity);
        this.repository.Save();
        return true;
    }
    catch (Exception e)
    {
        return false;
    }
}
</code></pre>

<p>There's obviously a pattern in the methods here: try/catch with the return values. So I was thinking that since all methods on the service need to implement this pattern of working, could I refactor it into something like this instead:</p>

<pre><code>public class SomeService
{
    public bool Delete(Entity entity)
    {
        return this.ServiceRequest(() =&gt;
        {
            this.repository.Remove(entity);
            this.repository.Save();
        });
    }

    public bool Create(Entity entity)
    {
        return this.ServiceRequest(() =&gt;
        {
            this.repository.Add(entity);
            this.repository.Save();
        });
    }

    protected bool ServiceRequest(Action action)
    {
        try
        {
            action();
            return true;
        }
        catch (Exception e)
        {
            return false;
        }
    }
}
</code></pre>

<p>This way all methods follow the same "template" for execution. Is this a bad design? Remember, the try/catch isn't all that could happen for each method. Think of adding validation, there would be the need to say <code>if(!this.Validate(entity))...</code> in each method.</p>

<p>Is this too difficult to maintain/ugly/bad design? </p>
