Skip to content
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

Decorate a class #2

Merged
merged 6 commits into from Jul 19, 2022
Merged

Decorate a class #2

merged 6 commits into from Jul 19, 2022

Conversation

anagudelogu
Copy link
Owner

In this Milestone I:

  • Created a class Nameable.

    • Has a method called correct_name that will raise a NotImplementedError.
  • Turned my Person class to Nameable.

    • Has a method correct_name that returns the name attribute
  • Created Base Decorator.

    • Receives a nameable object and stores it in an instance variable.
    • Implements the correct_name method that returns the result of the correct_name method of the @nameable.
  • Created CapitalizeDecorator.

    • Implements a method correct_name that capitalizes the output of @nameable.correct_name.
  • Created TrimmerDecorator

    • Implements a method correct_name that ensures that the output of @nameable.correct_name has 10 characters. If it's longer it should trim the word.

I would appreciate any optional comments and feedback about the code in general, this helps me improve my skills and write clean code that follows professional standards. 🤓

Copy link

@Gambit142 Gambit142 left a comment

Choose a reason for hiding this comment

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

Hi @anagudelogu 👋,

Good job so far!

Highlights

  • All linters checks passed 💯
  • Created Nameable class 💯
  • Created BaseDecorator class 💯

However, there are some issues that you still need to work on to go to the next project but you are almost there!

Required Changes ♻️

Kindly check the comments under the review.

Optional suggestions

Every comment with the [OPTIONAL] prefix is not crucial enough to stop the approval of this PR. However, I strongly recommend you to take them into account as they can make your code better.

You can also consider the optional suggestions I made in the comments under the review. 👍

Cheers and Happy coding!👏👏👏

Feel free to leave any questions or comments in the PR thread if something is not 100% clear.
Please, remember to tag me in your question so I can receive the notification.

Please, do not open a new Pull Request for re-reviews. You should use the same Pull Request submitted for the first review, either valid or invalid unless it is requested otherwise.


As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form.

Comment on lines +6 to +7
def initialize(nameable)
super()
Copy link

@Gambit142 Gambit142 Jul 19, 2022

Choose a reason for hiding this comment

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

  • [Optional] You do not need to call the super method here because the Nameable class doesn't have an initialize method (constructor). 👍

Copy link
Owner Author

Choose a reason for hiding this comment

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

Hi @Gambit142! thank you for your review, I had to add super because it throws an offense in rubocop if not added.

Choose a reason for hiding this comment

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

Hi @anagudelogu, It is alright, I forgot there has been a debate on this issue since the year 2020. 😄 You can get the full story here

lib/person.rb Outdated
Comment on lines 2 to 4
require_relative './capitalize_decorator'
require_relative './trimmer_decorator'

Copy link

@Gambit142 Gambit142 Jul 19, 2022

Choose a reason for hiding this comment

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

  • Kindly remove these statements here. When I try to create a Person object in other files to test your code, I get errors due to these lines of code. Remember that the only class you need to import in the person.rb file is the Nameable class. Kindly implement this change. 👍

Copy link
Owner Author

Choose a reason for hiding this comment

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

@Gambit142 Sure, I tested the functionality and forgot to remove those, thank you for your feedback!

attr_reader :id
attr_accessor :name, :age

def initialize(age, name = 'Unknown', parent_permission: true)
super()
Copy link

@Gambit142 Gambit142 Jul 19, 2022

Choose a reason for hiding this comment

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

  • [Optional] You do not need to call the super method here because the Nameable class doesn't have an initialize method (constructor). 👍

Copy link

@Omar-Muhamad Omar-Muhamad left a comment

Choose a reason for hiding this comment

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

Approved ✔

Hi @anagudelogu,

Great job, Your project is complete! There is nothing else to say other than... it's time to merge it :shipit:
Congratulations! 🎉

thumbs-up-agree

(Highlights) Good Points: 👍

  • You documented your work professionally. ✔
  • Github flow is used correctly. ✔
  • All linters checks are ok. ✔

(Changes Required) Aspects to improve: ♻️

  • N/A

[Optional] suggestions:

  • N/A

Every comment with the [OPTIONAL] prefix is not crucial enough to stop the approval of this PR. However, I strongly recommend you to take them into account as they can make your code better.

**Cheers and Happy coding!👏👏👏

Feel free to leave any questions or comments in the PR thread if something is not 100% clear, and please remember to tag me in your question so I can receive the notification**

Please, do not open a new Pull Request for re-reviews. You should use the same Pull Request submitted for the first review, either valid or invalid unless it is requested otherwise.


As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form.

@anagudelogu anagudelogu merged commit b63d5b4 into dev Jul 19, 2022
@anagudelogu anagudelogu deleted the decorate-a-class branch July 19, 2022 19:39
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.

None yet

3 participants