|
Puella Magissima posted:A while ago I wrote a bash script to print mpd's currently playing song and status. For most songs it works fine, but today I played a song with a * in it and the script printed the contents of my home directory. I don't know if bash is the horror or if I'm the horror for using it even for lovely one-off scripts. Probably both. Heh, my first program that did something cool was a bash script that pulled my library from mpd and injected it into the right-click desktop menu (I think it just generated XML files that openbox used to produce pipe menus). Wish i still had that somewhere.
|
# ? Oct 8, 2015 00:31 |
|
|
# ? Jun 5, 2024 07:24 |
|
MALE SHOEGAZE posted:Heh, my first program that did something cool was a bash script that pulled my library from mpd and injected it into the right-click desktop menu (I think it just generated XML files that openbox used to produce pipe menus). That sounds like a horrible way to browse your music.
|
# ? Oct 8, 2015 01:49 |
|
Sounds better than my first mp3 organizer.. 1999, everyone at work was downloading every single song off Napster and putting it on a shared server. I built some cgi scripts (in perl) that printed a checkbox for each directory to allow you to select which collections you wanted. Hit submit, it built an m3u file. Open it in winamp and presto, music.
|
# ? Oct 8, 2015 01:55 |
|
necrotic posted:That sounds like a horrible way to browse your music. It sure was!! And now you can try it yourself. code:
DONT THREAD ON ME fucked around with this message at 02:38 on Oct 8, 2015 |
# ? Oct 8, 2015 02:32 |
|
Ooh Is there anyway to transform the menu, so the position doesnt change but the size and content does? fake edit: i.e: iPod style menu traversal.
|
# ? Oct 8, 2015 13:03 |
|
Weird little HTML thing... Why does html think chucknorris is a color?
|
# ? Oct 8, 2015 14:21 |
|
That's not a horror, that's awesome.
|
# ? Oct 8, 2015 14:29 |
|
Then why does #rebeccapurple gives us purple?
|
# ? Oct 8, 2015 14:43 |
|
xzzy posted:Shell has always been a minefield of quote and escape errors. code:
|
# ? Oct 8, 2015 14:47 |
|
What actually happens, according to the answers on that page, is that all characters that aren't hex digits are replaced by zeroes, then zeroes are appended until the number of chars can be divided by three, then the string is divided in three groups, and each group is read as a hex code for R, G, and B.
|
# ? Oct 8, 2015 14:48 |
|
KARMA! posted:Then why does #rebeccapurple gives us purple? In memory of Eric Meyer's daughter.
|
# ? Oct 8, 2015 14:50 |
|
Appropriate username/post combo
|
# ? Oct 8, 2015 15:08 |
It's me, I'm the horror A couple months ago I was assigned to work on a mapper and I cried a little inside because it was awful hacky garbage. However, as an intern, I didn't want to step on any toes to I tiptoed around the awful hacky garbage the best I could and managed to complete my addition. Now that we're testing with appropriate amounts of test data, our frontend guys are unhappy with how the data is being presented and need it condensed a little. In the intervening period, I'd completely forgotten about this soggy mess of spaghetti code (this was actually my first encounter in the wild with using strings as data structures, before I thought it was something no self-respecting programming-employed person would do). Now I have to dig back in and smash together some stuff that is fundamentally opposed to being smashed together. The best part is that we're now in SIT, so an aggressive refactor is pretty much off the table.
|
|
# ? Oct 9, 2015 14:14 |
|
We're well under way taking over the operations of another company - we're a small company but the company we're taking over is smaller still (3 people who are now retiring). We keep running across funny and/or frustrating things they have done in their code. An example would be one of their internal tools which when we first got the code, would check at startup whether there's a folder in the C: drive called "hp" and vary its behaviour accordingly - presumably because one of the people who used it has an HP laptop and the other doesn't.
|
# ? Oct 9, 2015 14:30 |
|
xzzy posted:Sounds better than my first mp3 organizer.. 1999, everyone at work was downloading every single song off Napster and putting it on a shared server. I built some cgi scripts (in perl) that printed a checkbox for each directory to allow you to select which collections you wanted. Hit submit, it built an m3u file. Open it in winamp and presto, music. At least with that if you misclick you don't close the entire thing and have to start browsing from the ground floor again.
|
# ? Oct 9, 2015 17:22 |
|
Hey y'all. I finally got my full-time developer position and a 50% raise to go with it. Thanks for teaching me cool things while I went through my journey of becoming a coding horror creator, horrors thread. edit: Hah, I found the source to my awful turbopascal text adventure that I wrote in high school. Have it as a gift to the coding horrors thread: LeftistMuslimObama posted:I dug up the "text adventure" I wrote in TurboPascal in 10th grade. I didn't know anything about non-array data structures or about loading from/saving to files so the entire game map is encoded as several hundred methods. Each method does the following: http://pastebin.com/Qvg91WBn The MUMPSorceress fucked around with this message at 21:34 on Oct 9, 2015 |
# ? Oct 9, 2015 21:22 |
|
"You're welcome, Obama" Wait, that's not right
|
# ? Oct 9, 2015 21:30 |
|
code:
also this code:
|
# ? Oct 9, 2015 22:30 |
|
Lol. I have a writing degree now too. 10th grade me was, uh, creative...
|
# ? Oct 10, 2015 00:26 |
|
Node.js. That is all.
|
# ? Oct 10, 2015 01:56 |
|
LeftistMuslimObama posted:Lol. I have a writing degree now too. 10th grade me was, uh, creative... I especially like the way you apparently started out trying to write unique error messages for each location but ended up just using that one 300 times
|
# ? Oct 10, 2015 18:27 |
|
YO MAMA HEAD posted:I especially like the way you apparently started out trying to write unique error messages for each location but ended up just using that one 300 times I coded it all by hand every time too. Not so much as a copy and paste. I'm not even that dedicated to stuff I get paid for now.
|
# ? Oct 10, 2015 20:54 |
|
This may be a coding horror but I was reading the last page and I vastly prefer code like thiscode:
if (1), return true. if (2), then if (3), return true. by default return false. Which seems extremely readable to me. Most of the time it makes my eyes twitch if I would have to instantiate an arbitrary local boolean - sometimes multiple, depending on the desire to exit for-loops- and then make that boolean jump through the same hoops that the returns do before returning the state, all for the sake of treating "single exit only" like a Biblical Commandment. If people couldn't follow the (extremely straightforward) branching of multiple returns then following the state of a local variable as it follows the same branches is not easier, it's harder. Especially true when it involves terminating loops early. Of course there are exceptions to this too, if instantiating said booleans or local state variables does make the program easier to read. FieryBalrog fucked around with this message at 21:28 on Oct 10, 2015 |
# ? Oct 10, 2015 21:21 |
|
FieryBalrog posted:This may be a coding horror but I was reading the last page and I vastly prefer code like this You are the worst kind of scum if you write code like this. (Put in the goddamn braces)
|
# ? Oct 10, 2015 21:51 |
|
Early returns are preferable to mutation. I feel like I may have posted this exact statement here before.
|
# ? Oct 10, 2015 21:55 |
|
I like using ifs without braces when it is for simple stuff like return true, but idk why people don't make them one-liners. If it is already taking up two lines you might as well add the brackets.
|
# ? Oct 11, 2015 00:16 |
|
I'm writing the back end for a job scheduler; previously we could only execute one instance of a job at a time because the jobs used stored procedures that had temp state and weren't safe to call concurrently, but the database people fixed this and now it's possible for us to concurrently execute multiple instances of the same job type. This means that the return types for a few REST calls have to change, e.g. /status/jobtype used to return a single JobStatus (converted to JSON) but now needs to return a List<JobStatus> since multiple jobs of that type might be running. In an attempt to not have to do any work, the front end guy is saying that we just shouldn't tell the user that we can execute multiple jobs concurrently - that way we can keep returning a single JobStatus, the front end guy doesn't need to change any of his poo poo, and the user won't realize that they ought to be receiving a List<JobStatus>.
|
# ? Oct 11, 2015 00:42 |
|
fleshweasel posted:Early returns are preferable to mutation. I feel like I may have posted this exact statement here before. You were right then, you're right now. Corla Plankun posted:I like using ifs without braces when it is for simple stuff like return true, but idk why people don't make them one-liners. One-line conditional flow control has no place in source code that will be read again in the future. Flow control is important, give it space and make it easier to read.
|
# ? Oct 11, 2015 00:46 |
|
So, I gather that the perfect version of this code should have no mutation, a single return statement, and two braces for every if block. Well, the solution seems blindingly obvious to me. I don't know, maybe you're all bad? code:
|
# ? Oct 11, 2015 03:11 |
|
NihilCredo posted:So, I gather that the perfect version of this code should have no mutation, a single return statement, and two braces for every if block. i hate you
|
# ? Oct 11, 2015 03:53 |
For some reason the x() and y() being functions is what frustrates me most.
|
|
# ? Oct 11, 2015 04:22 |
|
Manslaughter posted:For some reason the x() and y() being functions is what frustrates me most. That's just standard C++.
|
# ? Oct 11, 2015 05:04 |
|
loinburger posted:I'm writing the back end for a job scheduler; previously we could only execute one instance of a job at a time because the jobs used stored procedures that had temp state and weren't safe to call concurrently, but the database people fixed this and now it's possible for us to concurrently execute multiple instances of the same job type. This means that the return types for a few REST calls have to change, e.g. /status/jobtype used to return a single JobStatus (converted to JSON) but now needs to return a List<JobStatus> since multiple jobs of that type might be running. When making a breaking change to an API (and changing the from returning a single value to returning a list of values is definitely something that could break consumers of the API), it's often better to simply deprecate the old API and introduce a new version that behaves how you want it to behave.
|
# ? Oct 11, 2015 05:05 |
|
NihilCredo posted:So, I gather that the perfect version of this code should have no mutation, a single return statement, and two braces for every if block. I think that's perfectly readable if you break it up into multiple lines.
|
# ? Oct 11, 2015 05:20 |
|
I agree, x() and y() seem dumb. "Coordinate" is a class I wrote within the first month of me learning Java (also my first programming language), and the reason for x() and y() is: me: getters and setters seem really superfluous a lot of the time. But everyone says I should use them all the time. So let me make getX() and setX(). Oh wait, it's really annoying to type getX and setX all the time. Also Joshua Bloch says immutable classes are better and this seems like a class that should be immutable. So let me make x and y final and get rid of these setters. getX() is still annoying to type but everyone says I should have getters. Fine so let me just make the getter as concise as it could possibly be. Maybe I'm wrong and this isn't dumb and I should keep the getters here instead of making it public final int, but I don't know what the right answer is. FieryBalrog fucked around with this message at 02:24 on Oct 13, 2015 |
# ? Oct 13, 2015 02:18 |
|
C# properties are what you want. Java does not have syntax for them. Just use getters and setters. You'll get used to it.
|
# ? Oct 13, 2015 02:35 |
|
Having a compiler keyword to say "synthesize getters/setters for this member variable, and while you're at it, optionally generate code for atomic accesses, weak reference gets, etc" is one of the few things that Objective-C got right. (And then I remember the last year of dealing with Apple's "burn the ships" approach to reverse compatibility, and the abomination that is NSMutableString, and I want to cry and never code in it again.)
|
# ? Oct 13, 2015 02:48 |
|
I guess I like this guy's answer on why getters and setters don't always make sense instead of just having public fields: http://stackoverflow.com/a/12108025/2022797 This is sort of my thought process. I don't think the getter SHOULD ever change the way this field is returned or used, so using a getter is, if anything, misleading compared to just having people use the public (and final) int value. Also the getter can be subclassed and overridden and I don't think that's a plus either. I didn't make Coordinate final because I made subclasses of it that had additional state and behavior (like a subclass where you could define connections to other coordinates). FieryBalrog fucked around with this message at 02:57 on Oct 13, 2015 |
# ? Oct 13, 2015 02:52 |
|
That guys argument is basically "if you want to change something, you should be forced to also change everything that depends on what you changed", which really isn't how sustainable software development works. Often you want to extend your class with new functionality and fields, which requires validating that the newly-added field doesn't conflict with any older ones. You might want to add callbacks that notify something else when a field is changed. You might want to start caching derived properties instead of recomputing them all the time, and need to know when to invalidate that cache. You might want to change which of your properties are actually stored directly, and which ones are derived from the stored properties. All of these are (more frequent than you think) changes that don't affect the external semantics of the class (at least as far as any previously-written code understands them), and shouldn't require wide-ranging yet mechanical changes to everything that uses it. This is especially important when you start producing code that's used by other people, where it might be literally impossible for you to just go in and change their code, and instead requires them to do the pointless busywork when you need to turn a field into a getter/setter pair. I have written dumb data holders that just use fields rather than getter/setters, but those have always been internally-scoped (usually private inner classes), which limits the scale of how much you need to refactor when your initial assumptions change.
|
# ? Oct 13, 2015 03:16 |
|
|
# ? Jun 5, 2024 07:24 |
|
I don't really use C#, but isn't that what structs are usually for in that language? I always thought it was customary to use getters/setters for classes and structs for dumb data blobs with public fields.
|
# ? Oct 13, 2015 06:15 |