Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Change SpeedOrPace constructor's visibility to protected #104

Closed
rohandhiman03 opened this issue Oct 12, 2023 · 0 comments · Fixed by #105
Closed

Change SpeedOrPace constructor's visibility to protected #104

rohandhiman03 opened this issue Oct 12, 2023 · 0 comments · Fixed by #105
Labels

Comments

@rohandhiman03
Copy link
Collaborator

Describe the technical debt
The technical debt in the given code snippet arises from the use of a public constructor in an abstract inner static class. Typically, an abstract class is not instantiated directly; it's designed to be subclassed. When the constructor of such an abstract class is marked as public, it gives an impression that instances of this class can be created directly, which is misleading and potentially confusing for developers. Additionally, it doesn't adhere to the principle of least privilege, which dictates that code should be given only the minimum privileges it needs to operate.
scm1

Proposed solution
To address this technical debt, the visibility of the constructor in the SpeedOrPace class should be changed to protected. By doing so, we ensure that only subclasses of SpeedOrPace can access and invoke this constructor. This change makes the code's intention clearer, and it more accurately reflects the purpose and usage of the abstract class.
The modified constructor will look as follows:

scm2

Technical information

  • Device: Pixel 3 API 26
  • OS: Android 8.0
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant