Replace system lambda
Howdy!
I'm looking to replace the system-lambda test library with small, local, bespoke code. This library specializes in nicer Java code for messing with System globals in the JVM such as STDOUT/STDERR, et al.
This addresses https://github.com/binkley/modern-java-practices/issues/483. Currently the build on this branch is green.
To consider before approving: Should the project provide example replacement code rather than continuing to use a 3rd-party library?
Use a code style that:
- Maximizes teaching, such as a lot of Javadoc: it isn't good enough to "just work", but should help others see the practices and patterns[1]
- Is a drop-in replacement for
system-lambdawith improved naming:captureTerminal(this code) vstapSystemOutNormalized(system-lambda library) (Expected discussion on naming for "captureTerminal" -- all TWers love noodling on naming 😀) - Hides internal details as much as possible (a lesson for readers) to lower the surface area of the API. The replacement class is
TerminalContextand only the static method ofcaptureTerminalshould be visible. Do not look behind the curtain: we mess with JDK global statics)
@Bukharovsi GitHub auto-suggested you to review. :D We won't depend on your feedback to decide if to merge this PR--there is a lot on your plate right now--, but would love your thoughts!
I really like the https://github.com/stefanbirkner/system-lambda library, and use it in some side projects where I need to test complicated things about the terminal or environment. For the example code in this project, it feels like using a cannon to hit an orange.
Footnotes
- Essentially what this PR and a library like
system-lambdadoes is to wrap a continuation (the call to test). Describing it this way is unhelpful for most programmers. We are wrapping calls (Application.main) that access monads for STDOUT and STDERR (such a scholarly description meaning "side effect"), and capturing the data sent to them so we can test these interactions. Yep, this is what testing "Hello, world" looks like! No way I want to talk about it this way to the general programmer audience.