This sort of code makes me very angy!

Tell me what’s wrong with this simple piece of code:

public class MyService : IMyService, IDisposable 
{
    private readonly IOtherService _otherService;
    public MyService(IOtherService otherService)
    {
        _otherService = otherService;
    }

    public void Dispose()
    {
       _otherService.Dispose();
    }
}

The answer is very simple: “I created you and I will be your end”, yet MyService didn’t create IOtherService, thus it has not right to call Dispose() on the service.”

Yet, at Mizuho, I saw many developers lacking this simple, yet critical design concept!

</rant>

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Up ↑

%d bloggers like this: