Skip to content

Rename LedgerMetadataBuilder#closingAt to parameter order - #1835

Merged
ivankelly merged 3 commits into
apache:masterfrom
ivankelly:closing-at
Nov 29, 2018
Merged

ivankelly merged 3 commits into
apache:masterfrom
ivankelly:closing-at

Conversation

@ivankelly

@ivankelly ivankelly commented Nov 23, 2018 •

Copy link
Copy Markdown
Contributor

The two parameters are long, so it can be confusing which order they should go in at the callsite.

This change renames #closingAt to #withClosedState, and remove the parameters. This brings the state change in line with #withInRecoveryState and means the caller has to explicitly call #withLastEntryId and #withLength. There is a runtime validation in LedgerMetadata to ensure that if the state is closed, both parameters have also been set.

Master issue: #281

The two parameters are long, which can be confusing.

Master issue: apache#281

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea

(metadata) -> {
return LedgerMetadataBuilder.from(metadata)
.closingAt(lastEntry, finalLength).build();
.closedAtEntryAndLength(lastEntry, finalLength).build();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a different opinion at putting parameter names at method. that means if we want to extend in future to add more stuffs at closing phase, we have to rename the methods across the project. so I would call it closedAt rather than closedAtEntryAndLength.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, we should remove both parameters, and let it be handled by the checkArguments in LedgerMetadata (i.e. require that people call withLength & withLastEntryId)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. but still I think 'closedAt' is better than 'closedAtEntryAndLength' at this point.

@ivankelly ivankelly changed the title Rename LedgerMetadataBuilder#closingAt to clarify parameter order LedgerMetadataBuilder#closingAt to clarify parameter order Nov 28, 2018
@ivankelly ivankelly changed the title LedgerMetadataBuilder#closingAt to clarify parameter order Rename LedgerMetadataBuilder#closingAt to parameter order Nov 28, 2018
@ivankelly ivankelly added this to the 4.9.0 milestone Nov 29, 2018
@ivankelly
ivankelly merged commit 079013e into apache:master Nov 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants