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

refactor using delegate (class TerminalCommandProcessor) instead of inheritance #151

Closed

Conversation

Arnaud-Nauwynck
Copy link
Contributor

@Arnaud-Nauwynck Arnaud-Nauwynck commented Jun 1, 2019

introduce class TerminalCommandProcessor to extract code specific to processing ansi escape commands (currently mixed into AnsiOutputStream, and using override...)
.. so change class inheritance by delegation...(Design Pattern best practices).
.. so also refactor to class WindowsTerminalCommandProcessor extends TerminalCommandProcessor instead of extending both WindowsAnsiOutputStream and WindowsAnsiPrintStream

instead of

   AnsiOutputStream               AnsiPrintStream        <=== lot of Copy&Paste
          /\                              /\
       extends                        extends
           |                              |
   WindowsAnsiOutputStream        WindowsAnsiPrintStream   <=== also lot of Copy&Paste

refactor as

   AnsiOutputStream                      AnsiPrintStream     <==== still lot of Copy&Paste
                   \                         /         ( ... cf other PR to fix this )
                   uses                   uses
                      \                    /
                      1 \/               \/ 1
                        TerminalCommandProcessor     <---  factory ---  TerminalType
                                     /\
                                      |
                          WindowsAnsiPrintStream

…nheritance (both WindowsAnsiOutputStream/PrintSteam extends AnsiOutputSteam/PrinStream)
@hboutemy
Copy link
Collaborator

good idea but too complex code
rewrote it, keeping naming and package conventions, avoiding Writer, keeping compatibility with previous API

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.

2 participants