Skip to content

"#1081 Removed public class modifiers" - #1082

Merged
sjwarner-bp merged 8 commits into
exercism:masterfrom
c-thornton:master
Dec 13, 2017
Merged

sjwarner-bp merged 8 commits into
exercism:masterfrom
c-thornton:master

Conversation

@c-thornton

@c-thornton c-thornton commented Dec 12, 2017 •

Copy link
Copy Markdown
Contributor

Removed public class modifiers from the Meetup.java and MeetupSchedule.java src and .meta folders.


Reviewer Resources:

Track Policies

@FridaTveit FridaTveit 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.

This looks great @c-thornton :) There's just one more thing which can be made package private :)

class Meetup {
private final LocalDate startOfMonth;

public Meetup(int monthOfYear, int year) {

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.

This can also be package private :)

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.

Sorry for missing that one @FridaTveit, thought I got them all. Thanks for the feedback on this. I will get that one modified in a couple hours when I am in front of my computer again and modify the PR.

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.

Perfect!

@sjwarner-bp sjwarner-bp 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.

I've just looked over your last few commits - we're so close here!

None of MeetupTest needs to change, as the JUnit tests and class need to be public - but as @FridaTveit has said, on line 8 in Meetup you can remove the public modifier. We can't make it private as it needs to be accessed by the tests (I saw you tried this and it didn't work out), but package-private should be fine 🙂

@c-thornton

Copy link
Copy Markdown
Contributor Author

Thanks @sjwarner-bp for the tip. I was wondering what I was doing incorrectly there. I should have read what @FridaTveit had written better. This is a learning experience for sure. The tests are running again now so hopefully it will pass this time and we should be good.

@sjwarner-bp sjwarner-bp 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.

So so nearly there! I think I was a little unclear in my last comment. 'package-private' is an access level, but to specify this level of privacy you don't need any keyword (i.e. you can delete the access modifier on line 8).

Access modifiers are super useful to restrict access to certain areas of code, and they help promote proper encapsulation! If you want to read up here is a good link 🙂

@c-thornton

Copy link
Copy Markdown
Contributor Author

Doh! I should have known that honestly. Thanks for the link, I will read up on that tonight. I will make the correct change shortly and push it to my fork. Thanks for the guidance @sjwarner-bp and for being patient with me.

@sjwarner-bp

Copy link
Copy Markdown
Contributor

That's no problem! Thanks for the speedy updates 👍

@c-thornton

Copy link
Copy Markdown
Contributor Author

So one thing I just thought about @sjwarner-bp was consistency with the style. Since the Meetup method will not have a private declaration should I go ahead and remove it from the cycleToPrev method as well so that the style is consistent within the Meetup class?

Removed package-private from Meetup method and removed private from
cycleToPrev and cycleToNext methods.
@sjwarner-bp

sjwarner-bp commented Dec 12, 2017 •

Copy link
Copy Markdown
Contributor

That's a good question! While changing the private methods to package-private wouldn't cause the build to fail, it is worth keeping in mind that we are trying to minimise the accessibility of classes and members.

Because these methods are only used in Meetup (i.e. nothing outside of their class calls them), we can keep them as private.

Remember - package-private is more accessible than private, and we want to keep accessibility to a (working) minimum 🙂

Per feedback on pull request #1082 added the private access levels back
to these two methods.
@c-thornton

Copy link
Copy Markdown
Contributor Author

Awesome, thanks for the link and the info. So I removed private from cycleToPrev and cycleToNext with the commit that I just pushed on my side. I added them back in a pushed again and the checks just finished up for this one and were succesful. Thanks for the extra guidance and patience while working with me on this pull request.

@sjwarner-bp sjwarner-bp 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.

LGTM! 🎉

@c-thornton

Copy link
Copy Markdown
Contributor Author

Awesome! Thanks @sjwarner-bp. Now time to do some reading before tackling some other issues. Thanks for all the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants