1

I want my program to:

  1. read some input lines from CSV file
  2. write the output lines to plain string file
  3. read some input from the same file in (2) and compare it to some calculated data

I want to consider these abstraction levels:

  • create Dal interface with CRUD operations
  • implement Dal<T1>, Dal<T2>, Dal<T3>
  • create FileHandler interface with read and save operations
  • implement CsvFileHandler, StringFileHandler

And then:

  • Dal<T1> will implement read with a member of CsvFileHandler
  • Dal<T2> will implement read and write with a member of StringFileHandler
  • Dal<T3> will implement write with a member of StringFileHandler

Is it OK that Dal<T1> and Dal<T3> really implement Dal only partially (not all CRUD). Or should I choose other abstractions?

I'm using guice DI and I need to differentiate Dal<T1> and Dal<T2> even though they both read / write type String. So I created a dummy different classes for T1, T2.

Do you think I use too much abstraction? Are FileHandler and Dal overlapping?

Any other way to differentiate Guice injection rather than create dummyTypes?

1

If you follow the Liskov Substitution Principle you should not have implementations which do not fully implement an interface.

I rather have two or three different interfaces which state exactly what they can. Maybe a class will at the end implement more than one interface...

The other benefit you gain is that when you have specific interfaces they do not need to be further qualified in order for Guice to know which instance you need. If you still have more than one implementation of an interface you can use annotation to qualify them. See Binding Annotations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.