Your constructor smells

A code like the following looks as a “code smell” definitely:

public ProductProvider(
    IProductDataProvider dataProvider = null,
    IProductDecorator decorator = null,
    IProductSearchCriteriaParser parser = null,
    IProductInventoryDataProvider inventoryProvider = null,
    IProductSessionDataProvider sessionProvider = null,
    IContentProvider contentProvider = null,
    IProductQueueProvider queueProvider = null)
{
}

But unfortunately nothing I can do. What can I say? Alas!

This entry was posted in Programming and tagged . Bookmark the permalink.

One Response to Your constructor smells

  1. abatishchev says:

    Actually, it’s more ok rather than a code smell. From what I know 2 years later, parameters shouldn’t be optional because iirc it was done only to simplify unit testing. That’s it, everything else looks like a proper dependency injection via constructor.

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s