[ImageJ-devel] [fiji-devel] New methods in CalibratedSpace

Jean-Yves Tinevez tinevez at pasteur.fr
Thu Jul 12 16:28:28 CDT 2012


On 12-Jul-12 23:22, Curtis Rueden wrote:
> Hi Steffi & J-Y,
>
> > if ( img instanceOf ImagePlusImg )
>
> I think using instanceof in this way is quite evil, and should be 
> avoided whenever possible. It is something I very much want to avoid 
> in the core ImgLib2 and ImageJ2 code, because it prohibits 
> extensibility. Better is to put the common functionality into an 
> interface method declaration and then implement it differently in the 
> different subclasses.
>
> That said, how to avoid writing code like this depends on the 
> situation. We'd have to look over the various places in code that it 
> is currently happening...
>
> > 1) break it and maybe it is just fine
> > 2) make a wrapImgPlus method
> > Maybe 1) is the better way to go, I just wanted to bring up 
> potential implications ....
>
> In this case, given that it would be easy to simply add the 
> wrapImgPlus methods, that may be a safer way to go. Anyone else have 
> an opinion?

Maybe

we could take the thing in reverse:

- have wrap() methods return an actual ImagePlusImg
- have ImagePlusImg be an ImgPlus

I quickly looked and this is not trivial: ImagePlusImg is already a 
PlanarImg, and we would have to add some hierarchy in the middle...



More information about the ImageJ-devel mailing list