5 ms·
ASCII Art in .NET Code
- WorldMaker 7y agoAn interesting thing about the Timelines example is that the Reactive Extensions world uses a lot of similar ASCII drawing and often refers to them as "Marble Diagrams". There are tools to generate nice graphic versions of ASCII Marble Diagrams. Some unit tests frameworks for RX libraries even support writing tests directly as ASCII Marble Diagrams: https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/testing/marble-testing.md https://github.com/ReactiveX/rxjs/blob/master/docs_app/conte...
- 32bitkid 7y agoI have no connection or affiliation with this product, but I enjoy a good ASCII/Unicode chart in code—a picture is worth a 1k words—and I've been leaning on https://monodraw.helftone.com/ https://monodraw.helftone.com/ lately for my text drawing needs.
- mpoteat 7y agoThat's an awesome product but being Mac only is a no go for me. Electron / Web app is such a common product model, no idea why they didn't embrace that.
- v-yadli 7y agoTry jave, it’s java based and has been around for a long time.
- cheerlessbog 7y agoPretty funny that a format intended to allow you to draw without a mouse now has a visual designer. Are there serious interactive image editors that don't require a mouse? For symmetry's sake.
- Exuma 7y agoHow does the regex work?
- McGlockenshire 7y ago"/\*" - literal forward slash followed by literal asterisk "(.*?)" - followed by zero or more of any character, captured non-greedy "\*" - and another literal asterisk "|" - all of the above, or the following "//(.*?)" - literal two forward slashes and another non-greedy anything "\r?\n" - a possible carriage return followed by a newline "|" - or the following pattern in double quotes: "(\\[^\n]|[^"\n])*" - a backslash followed by one character that is not a newline, OR anything that is not a double quote or a newline. this sequence can occur zero or more times, and both the matching sequence and all of the matching sequence are captured "|" - or "@("[^"]\*")+" - a literal at sign, followed by one or more of anything that is not double quotes, enclosed by double quotes. All it's doing is sniffing segments that look like they might be comment blocks, sections in double quotes, and... I'm not actually sure what the last segment would be, it seems to capture @"whatever"? Regardless, this doesn't actually sniff for ASCII art as much as comments themselves.
- bhrgunatha 7y agoIn C# @"..." are verbatim strings - useful for capturing characters without having to escape them.
- matthewwarren 7y ago> Regardless, this doesn't actually sniff for ASCII art as much as comments themselves. Yeah you're right. The regex just finds comments. I then wrote some very simple code that analysed the text inside the comments to find potentially interesting ASCII Art. I then looked through these manually to get the ones for the post.
- userbinator 7y agoComments like this are often discouraged because they're difficult to modify when the code is changed, but in these cases it seems their purpose besides explanation is to imply that there is a good reason the code is the way it is, and that you had better have a very good reason to change the code (and the accompanying comment). In other words, they serve to also guard against change, in parts of the code which should not change often.
- ken 7y agoMost of these diagrams don't look that difficult to modify -- but then, I've got Emacs (with picture-mode, artist-mode, table-mode, etc). The presence of a diagram would not discourage me from changing a function, if I thought it needed changing. I wish most functions were so well documented! It's true I haven't seen any IDEs with similar capabilities, so I imagine it is harder for other people. At what point does it become permissible to say "It's not my problem you choose to use a text editor that isn't capable of editing this style of text"? We're certainly well beyond that point in most other areas, e.g., indentation, capitalization, or renaming.
- matthewwarren 7y ago> but in these cases it seems their purpose besides explanation is to imply that there is a good reason the code is the way it is, and that you had better have a very good reason to change the code (and the accompanying comment). In other words, they serve to also guard against change, in parts of the code which should not change often. Interesting, I'd not thought about that 'side-effect', but you're right, it does guard against that
- selectnull 7y agoOf course, whole another level of using ASCII art is to make it executable, as done by a good friend of mine: Stack Trace Art (https://github.com/ironcev/stack-trace-art https://github.com/ironcev/stack-trace-art). I've loved it so much that when I saw it for the first time (some 5 years ago) I had to port it to JavaScript (original is C#) and you can see it here: https://github.com/selectnull/stacktraceart https://github.com/selectnull/stacktraceart If you're interested in story of how the idea was born, read about it in these blog posts: * http://thehumbleprogrammer.com/stack-trace-art/ http://thehumbleprogrammer.com/stack-trace-art/ * http://thehumbleprogrammer.com/his-majesty-hangul-the-filler/ http://thehumbleprogrammer.com/his-majesty-hangul-the-filler...
- matthewwarren 7y agoWow, 'Stack Trace Art' is very cool, thanks for the links!
- deleted 7y ago[deleted]