Results 1 to 4 of 4

Thread: Setter in Interfaces yes or no?

  1. #1
    Join Date
    Aug 2007
    Posts
    12

    Default Setter in Interfaces yes or no?

    hello folks,

    i have a interface-design-question ...

    i have a document-service-interface:

    public interface DocumentProvider {

    FileContent getDocumentContent(Document aDocument);
    ...
    void setDocumentHandlerRegistry(DocumentHandlerRegistry aRegistry);
    }

    Q: is it correct to insert the setter for the injected "service-bean" into the document-service-interface?

    the document-service should use the document-handler-registry to "find" a document-handler
    for the requested "document-type" (getDocumentContent) ... there are many different document-types and so
    many differtn document-handlers.

    Q: is registry a good name? document-handler-service could be a better name?!

    Q: how should i initialize such a registry with spring ... i guess the xml should look a little bit complex at the end?!

    any help will be welcome

    regards
    andreas
    Last edited by ahoehma; Aug 21st, 2007 at 11:07 AM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    I think that a Service interface must only contain the the service methods. It can be quite well possible that 2 different implementations of those interfaces need different 'helper' methods. For instance one can need the setDocumentHandlerRegistry the other could simply look it up or create it's own.

    Naming it depends on what it should do and what the conventions in your team are.

    Initializing those service it can be as complex or not as you decide it to be. Especially with the new namespace support a lot can be done to cut down the size and complexity of configuration.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    I would agree with Marten's comments. The collaborators of the service are an implementation detail so you don't really clutter the interface with it.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  4. #4
    Join Date
    Jul 2006
    Location
    Kolkata, India
    Posts
    217

    Default

    Quote Originally Posted by ahoehma View Post
    Q: is it correct to insert the setter for the injected "service-bean" into the document-service-interface?
    +1 with Marten - the setter is always part of the implementation.

    Quote Originally Posted by ahoehma View Post
    Q: is registry a good name? document-handler-service could be a better name?!
    Follow the domain terminology, what the domain users call it, aka The Ubiquitous Language ..

    Cheers.
    - Debasish

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •