Question: When I work with my local version of project then every action taken on website needs around 10 seconds long response. It's so frustraiting. And it hapens only on my PC. How can I prevent this action?? Downloading project from VCS to new folder helps for short time. I have Windows 10, Laravel 5.4, PHP 7.0.15. Commands 
 `php artisan cache:clear`
and 
 `php artisan optimize` 
are not helping. Please, can anyone help?

Answer: 
Note that the duplication exists because you do the same things *twice*, just on different objects.

To fix that, create a new method which does those things only *once*:

```
private static void ShowHideEmailContents(?? hl, ?? txt, string email, string format, string tooltip, bool isReadOnly)
{
    if (isReadOnly)
    {
        hl.NavigateUrl = string.Format(format, email);
        hl.Text = email;
        ...
    }
    else
    {
        txt.Text = email;
    }
}

```

and *call it twice*:

```
private void ShowHideEmailContents(string email, string email2, string format, string tooltip, bool isReadOnly)
{
    ShowHideEmailContents(hlEmail, txtEmail, email, format, tooltip, isReadOnly);
    ShowHideEmailContents(hlEmail2, txtEmail2, email2, format, tooltip, isReadOnly);
}

```
You can minimise the number of parameters that you pass by encapsulating the logic to set the email object's properties in a class:

```
public sealed class EmailOptionsSetter
{
    readonly string _tooltip;
    readonly string _format;
    readonly bool   _isReadOnly;

    public EmailOptionsSetter(string tooltip, string format, bool isReadOnly)
    {
        _tooltip    = tooltip;
        _format     = format;
        _isReadOnly = isReadOnly;
    }

    public void SetOptions(YourEmailType emailObj, string email)
    {
        emailObj.NavigateUrl = string.Format(_format, email);
        emailObj.Text        = email;
        emailObj.ToolTip     = _tooltip;
        emailObj.Visible     = _isReadOnly;
    }
}

```

Then you can call it like this:

```
    private void ShowHideEmailContents(string email, string email2, string format, string tooltip, bool isReadOnly)
    {
        if (isReadOnly)
        {
            var optionsSetter = new EmailOptionsSetter(tooltip, format, isReadOnly);
            optionsSetter.SetOptions(hlEmail, email);
            optionsSetter.SetOptions(hlEmail2, email2);

            txtEmail.Visible  = !isReadOnly;
            txtEmail2.Visible = !isReadOnly;            
        }
        else
        {
            txtEmail.Text  = email;
            txtEmail2.Text = email2;
        }
    }

```