Skip to content
Curtis Rueden edited this page Jul 10, 2015 · 9 revisions

How are the ops named?

Each op has a name, which is not necessarily unique. This allows multiple "overloaded" ops with different combinations of parameter types, similar to the method overloading feature of Java and other programming languages.

Ops may optionally have a namespace. This is similar to packages in Java and similar features in other languages. The namespace is expressed as a prefix; such ops are referenced by their namespace, followed by a dot, followed by the op name. Ops without a namespace belong to the "global" namespace, with no prefix or dot. Two ops with the same name but different namespaces do not "overload" or "override" one other.

The naming convention for both namespaces and op names is to use an alphameric string, in lower camel case.

How are the Java classes and packages named?

We use the following guidelines:

  • Each kind of operation has an associated interface in the net.imagej.ops.Ops container class, nested beneath its namespace. For example, ops named math.add implement the Ops.Math.Add interface. The Ops container class is autogenerated from a Velocity template; see Ops.list and Ops.vm.
  • Each kind of operation lives in an associated package matching its namespace and op name. For example, ops named math.add are declared in the net.imagej.ops.math.add package.
  • It is OK to have subinterfaces for different sorts of ops with the same name, if needed.
  • For each Ops.Foo.Bar interface, create a net.imagej.ops.foo.AbstractBarOp base class, as well as one or more concrete implementing subclasses, each annotated with @Plugin. If you have a single concrete implementing class, it will typically be named net.imagej.ops.foo.DefaultBarOp. See the type hierarchy of net.imagej.ops.identity for a simple example.
  • The reason for the Op suffix of BarOp etc. is in case the operation works with a data structure of the same name. For example, a MeanOp might compute a Mean, a SmallestEnclosingRectangleOp might compute a SmallestEnclosingRectangle, and so on.

How are the built-in method signatures structured?

The OpService provides built-in type-safe methods corresponding to all ops available in the core OPS library. These methods are consistent with the patterns discussed above: global ops have methods directly in OpService, while the ops of a particular namespace are accessible via their Namespace class, which is accessible from the OpService. For example, to call a math.add op, you would write ops.math().add(...), where ops is a reference to the OpService instance.

Clone this wiki locally