at work we use this pattern for certain classes wh...
# getting-started
y
at work we use this pattern for certain classes where instead of having a single concrete class
Foo
, we moved all the method definitions into something like
interface FooInterface
. all the methods return
Unit
and have an empty default implementation defined in the interface. then we have a
FooFactory
which (depending on some external setting) returns either a
class Foo
with overrides for each method, or a
object DummyFoo
, which doesn't override (and so has empty implementations for all the methods). I understand what this pattern is trying to achieve, but is there an alternative? I really don't like it. especially as
interface FooInterface
keeps getting more and more methods, and becoming more and more specific.
v
it depends on what’s the end goal.. what is the purpose of those interfaces? at some point long time ago people would make an interface for every single class “just in case” it was ever needed. i always hated this approach as it doubles the number of classes/interfaces you have for no good reason