Hacker News new | past | comments | ask | show | jobs | submit login

I have thought at times that allowing the definition of constructors in interfaces would go a long way towards solving this problem. It's much easier to manage dependencies with cleaner patterns when you don't have to define some ugly Configure(MyConfiguration) method and throw exceptions if it hasn't been called before you do anything else.

In their example an interface doesn't really help since CreditCard is probably a value object, which don't generally provide implementation variations, however you see the problem in the Database and OfflineQueue types, whose lack of an interface is going to add complexity to the test (CreditCardProcessor takes an OfflineQueue but imagine OfflineQueue requires implementors to configure a queue address at runtime, taking IQueue instead would allow you to pass in a mocked IQueue).




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: