I mean… that is just good design. The main function should be the initializer and orchestrator of the logic. You should be able to look at the main function and tell, at a high level, what the program is doing. It should be usually pretty basic and procedural. Other functions handle the details and complexity.
- 0 Posts
- 52 Comments
kryptonianCodeMonkey@lemmy.worldto
Programmer Humor@programming.dev•Op doesn't have time for interviews
12·1 month agoIt’s a silly riddle that, for some reason, has stuck around in my head for decades, I think from an old tv show (anyone else remember Crashbox?). I remembered the answer immediately. So, this would be less of a test of my reasoning/problem solving skills, and more of a test of my ability to find and store vast amounts of useless trivia and instantly recall it decades after the fact. If that’s what you’re hiring for, I’m your guy!
Propogation of Errors by Bleak Knowledge About Coding
kryptonianCodeMonkey@lemmy.worldto
Programmer Humor@programming.dev•What are some of the worst code you have seen in a production environment?
4·2 months agoSure. There were worse problems to. SQL injection vulnerabilities, dense functions with hundreds of lines of spaghetti code, absolutely zero test coverage on any project, etc. That’s just the easiest to show an example of and it’s also the one that made me flinch every time I saw it.
"".equals()😨
kryptonianCodeMonkey@lemmy.worldto
Programmer Humor@programming.dev•What are some of the worst code you have seen in a production environment?
61·2 months agoJoined a new team and one of my first tasks was a refactor on a shared code file (Java) that was littered with data validations like
if ("".equals(id) || id == null) { throw new IllegalArgumentException() }The dev who wrote it clearly was trying to make sure the string values were populated but they apparently A) didn’t think to just put the null check first so they didnt have to write their string comparison so terribly or else didnt understand short circuiting and B) didn’t know any other null-safe way to check for an empty string, like, say StringUtils.isEmpty()
kryptonianCodeMonkey@lemmy.worldto
Programmer Humor@programming.dev•with a break statement right?
13·3 months agoCPU temp will be my break statement.
Heh, Gateway monitors.
That’s a lot of trust on my butter fingers while trying to manipulate tools with my other hand…
kryptonianCodeMonkey@lemmy.worldto
linuxmemes@lemmy.world•Sometimes people like to complain about windows and iOS
1·3 months agoI’m sure they have. Just relaying my personal experience with it, though it may be outdated by now.
kryptonianCodeMonkey@lemmy.worldto
linuxmemes@lemmy.world•Sometimes people like to complain about windows and iOS
1·3 months agoIt wouldn’t just drop, like suddenly out of nowhere. It was on a kernel update. This was, I guess, 2018 or 2019? Can’t remember exactly.
kryptonianCodeMonkey@lemmy.worldto
linuxmemes@lemmy.world•Sometimes people like to complain about windows and iOS
111·3 months agoI have no love for Windows (and active hatred for Apple), and I highly value much of the features, customizability, open-source culture, and anti-capitalist aspects of Linux. But it’s not perfect.
I’m a software engineer. I part pick and build my PCs. I’ve worked in IT. And I manage my home networking and automate my self-hosted media server. But when I tried fully switching to Linux a few years back, I held out for a few months, but it just wasn’t worth the hassle. My PC had an Nvidia graphics card, and I had no choice but to use a wifi dongle at my previous residence. Support for both was an after market hack job that needed constant maintenance. It was just annoying, my monitor’s resolution just dropping to 480p and the internet cutting out until I reapplied some patch job.
If I had built my PC with Linux in mind, I would have done it differently. And I’m sure that I’ll try again with my next PC when I can pick compatible hardware. But my point is that I’m far from the layman and still didn’t stick with it the first time. The average computer user doesn’t need a project, doesn’t need highly customizable everything, and doesn’t care about open source. They need things to just work. And I know the problem is the lack of Linux support from major tech companies, which is BS. But that means that Linux simply can’t provide that stability and just work for a more casual user. So it is not the best option for most people.
kryptonianCodeMonkey@lemmy.worldto
Programmer Humor@programming.dev•goto spaghetti1 goto spaghetti8 goto spaghetti6 goto end1 goto start5
14·3 months agoBut anyway, I kind of like goto too much. I find it more intuitive to just jump around and re-use parts rather than think about how to do loops without too much nesting.
Might I introduce you to functions?
Need to write a prompt to the console and get an input? That could be a function. Need to check if a character matches some option(s)? That’s could be a function. Need to run a specific conditional subroutine? That could be a function. And function names, done correctly, are their own documentation too.
You main function loop could look almost like pseudo code if you do it right.
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> char* prompt_for_input(const char* prompt_message) { char temp[100]; printf(prompt_message); fgets(temp, 100, stdin); temp[strlen(temp)-1] = '\0'; char* input = malloc(strlen(temp)); strcpy(input,temp); return input; } int string_to_int(char* input) { return (int)strtol(input, NULL, 10); } int prompt_for_loop_count() { char *input = prompt_for_input("\nI'll loop over this many times: "); int loop_count = string_to_int(input); free(input); return loop_count; } bool prompt_to_do_again(){ char *input = prompt_for_input("Let's do that again!\nShallow we? (y/n): "); bool do_again = (strcmp(input, "y") == 0 || strcmp(input, "Y") == 0); free(input); return do_again; } void print_and_decrement_counter(int loops_remaining) { do { printf("Current = %d\n", loops_remaining); loops_remaining--; } while (loops_remaining > 0); } int main() { bool need_to_get_loop_count = true; printf("Hello."); while(need_to_get_loop_count) { int loops_remaining = prompt_for_loop_count(); print_and_decrement_counter(loops_remaining); need_to_get_loop_count = prompt_to_do_again(); } printf("\nBye\n\n"); }
I wasn’t implying anything of the sort, but ok.
In this case, I think it was more indoctrination of a rule her dad set that she never questioned.
I had a similar conversation with a friend in college who alleged that waking up after 9am meant that you are lazy. In all cases. Period.
Stayed up until 3am partying with your friends? Better still be up by 9.
Took the Redeye which didn’t land until 5am? Oof, enjoy your few hours remaining but don’t sleep in…
Work a double shift through the night until 8am? Did I fucking stutter, you can only sleep until 9am, you useless fuck!
Idk… seems silly and arbitrary.
Giancarlo Esposito is the embodiment of quiet menace and commitment to character


My wife can bake (more or less), but cannot cook much else to save her life. She’ll default to crackers, cheese and turkey slices for every meal, maaaaybe the occasional frozen pizza, if I don’t cook. Also I’m a really good cook and I like my food, so… I’mma do the cooking.