-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Opening API #55
Comments
Thanks for asking! I was just about to ask about this myself. My vote would be for both 2 and 3. I found myself wanting access to these things in my
|
Our implementation follows 1) On the one hand, it helps in keeping BT implementation details contained in 1 class, and we can expose operations with semantic meaning in our domain. On the other hand, it does end up becoming a God class. Our BleManager implementation is ~550 lines with very little tests (see #45) Implementing 2) would helping in having smaller, domain-specific Ble classes if we were able to keep a single queue request. As I'm thinking it right now, we'd have a singleton BleManager instance and per-feature wrappers over it. This'd make smaller classes with easier testing. SensorBleManager @Inject constructor(private val bleManager) {
fun enableVibration(){
bleManager.writeCharacteristic(...).enqueue()
}
} Which methods are you considering to make non-final? What would be the goal? Is it to facilitate testing or are there other reasons? |
Let's leave the testability to #45. I was thinking about definaling methods that return Requests, e.g. Regarding having smaller domain-specific classes, I was rather thinking about allowing to add "modules" to the manager, responsible for some part of the logic. For example, DFU module, Battery module, etc. So far I'm (almost) convinced to make request operations non-final. Then exposing |
Hi,
As you may have seen, most of the methods in the
BleManager
are package protected and final. My intention was to allow the final user to define the their manager's API without bringing all other methods with it. For example, theMySuperCoolManager extends BleManager
would have a methodenableFancyLED()
,bond()
, etc. and internal methods, likewriteNotification
would not be visible from outside. There are 2 methods exposed:connect(..)
anddisconnect(..)
, but not more.The question is: is it a good idea, or does it make more troubles than good?
There are 3 solutions:
As I'm thinking now, making them non-final is the best idea. Some methods could be made public by overriding them without actually changing functionality.
CC: @eliotstock, @maragues-kolibree, @sztomek, @balazsnemeth, @balazsnemeth, ...
The text was updated successfully, but these errors were encountered: