-
Notifications
You must be signed in to change notification settings - Fork 10
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
Refactored own class for receiving app properties #17
Conversation
bMenuItemAlignmentRight = Properties.getValue("menu_alignment"); | ||
} | ||
|
||
static function get() as Settings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be managed through the HomeAssistantService
(service.settings
), that way we will still only have one?
return instance; | ||
} | ||
|
||
function apiKey() as Lang.String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use a function instead of just a public property?
setttings.apiKey() as Lang.String
vs settings.apiKeyas Lang.String
I don't particularly have a preference either way, just wandering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello!
Yes, using a public property would be fitting too. Could then also be part of Globals
.
Using a class with methods for encapsulating the properties have the "benefits" for more comfy unit testings and refactorings. But yes, there are no unit testing atm in this project and the refactoring capabilities of Visual Studio Code for Monkey C is very limited. So you could say, using properties would be a better fitting solution.
I although had in mind using the settings class for in-app settings, where the user can be change settings like the item alignment or showing the icon/labels in the running app itself. But this could be done when implementing this.. .
In the end, I prefer here methods more than properties, because its more fitting in terms of OOP. But for the current circumstances, properties are good enough :)
Okay, just so I'm clear, the plan is to create a brand new file Properties.getValue("api_key") as Lang.String And in doing so add another layer of indirection to the code, soley to provide the type? My current feeling is that I'm missing the value add.
Extra layer of indirection equals obfuscation. Also you now have one extra class with 5 extra methods, is the code really cleaner?
Only a confirmation of type, that's all really.
Ah, now I can see where this is coming from based on previous conversations. You can do Aside: This is a topic where I feel softare engineers may have lost the plot a little. When Dr Wheeler made his famous quote: "All problems in computer science can be solved by another level of indirection." I don't think he considered for one moment how he would encourage unnecessary indirection just for the cleverness of it, i.e all problems "…except for the problem of too many levels of indirection". So I hope you'll understand my reticence to pull this code presently. I'm of the personal opinion that it has yet to meet a threshold or worthiness where it adds more value than it subtracts. It is "nice" don't get me wrong. Sorry to sound negative. |
Hello!
Depends on what is understood as "cleaner" regarding the collaborations circumstances of a project. If there is a relevant likelihood for a project that it has many different person dealing with the code (like every open source project and many closed source ones (for example in bigger companies)), then, for me, there are like four main factors for indicating cleaner code:
And the property names like "api_url" were redundant too.
Hehe true, I am also not a fan of too many level of indirections.. but I am don't like reading assembler code too ;)
Its fine. As I answered already to Joseph's review comment.. that using "settings properties" (for example in the
Have fun, |
3fe48be
to
fc22ca3
Compare
Something that could push this over my personal "threshold of worthiness" comes from the conversion of the two booleans in the application settings to a more descriptive item selection from a pair of drop down menus. See https://developer.garmin.com/connect-iq/core-topics/properties-and-app-settings/#arraysettings The settings would then provide enumerated types like |
I liked this. The UX in the settings area could be better with this. Later, I should have time for implementing this (I would do this in this branch). |
And another thought. |
Due to conflicts and a desire to use a static class rather than a factory class pattern, this work will be completed under https://github.com/house-of-abbey/GarminHomeAssistant/tree/37-add-device-battery-logging-and-settings-class. |
Hello!
Refactoring for encapsulation of Properties.getValue() calls into one place.
Have fun,
someone