Skip to content

Feature request: Consider protected rather than private methods #1307

Closed
@danrivett

Description

@danrivett

Use case

Following on from #1198, it would be fairly trivial to implement disabling a logger by extending the Logger and overriding the shouldPrint function. Unfortunately it's marked as a private method and so can't be.

This ticket has been created to evaluate using the protected method modifier instead of private. There's pros and cons to doing that, but in my experience it is a quick option for improving extensibility, and provides escape hatches.

There are other solutions that can be better for extensibility, but they normally require a larger investment by the library creator, whereas using the protected modifier is simple for the library creator, but puts the onus on the sub-class implementor to know exactly how that method is implemented and maintain any customization going forward.

Therefore another option is to selectively mark certain methods which are simple in nature and likely candidates for customization (such as shouldPrint above).

Solution/User Experience

Use the protected access modifier instead of private either generally for all private methods, or certain methods where it's likely a user may want to customize its behaviour.

Alternative solutions

No response

Acknowledgment

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityloggerThis item relates to the Logger Utility

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions