question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refactor ConsoleDrivers to remove duplicate code

See original GitHub issue

There is a LOT of common code across the three (now four with Fake) Drivers.

I was just thinking about how to fix bugs related to non-printable chars causing rendering issues on some terminals. For example, in Windows Terminal and Fluent if AddRune gets called with \n it does this: image

The fix is to modify AddRune to look for non-printable chars like this, that may cause the underlying console to take action and replace them with the right glyph. E.g:

image

However, it’s stupid to do this 4 times. Instead the base should implement the least-common-denominator functionality.

Right?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
tigcommented, Aug 9, 2023

Woo-hoo! Finally!

It ain’t perfect, but this radically simplifies and improves the ability to prove quality.

2reactions
migueldeicazacommented, Jun 15, 2020

I think this makes sense.

The abstract capability is more of an indicator that some holes need to be plugged by concrete implementations, but we could move common code here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code Refactoring to remove the duplicate code
I have three methods in two classes in which two methods have the same code but with different inheritance. How can I reduce...
Read more >
Duplicate Code
Use Extract Method for both classes, followed by Pull Up Field for the fields used in the method that you're pulling up. ·...
Read more >
Refactoring Duplicate Code. Engineering Insights | by Talin
Thus, refactoring duplicate code can make this evolution easier. Some programmers are pretty obsessive about eliminating duplicate code ...
Read more >
object oriented - How to remove duplicate code (in general)?
So the fix would be to extract the method and delegate to common behaviour. in the same method, perform Extract Local Variable and...
Read more >
The Art of Refactoring: Removing Code Duplications
Our first goal is to remove the second duplication. This should be easy, because the code looks almost the same.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found