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.
Activity for kluttâ€
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Comment | Post #289480 |
That's a really good argument! (more) |
— | 8 months ago |
Comment | Post #286504 |
@#56802 I also have to admit that the joke in the end was priceless :D (more) |
— | over 1 year ago |
Comment | Post #286504 |
I don't see where this comes from. Regardless of the any ones opinions of NobleZarkons complaints, their experience is real, and if one person complains about this, it is very likely that there are many others who feel the same way. And sure, since it's people who put in their free time to do this, t... (more) |
— | almost 2 years ago |
Comment | Post #286189 |
Yep, I agree that it could be hard to suggest alternatives. However, as it is now your post gives the impression that finding a replacement is trivial. I think you should at least mention that this can be somewhat tricky. Especially in a portable way.
And another thing. You're referring to a quest... (more) |
— | about 2 years ago |
Comment | Post #286189 |
I think this post would benefit a great deal with more suggestions of alternative. After all, you're saying that the most common print function - `printf` - should not be used. Many people don't even know about anything else. (more) |
— | about 2 years ago |
Comment | Post #286191 |
No I did not say that, and the comparison is ridiculous. (more) |
— | about 2 years ago |
Comment | Post #286191 |
In the case that it would mean a catastrophe if the programmer forgets to do the null check in the right place, it makes total sense to have a check in the wrong place. (more) |
— | about 2 years ago |
Comment | Post #286191 |
I find this very dogmatic. "Never" is a very strong word. As someone said: "Blindly following best practices is not best practice."
However, I can agree that it seems a bit point(haha)less for two reasons.
1. There is rarely a good way to recover is a NULL pointer is passed.
2. NULL is basica... (more) |
— | about 2 years ago |
Comment | Post #286003 |
@#53185 We ended up using something anyway, and I got pretty good argument from my boss about it. Firstly, our requirements are stricter than the ldap server. We don't care if they match to 100%. The only thing we care about is that those that the check lets through to the server are 100% guaranteed ... (more) |
— | about 2 years ago |
Comment | Post #286054 |
I think the first half of your answer would be better if it was a comment thread on the answer, because that's what it is. :)
Fixed the type issue. When it comes to using Set, that fell into the category "I know, but it's not important enough to care about". Did that change too.
I was fiddling ... (more) |
— | about 2 years ago |
Comment | Post #286047 |
I could have sworn I got it, but if you say so. Feel free to edit. (more) |
— | about 2 years ago |
Comment | Post #286031 |
I really appreciate the help, but now I realized that B is a final class :D
I'll have a look. Thanks. (more) |
— | about 2 years ago |
Comment | Post #286031 |
When I saw what you wrote I thought "Omg, that's so obvious", but unfortunately, B does not have a default constructor :(
(And no, it cannot be added) (more) |
— | about 2 years ago |
Comment | Post #286031 |
In the real code, A::add calls B::add. I want to intercept this and make A::add call BMock::add instead.
And yes, A::add is being called multiple times. Well, actually it's kind of that I call A::import, which in turn will call A::add multiple times. So there is a bit of nesting here. (more) |
— | about 2 years ago |
Comment | Post #286013 |
Using protected made a lot of sense, and that's what I ended up doing. Also mocked a lot. (more) |
— | about 2 years ago |
Comment | Post #286017 |
My first reaction to this was what you wrote in the second post. It's just that kind of clever code I'm trying to avoid.
It's often the case that I think code is too airy. Sometimes it makes sense with dense code. Because having to scroll back and forth when reading code can be extremely distr... (more) |
— | about 2 years ago |
Comment | Post #286017 |
That makes good sense. I think you should write an answer with it. (more) |
— | about 2 years ago |
Comment | Post #286017 |
@#53078 Thanks for your input. And yes, I agree to 100% that less lines isn't necessarily better. But there are cases where it is. On the contrary, I'd say that more abstractions, less duplication and big dose of "best practice" isn't necessarily better either.
Oneliners isn't the main goal. Well... (more) |
— | about 2 years ago |
Comment | Post #286019 |
Look at this for instance:
Foo a;
a = new Foo(); a.setX(42); assertEquals(13, bar.fun(foo).getY());
a = new Foo(); a.setX(43); assertEquals(10, bar.fun(foo).getY());
a = new Foo(); a.setX(44); assertEquals(16, bar.fun(foo).getY());
a = new Foo(); a.setX(47); assertEqua... (more) |
— | about 2 years ago |
Comment | Post #286019 |
I completely understand your skepticism, and don't get me wrong. In many (most) cases what you're saying here is the correct approach. I'm just investigating options for when I want another option.
I do make changes to the code for testing. But almost never something that would not also make sens... (more) |
— | about 2 years ago |
Comment | Post #286018 |
I honestly didn't even think about this simple solution. I'll use it. Thanks. (more) |
— | about 2 years ago |
Comment | Post #286017 |
@#53078 Yes, I know, but as I mentioned, I don't want to modify neither `Foo` nor `Bar`. (more) |
— | about 2 years ago |
Comment | Post #286005 |
@#53305 Yes, I actually saw that.
I agree with what they say in the accepted answer. That private methods should be considered implementation details in general. But reality does not follow the books unfortunately. In my case, `foo` has a very simple, yet very distinct task. It's job is to validat... (more) |
— | about 2 years ago |
Comment | Post #286005 |
@#53305 Yes, you're completely right. I'm looking for a mocking solution now. However, I would still like to be able to test this separately. Mainly because some tests will go very quick to run, and can be executed as part of the build process. But other tests will be to much of a slowdown. (more) |
— | about 2 years ago |
Comment | Post #286003 |
@#53305 You're probably right there. I'm using the protocol Ldap to connect to an active directory. When I google it, I'm not the first one to mix this up. :D (more) |
— | about 2 years ago |
Comment | Post #285957 |
The first example with pointer to array with unknown size was the most confusing at first. But I guess it's about the same thing as the struct/union example. If you want to allocate an array of arrays, you do want to know the size of the array. And if you don't something is weird.
And also, would ... (more) |
— | about 2 years ago |
Comment | Post #285957 |
Nice answer!
Some questions here. Regarding allocation of forward declared structs/unions. Spontaneously, I think this looks like a really strong code smell. Am I right? It just feels like something is very wrong if you are about to allocate memory for a struct array before knowing the size of th... (more) |
— | about 2 years ago |
Comment | Post #285956 |
@#8176 I'm 100% confident that you understand what I'm trying to illustrate. If you think that "code duplication" isn't a good phrase to use, please suggest another one. (more) |
— | about 2 years ago |
Comment | Post #285956 |
The duplication comes if you have this:
int *p;
p = malloc(10 * sizeof(int));
free(p);
p = malloc(10 * sizeof(int));
free(p);
p = malloc(10 * sizeof(int));
Changing `p` to `long*` would require three extra changes.
(more) |
— | about 2 years ago |
Comment | Post #285956 |
Indeed. Fixed it. Thanks. (more) |
— | about 2 years ago |
Comment | Post #285956 |
I'm not quite sure what you're saying here. Are you saying that something is wrong? (more) |
— | about 2 years ago |
Comment | Post #285910 |
@#8176 What's problematic with that one? I do indeed expect `sizeof *p` to be 20 bytes with 32-bit int, which it also is. (I checked because you made me believe it would be something else :) )
I'd also like to add that it's a pretty unrealistic example. You declare a local pointer in the argument ... (more) |
— | about 2 years ago |
Comment | Post #285910 |
I would argue that `void failloc (int n, int p[5][5])` isn't a very good counterexample. Using arrays as parameters can indeed be very confusing.
And regarding your pointer to pointer example, I'd say that it is very consistent. You just do `p[i] = malloc(y * sizeof *p[i])` (more) |
— | about 2 years ago |
Comment | Post #285899 |
@#8176in "Depending on the context" is my exact point. You don't throw them in everywhere just for the sake of it. (more) |
— | about 2 years ago |
Comment | Post #285908 |
About step 3. I would definitely not have that as an automatic step. (more) |
— | about 2 years ago |
Comment | Post #285902 |
@#53280 Actually, we ended up using httpinterceptors for this purpose instead. It was quite clean to implement.
However, we also kept your suggestion to make sure that logging out occurs if the user is inactive. (more) |
— | about 2 years ago |
Comment | Post #285899 |
When they standardized C to C89, they took various ideas from different implementations where some had extensions like the void pointer. The important thing wasn't exactly when and where void pointers became a concept, but instead just the fact that void pointers are very old and arguments based on t... (more) |
— | about 2 years ago |
Comment | Post #285899 |
I updated to a better example (more) |
— | about 2 years ago |
Comment | Post #285899 |
I removed that part. I was remembering completely wrong. (more) |
— | about 2 years ago |
Comment | Post #285902 |
I completely understand your skepticism, but this is not the typical office environment. I also hate such features, but in this case it's a security issue that's not negotiable. In the case that someone get interrupted by another task it's actually imperative that this automatic logoff works.
Howe... (more) |
— | about 2 years ago |
Comment | Post #285902 |
Thanks, I'll look into it. However, I was really hoping to not have to redesign everything just to fix this bug.
Task switching is not a thing in this environment. :) (more) |
— | about 2 years ago |
Comment | Post #285875 |
TBH, I think the original phrasing is pretty ok. The problem is how it would have been interpreted on SO. Because there, "too opinionated" means "not 100% objective". (more) |
— | about 2 years ago |
Comment | Post #285883 |
Updated the question (more) |
— | about 2 years ago |
Comment | Post #285035 |
@#55310 The Monica incident was also what drove me here. But there are two important things to consider here.
1 - Even if a user didn't come here for the features, it can be the features that makes the user stay.
2 - Just because you aren't attracted by features, that does not mean that no one... (more) |
— | about 2 years ago |
Comment | Post #285784 |
It looks like there's not enough info in this question to reproduce the problem. https://software.codidact.com/posts/285810 (more) |
— | about 2 years ago |
Comment | Post #277537 |
Good answer. However, I'd say that external memory is also optional. It's fairly common in embedded systems. (more) |
— | over 3 years ago |
Comment | Post #278907 |
Yes, I could write it as a oneliner, but don't get stuck on the specific example. It was just made as an example, and actually, I would have written it as a oneliner, but I would do it by just removing the newline and have `while(arr[index]) index++;` as a single line. Actually I'm pretty fond of doi... (more) |
— | over 3 years ago |
Comment | Post #278896 |
Your first example is also something that would be solved by autoindentation. Plus that if I wrote that , I would put braces around the outer if plus the else. Like `if(x) { if(y) a=k; } else { a=m; }`. And also, autoindentation would solve the problem. It was autocompletion that caused the problem i... (more) |
— | over 3 years ago |
Comment | Post #278895 |
To me it sounds a bit like "you should not use i and j as counters in a nested for loop, because you CAN use the wrong one by accident" ;) (more) |
— | over 3 years ago |
Comment | Post #278895 |
While that example is pretty interesting, it's anecdotal evidence. I understand that it's still possible to produce bugs like this. One could also reasonably argue that it could have been avoided if they used `else if` instead of `if` or didn't use `goto`. (more) |
— | over 3 years ago |