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.

1 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 to abatishchev Cancel reply

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