Skip to content
This repository was archived by the owner on Oct 26, 2026. It is now read-only.

Remove help Op In Favor of Additional Op Environment API - #34

Merged
hinerm merged 1 commit into
mainfrom
scijava/scijava-ops/help
Jan 27, 2023
Merged

hinerm merged 1 commit into
mainfrom
scijava/scijava-ops/help

Conversation

@gselzer

@gselzer gselzer commented Jun 7, 2021 •

Copy link
Copy Markdown
Member

It seems rather convoluted to me that our promoted way of obtaining information about the ops in an OpEnvironment is to ask a help Op (in our case, a BiFunction<String, OpService, String>), which takes the OpService/OpEnvironment in question, asks it for the relevant OpInfos, and calls utility methods to produce readable Strings from those OpInfos. Why do we not just let the OpEnvironment do the work directly?

This PR removes the help Ops in an attempt to do just that. Instead of calling a help Op, we add two methods to the API of OpEnvironment:

	/**
	 * Returns the descriptions for all Ops contained within this
	 * {@link OpEnvironment}
	 *
	 * @return a {@link List} of descriptions
	 */
	Iterable<String> descriptions();

	/**
	 * Returns the descriptions for all Ops identifiable by a given name within
	 * this {@link OpEnvironment}
	 *
	 * @return a {@link List} of descriptions
	 */
	Iterable<String> descriptions(String name);

This approach does not come at the cost of extensibility, since each implementation of OpEnvironment can implement these methods as the writer sees fit, and the BiFunction<String, OpService, String> type of the help Op did not really offer any more extensibility than this approach does. This approach is also simpler and more readable; instead of writing:

String descriptions = ops.op("help").input("namespace.op", ops.env()).outType(String.class).apply();

we can simply write:

Iterable<String> descriptions = ops.env().descriptions("namespace.op");

The API also no longer combines the descriptions into a single String, which provides users more freedom.

Closes scijava/scijava#27

@gselzer
gselzer requested a review from hinerm June 7, 2021 19:09
@gselzer
gselzer force-pushed the scijava/scijava-ops/help branch from 3c8abaa to f4e4c26 Compare June 8, 2021 14:43
@gselzer
gselzer force-pushed the scijava/scijava-ops/help branch 3 times, most recently from b855711 to 0a3f30f Compare January 17, 2023 19:35
@hinerm
hinerm force-pushed the scijava/scijava-ops/help branch from 0a3f30f to ee22401 Compare January 26, 2023 21:24
@hinerm
hinerm merged commit d6dc506 into main Jan 27, 2023
@hinerm
hinerm deleted the scijava/scijava-ops/help branch January 27, 2023 16:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Help Op Functionality

2 participants