-
Notifications
You must be signed in to change notification settings - Fork 554
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
Extract print methods to seperate classes #854
Conversation
d1cf241
to
5f4f214
Compare
lib/thor/shell/printer.rb
Outdated
@@ -0,0 +1,13 @@ | |||
class Thor | |||
module Shell | |||
class Printer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this class? Can't we just merge it with ColumnPrinter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TablePrinter
and WrappedPrinter
inherit from Printer
as well.
All three subclasses implement the print
method in their own way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we change them to inherit from ColumnPrinter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm asking this because Printer doesn't have the same interface as their subclasses so it is breaking the Liskov substitution principle, and I see no reason to break that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
The printing methods are already pretty large, making it difficult to add extra functionality. Extracting them to seperate classes allows refactoring them for easier maintainability. A lot of the functionality of calculating the terminal width can be extracted to a separate object as well.
5f4f214
to
580234a
Compare
The newest Thor also contains a Terminal module, causing "uninitialized constant Thor::Shell::Terminal::Table (NameError)"
The printing methods are already pretty large, making it difficult to add extra functionality. Extracting them to seperate classes allows refactoring them for easier maintainability.
A lot of the functionality of calculating the terminal width can be extracted to a separate object as well.