Pi4J / pi4j-v2

Pi4J Version 2.0
Apache License 2.0
266 stars 54 forks source link

#340 merging pi4j-board-info into pi4j-core #341

Closed FDelporte closed 3 months ago

FDelporte commented 3 months ago

To be able to use the data from the model in a REST API, this requires an extra dependency. Is this a problem?

com.fasterxml.jackson.core:jackson-annotations
eitch commented 3 months ago

To be able to use the data from the model in a REST API, this requires an extra dependency. Is this a problem?

com.fasterxml.jackson.core:jackson-annotations

Shouldn't we keep the JSON stuff out of core Pi4j? Let the REST API code generate the JSON code, then we don't need this dependency.

FDelporte commented 3 months ago

Shouldn't we keep the JSON stuff out of core Pi4j?

@eitch I was expecting this ;-) is removed now...

FDelporte commented 3 months ago

We should perform the code to detect the board only once, and then store it in a singleton.

It's called from DefaultContext.java, so it's part of a singleton, correct?

https://github.com/Pi4J/pi4j-v2/pull/341/files#diff-34f18b9362bf258d05dac12071fa50bf49f05a9459c7875dbbb2044bdbe23962R107

eitch commented 3 months ago

We should perform the code to detect the board only once, and then store it in a singleton.

It's called from DefaultContext.java, so it's part of a singleton, correct?

https://github.com/Pi4J/pi4j-v2/pull/341/files#diff-34f18b9362bf258d05dac12071fa50bf49f05a9459c7875dbbb2044bdbe23962R107

Sure, but maybe someone else would call BoardInfo.current(), as it is a static helper method.

FDelporte commented 3 months ago

Sure, but maybe someone else would call BoardInfo.current(), as it is a static helper method.

yep, in that case, it's up to the user to decide if they want to do that multiple times, right?

eitch commented 3 months ago

Sure, but maybe someone else would call BoardInfo.current(), as it is a static helper method.

yep, in that case, it's up to the user to decide if they want to do that multiple times, right?

True, but from a library i expect it to avoid unnecessary computations. So multiple calls should cache this computation somehow.