I know I'm a bit late to this thread, but I figured I'd chime in anyway.

Why are the hints dissociated from the classes that use them? Any why have we bastardized the AWT class RenderingHints with things that have nothing to do with rendering? Also, forcing implementers to reference some other class that contains final static attributes that might or might not be relevant just feels mean.

Since in this case we are demanding that users of Foo have a FilterFactory, but some users just don't care, I would implement it as follows:
class Foo {
  FilterFactory filterFactory;

  Foo( FilterFactory input ) {
filterFactory = (input == null) ? FilterFactoryFinder.findFilterFactory(null) : input;
 }
}

class FilterFactoryFinder {

 //  public static final attributes...

 static public FilterFactory findFilterFactory(Collection hints){

   FilterFactory result = null;

   if((hints != null){

     // Iterate through hints and populate result if possible

   }

   if(result == null){

     // assign default

   }

   return result;

 }

}


This way the user has access to whatever they need to do their job, but nothing more. It also prevents the inevitable NullPointerException caused by the exceptionally lazy user.


[EMAIL PROTECTED] wrote:

Date: Thu, 12 Oct 2006 14:49:33 -0400
From: Martin Desruisseaux <[EMAIL PROTECTED]>
Subject: Re: [Geotools-devel] Factories: a proposal
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Justin Deoliveira a ?crit :
So I think code that does this:

class Foo {
  FilterFactory filterFactory;

  Foo() {
    filterFactory = FilterFactoryFinder.findFilterFactory();
  }
}

should do this.

class Foo {
  FilterFactory filterFactory;

  Foo( FilterFactory filterFactory ) {
    this.filterFactory = filterFactory;
  }
}

The alternative that I was talking about (as used in modules that uses correctly the hints) is:

class Foo {
   FilterFactory filterFactory;

   Foo(Hints hints) {
     filterFactory = FilterFactoryFinder.findFilterFactory(hints);
   }
}

which leads to exactly the same result, with more flexibility (null hints for default, LENIENT_DATUM_SHIFT, FORCE_LONGITUDE_FIRST_AXIS_ORDER, etc). However one approach doesn't exclude the other. Both can live in parallel; Hints can actually be considered as an other flavor of constructor injection. More complete example:

class Foo {
   FilterFactory filterFactory;

   Foo() {
     this((Hints) null);
   }

   Foo(Hints hints) {
     this(FilterFactoryFinder.findFilterFactory(hints));
   }

   Foo(FilterFactory filterFactory) {
     this.filterFactory = filterFactory;
   }
}

        Martin

begin:vcard
fn:Jeff Yutzler
n:Yutzler;Jeff
org:IONIC Enterprise, Inc.
adr;dom:Suite 300;;901 N. Pitt St.;Alexandria;VA;22314
email;internet:[EMAIL PROTECTED]
title:Senior Geospatial Systems Engineer
tel;work:(703) 535-5973
tel;cell:(703) 981-8753
x-mozilla-html:TRUE
version:2.1
end:vcard

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to