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

Milestone/Project 2: feature - decorators 🎫 #2

Merged
merged 5 commits into from
Nov 8, 2023

Conversation

ITurres
Copy link
Owner

@ITurres ITurres commented Nov 7, 2023

🚩I have made the following changes to complete OOP School Library - Milestone/Project 2

Here is a summary of what has been done

Type of files changed/added

My Skills

In this new Branch, I have ➕ADDED➕ the succeeding *📂 folders and/or **📄 files to complete this milestone's requirements

*📂 root/

  • *📂 lib/

    • **📄 nameable.rb

      • The -Nameable- class will raise the NotImplementedError exception if the correct_name method is not implemented.

      • The -BaseDecorator- will inherits from -Nameable-.

        • In its constructor it will get the nameable object and assign it to the @nameable attribute.

        • It will also implement the correct_name method returning the @nameable object's correct_name method.

      • -CapitalizeDecorator- will inherits from -BaseDecorator-.

        • It will implement the correct_name method returning the @nameable object's correct_name method capitalized.
      • -TrimmerDecorator- will inherits from -BaseDecorator-.

        • It will implement the correct_name method returning the @nameable object's correct_name method trimmed unless the @nameable object's correct_name method length is less <= 10 characters.

I have ✏️MODIFIED✏️ the succeeding *📂 folders and/or 📄** files

*📂 root/

  • **📄 README.md ✏️

    • I have marked as complete the 'Class Decorators' item on Future Features section.
  • *📂 lib/

    • **📄 person.rb ✏️

      • I have required nameable.
      • I have also included the method correct_name returning the @name attribute.

Thank you for taking the time to review this PR ⭐


If you require additional information or have any questions, don't hesitate to get in touch with me on Slack as Arturo (Arthur) Emanuel Guerra Iturres. I'll be happy to help you out. 🎯


- Add 'Nameable' class interface.
- Add 'BaseDecorator' class base decorator.
- Add 'CapitalizeDecorator' class decorator inheriting from 'BaseDecorator'.
- Add 'TrimmerDecorator' class decorator inheriting from 'BaseDecorator'.
- Include 'Nameable' class as an interface, which defines
  the 'correct_name' method.
- In the 'Person' class, call super in the constructor
  to ensure proper initialization.
- Implement the 'correct_name' method to meet the
  requirements of the 'Nameable' class interface.
@ITurres ITurres added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 7, 2023
@ITurres ITurres self-assigned this Nov 7, 2023
Copy link

@Johnadibe Johnadibe left a comment

Choose a reason for hiding this comment

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

Status: Approved ✔️

Hi @ITurres👋🏽,

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

LeonardoInGatsby

Highlights

  • Created a class Nameable that has a method correct_name implemented✔️
  • Created a base Decorator class that implements the correct_name method which returns the result of the correct_name method of the @nameable✔️
  • Created a CapitalizeDecorator class that implements a method correct_name which capitalizes the output of @nameable.correct_name✔️
  • Created a TrimmerDecorator class that implements a method correct_name which makes sure that the output of @nameable.correct_name has a maximum of 10 characters✔
  • The App works as expected✔

Optional suggestions

Every comment with the [OPTIONAL] prefix won't stop the approval of this PR. However, I strongly recommend you to take them into account as they can make your code better. Some of them were simply missed by the previous reviewer and addressing them will really improve your application.

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.


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 7 to 18
class BaseDecorator < Nameable
attr_accessor :nameable

def initialize(nameable)
super()
@nameable = nameable
end

def correct_name
@nameable.correct_name
end
end

Choose a reason for hiding this comment

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

  • [OPTIONAL] I suggest you put this code in a seperate .rb file. Doing this will help organize your code more efficiently.👍

Comment on lines 20 to 24
class CapitalizeDecorator < BaseDecorator
def correct_name
@nameable.correct_name.capitalize
end
end

Choose a reason for hiding this comment

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

  • [OPTIONAL] I suggest you put this code in a seperate .rb file. Doing this will help organize your code more efficiently.👍

Comment on lines 26 to 30
class TrimmerDecorator < BaseDecorator
def correct_name
@nameable.correct_name[0...10] unless @nameable.correct_name.length <= 10
end
end

Choose a reason for hiding this comment

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

  • [OPTIONAL] I suggest you put this code in a seperate .rb file. Doing this will help organize your code more efficiently.👍

@ITurres
Copy link
Owner Author

ITurres commented Nov 7, 2023

Hi @Johnadibe John! how are you? absolutely! 🎯, you know, modularizing the decorators was my first approach 😄, however, I encountered the error that both the string modifier decorators were missing when I instantiated them on person.rb during testing.
The problem was that I was requiring just nameable and this file would only contain the nameable class interface. So in order for it to work I would have to require each string modifier decorator.

Such as:

require_relative 'class_decorators/capitalize_decorator'
require_relative 'class_decorators/trimmer_decorator'

What do you think? 🤠

@Johnadibe
Copy link

Hello @ITurres, I believe it is okay if you do that.👍

@ITurres
Copy link
Owner Author

ITurres commented Nov 7, 2023

Great then, thank you @Johnadibe John for having reviewed this PR! 👍🏼, wish you a great week and happy coding! 🎆

- Move 'BaseDecorator', 'CapitalizeDecorator', and 'TrimmerDecorator'
in 'nameable.rb' to their own files.
@ITurres ITurres merged commit b0b74bf into development Nov 8, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants