Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Posts by klutt
Increase exposure One way of increasing our exposure is to use Codidact as a source when answering on other forums. As long as we are treating Codidact as any other source, there is absolutely not...
Linux questions in general are not really topic here. But Bash is. After all, Bash IS a scripting language as much as Javascript. I have a hard time thinking of a question about Bash that is not o...
Sometimes when I ask questions here, I get told that I should include a minimal, reproducible example. What is that?
TL;DR A MRE (minimal reproducible example) is simply the minimal code and information needed for someone who is reading your question to reproduce the problem you are having. It needs to be enoug...
I have seen this construct quite a lot: int *p = (int*) malloc(n * sizeof(int)); Is this how it should be? What is the proper way to use malloc? I have also seen this: int *p = malloc(n * size...
This is intended to be a canonical post for this problem which is pretty common. Especially among beginners. I've heard that I should avoid using floating point variables for representing curren...
I have heard that it is undefined behaviour to make a pointer point outside boundaries of an array even without dereferencing it. Can that really be true? Consider this code: int main(void) { ...
While writing the question I actually came up with something that seems to work fairly well, and it's very simple. Just add if(false) in front of the statement.
Background This is kind of a subquestion to How to properly use malloc? When allocating, there are basically two common ways of using the sizeof operator: int *p; p = malloc(n * sizeof *p); /...
TL;DR You should use int *p = malloc(n * sizeof *p); for two reasons The cast (int*) is not necessary, which means it's clutter. Using sizeof *p instead of sizeof(int) removes code duplica...
Consider this code: #include <stdio.h> int main(void) { static void *ptr; if(ptr == NULL) puts("It's NULL!"); } I wonder if this is guaranteed to print "It's NULL!" I know ...
The last few years, PHP has basically exploded with lots of modern language constructs that makes the life easier. But local constants are still missing, and I find that very strange. I have found...
I have an Angular application. The frontend has a mechanism that periodically fetches some information like this: ngOnInit(): void { setInterval( () => { this.http.get(... ).sub...
@BruceAlderman gave a good answer with different aspects that covers the most. I'm not very good at SQL, so my answer is more general. When I have to choose between two different things that are e...
It seems like autocompleting usernames does not work. I wanted to answer a comment and started typing @ followed by the first letter in the username, but no suggestion appeared. I tried pressing ta...
I have a code block like this: try { ... x.foo(); // This is the line that forces us to have the try block ... } catch (ArrayIndexOutOfBoundsException e) { logger.error(e.getM...
I'm writing a function that counts the number of assignments for a fscanf format string. I studied the documentation in C standard 7.21.6.2 It looks like it works. It passes all test cases I have w...
Let's say I have this class: class myService { private boolean foo(T arg) { return arg == 42; } public Response bar(U arg) { if(foo(U.field)) { return Response.st...
See this picture How do you answer in that thread? Hmm, there are two buttons. One says "show more". I click on that and the thread collapse. Is that "more"? Ok, so I click on the thread agai...
This is a bit opinionated, but personally, I would not do it. It would just clutter the code and could hide sources of bugs. But it depends a lot on what function it is. It's also hard to give a ve...
If we compare to SO (and we do) there's one thing I really don't like there. And that is that so many questions get closed for being too opinionated. Granted, many of them is quite naively asked. ...
@laserkittens and @dmckee has already provided good answers, and I will not copy what's there. Personally, I treat cli arguments as the default choice because of the flexibility it gives to scrip...
I have found an improvement that is worth posting as an answer to my question. One thing that I was not comfortable with was coming up with test cases and figuring out how many assignments a forma...
I have some code connecting to an active directory via ldap. Something like this: public Response add(User user) { try { LDAPConnectionPool ldapPool = ldapConnectionPool.getPool();...
Consider this code: while(arr[index] != 0) index++; vs while(arr[index] != 0) { index++; } Personally, I prefer the first. The fact that the braces are not needed makes them -- u...