Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

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 Dirk Herrmann‭

Type On... Excerpt Status Date
Answer A: What are statements and expressions?
The use of the terms expression and statement could vary between programming languages. However, the following distinction is widely used: Expressions are syntactic forms that allow software authors to describe computations. They intentionally only bring few constraints with respect to ordering....
(more)
9 months ago
Answer A: What are disadvantages of static functions (ie functions with internal linkage) in C?
There are some reasons why a function would intentionally not be declared `static`. (In the following I use the term 'module', but in contrast to others, I use it not to describe a file or translation unit, but rather for an architectural entity (for example, a library), which can consist of several...
(more)
10 months ago
Answer A: For scripting what are the pros and cons of command line arguments versus capturing input at the start?
I would like to add further options to the set of possibilities, namely environment variables and GUI input. Moreover, I would like to distinguish reading information from `stdin` and from other (named) files, as this has some architectural implication. With the options from the OP and other answ...
(more)
10 months ago
Answer A: Count the number of occurrences in a text string
@elgonzo mentioned correctly that the nice trick from @pnuts can not be applied if you are interested in the number of occurrences including overlapping ones. So, just in case someone is in need of such a functionality, here is a function in LibreOffice Basic which handles that case: ``` Funct...
(more)
10 months ago
Answer A: grep AND search for multiple words in files
From your description ... > I have text (xml actually) files. Some files contain 'foo', some contain 'bar', some contain neither and some contain both. It's the both I'm interested in. ... I conclude that you are interested in files that contain both 'foo' and 'bar', but not necessarily on the...
(more)
11 months ago
Answer A: What is the purpose of grouping the tests in a `tests` module and is it possible to split them?
When you think about how to organize your test code, you should develop an understanding of your goals. Typical goals about test code organization (which typically includes helper code only needed for the tests) are: Ensure that test code does not become part of production code - for some kinds ...
(more)
11 months ago
Answer A: Can freed pointers undergo lvalue conversion?
I see it such that it is undefined behavior (I refer to N1570 as the OP https://port70.net/nsz/c/c11/n1570.html): After `free(p)`, the lifetime of the object pointed to has ended (7.22.3p1: "The lifetime of an allocated object extends from the allocation until the deallocation.") Consequently, ...
(more)
about 1 year ago
Answer A: Should we allow answers generated by ChatGPT?
The expectation for all posts is, that a post is always understood as the own work of the poster, who has the copyright and responsibility for it and offers it to the site according to the site's conditions regarding editing etc. What we should ban, therefore, is adding of verbatim ChatGPT respons...
(more)
about 1 year ago
Answer A: How to proportionally convert a number in the range of -1 and 1 to a number in the range of 0 and 319
There is one thing to clarify when mapping a float interval to an integer interval, namely how the boundaries of the float interval shall be mapped to the boundaries of the integer interval. Taking the example of the float interval [-1.0, +1.0], assuming here, that the endpoints of the interval ca...
(more)
over 1 year ago
Answer A: C naming convention, module trigrams?
Starting with the goals: A naming convention typically aims at supporting several, partly contradictory goals, among which are the following: Compliance with the limitations of the language standard and possibly other standards that apply. There are many symbols that are reserved by the ISO-C st...
(more)
over 1 year ago
Answer A: Cast uninitialized variable to (void)
It is undefined according to my reading of the standard (I am referring to the latest public draft). int x; (void)x; In the second line, `(void)x` is a full expression, but `x` by itself is already an expression. For the expression `x` the following holds: > 6.5.1 - 2: An identifi...
(more)
over 1 year ago
Answer A: Create a list of Niven numbers in Python
The way your code handles the variable `i` within the `for` loop seems to indicate a wrong understanding of the meaning of for i in range(1,n+2): `range(1,n+2)` will provide an object of type `range`. This object represents the sequence of numbers from `1` to (not including) `n+2`. At the...
(more)
over 1 year ago
Answer A: Is there any benefit to using new?
Well, you still need (placement) `new` for the implementation of the smart pointers themselves. You would also use it (or malloc) to implement custom allocators, for example: https://www.boost.org/doc/libs/1780/libs/pool/doc/html/boost/defaultuserallocatornewdelete.html. One unusual scenario is...
(more)
over 1 year ago
Answer A: How to use grep to print only specific word from a string
`grep` is not the right tool for your case. You can use `basename`: basename a/b/c --> c basename a/b/c/ --> c or, in your case basename branches/features/armandmusl --> armandmusl which, within a sh script, you would use as dirname=`basename "$CCSR"` Note...
(more)
almost 2 years ago
Answer A: Do you need to use std::move to store a parameter passed by value?
Update: Distinguished between the general case and cases (as with `std::string`) where it is known that there are no side effects. In the general case, the substitution of the call to a copy constructor by a call to a move constructor could lead to a different behavior: The two constructors might ...
(more)
almost 2 years ago
Answer A: Vim: how to search for all instances of a string, except for those that are between two specific strings
As @Quasímodo‭ has shown, the search pattern `\(abc.\)\@ (bird if not preceded by "abc") or (bird if not followed by "xyz") This is why @Quasímodo‭'s answer works. Your search pattern `/\(abc.\)\@<!bird\(.xyz\)\@!`, however, has the following meaning: bird, if ((not preceded by "abc") AN...
(more)
almost 2 years ago
Answer A: A state machine in Python
Some thoughts about your design / code (not repeating what was already said by Derek): You have chosen member `observers` of class `State` to be a list, and member function `register` to append to that list. Consequently, the same observer can be registered more than once, and the order of execu...
(more)
almost 2 years ago
Answer A: How to open a file and edit its content in groovy script
One simple possibility to eliminate a set of lines with precisely known content is to use the `patch` tool. The below code shows an example shell script. The script calls `patch` on the file to be modified (in this case `foo.txt`). The `patch` tool then also gets on the standard input the diff i...
(more)
almost 2 years ago
Answer A: Measuring the impact of using exceptions instead of return values in an ASP.NET Core application
Since your code performs a data base operation, the cost of this operation is likely dominating the execution time. The cost of both a return or an exception may be negligible compared to that operation. For example, assume your data base operation takes 6ms, the return takes 1ns, and the excepti...
(more)
almost 2 years ago
Answer A: Child process works only once after the parent's two calls to scanf
One problem of your code is the one that @celtschk already has reported: You start one child process, and that one child process does the area calculation exactly once. Thus, one step towards the proper solution is to either spawn one child process per calculation, or have the child process also p...
(more)
almost 2 years ago
Question Solving logical puzzle with negation and undefined aspects in Prolog
Assume this trivial logic puzzle which I have made up: There are three boys, Fred, John and Max. No two of the boys have the same age. Max is older than John. Fred is not the oldest one. Question 1: Who is the oldest one? Question 2: What could be possible orderings by age? Obviously, Max ...
(more)
almost 2 years ago
Answer A: Why can't a derived class add a const qualifier to a method?
@InfiniteDissent‭ gives an excellent explanation why such a feature would be problematic from a programming language design perspective. As a consequence, C++ is defined such that the code you wanted to write is no valid C++ code and thus compilers will reject it. Although not directly addressed ...
(more)
almost 2 years ago
Answer A: Explaining the result of an arithmetic expression in JavaScript
The concept that is important to understand here is the concept of operator precedence. Assume you have an expression `a + b c`. What does it mean? You could have the following options: `(a + b) c` or `a + (b c)`. By adding the parentheses it can be made clear what shall be computed first, b...
(more)
almost 2 years ago
Answer A: How this recursive treewalker works?
To understand the concept of recursive tree traversal, I would like to give you an analogy. Imagine a labyrinth of rooms connected like a tree structure. That is, there is an entry to the first room, and when entering a room you may find doors leading into rooms deeper down into the labyrinth, but ...
(more)
about 2 years ago
Answer A: How this recursive treewalker works?
Note: This answer was written for a version of the question that focused on getting rid of the if-else, rather than on an explanation of the workings of the recursive tree-traversal. One way of getting rid of if-elses to achieve uniform handling of different objects is to hide the distinction in l...
(more)
about 2 years ago
Answer A: Recursion without a procedure ("function") in JavaScript
There are several ways to turn a recursive algorithm into an iterative one or at least avoid to do the recursive calls in your own code. In the specific example of yours, where your traverse a tree, some possibilities are: You can create a stack data structure explicitly that corresponds to the ...
(more)
about 2 years ago
Answer A: How to delete contents of a specific field, if it matches a pattern and there is nothing else in the field
For the regular expression to only match a full field of hyphens, you have, as others already have explained, to put the `^` anchor at the begin of the regular expression and the `$` anchor at the end and make it clear that you are interested in a sequence of hyphens by adding a `+` after the hyphen....
(more)
about 2 years ago
Answer A: Should I check if pointer parameters are null pointers?
To extend a bit on some points already mentioned: Regarding where to add checks on a case by case basis: If you have a static code analysis tool that can give you information about areas where provably no null pointer will be passed / no undefined behavior can occur, you can omit the checks in the...
(more)
about 2 years ago
Answer A: Detecting balanced parentheses in Python
> Is this a good approach? How can I improve my algorithm? Your code is correct and simple. That is good, and it may be all that is needed. You have received some responses that indicate that there would be a performance problem. But, whether or not performance is an issue, and what the precise...
(more)
about 2 years ago
Answer A: A class to access dicts using attribute syntax
I like the idea, but more as an exercise or a demonstration what can be done with Python. I also like that the code comes with a set of test cases which are written in a way that they nicely serve as user documentation. In fact, I could even imagine this example being used in a tutorial about the `...
(more)
about 2 years ago
Answer A: Questions easily answered by studying a beginner-level book
What if a question is beginner level? I would say: Someone should answer it. Some of the beginner level questions on stackoverflow have received answers that explain things in wonderful ways. Beginner level questions are formulated in the way beginners ask questions. Experienced people forgot...
(more)
about 2 years ago
Answer A: What does a variable followed by parentheses ("ptr()") mean?
> What does `ptr()` mean in this code? An expression like `ptr` followed by parentheses as in `ptr()` is a function call. In your example, `ptr` is a variable of type "pointer to function" because of the declaration `void (ptr)()`. That is, `ptr()` will call the function that the variable `ptr` ...
(more)
about 2 years ago