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

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

You are commenting using your 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.