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 Lundin‭

Type On... Excerpt Status Date
Answer A: Pattern / architecture for interfacing with components in C
Code review part: Design (important!) - Global variables/external linkage are to be avoided (Why is global evil?). - You don't actually have private encapsulation in this code since the internals of the struct are exposed to the caller. There are better ways to design this with "opaque types" an...
(more)
about 1 year ago
Edit Post #291195 Post edited:
about 1 year ago
Edit Post #291196 Post edited:
about 1 year ago
Edit Post #291196 Post edited:
about 1 year ago
Edit Post #291196 Initial revision about 1 year ago
Answer A: Why is global evil?
The basics of good vs bad program design All programs are divided in classes. (Or modules/abstract data types/interfaces etc - a rose by any other name.) Each class should only be concerned with its own designated task and not with unrelated parts of the program. Similarly, each class is aut...
(more)
about 1 year ago
Comment Post #291175 Indeed. I could answer this from a general programming perspective, but not from a PHP-specific perspective. Mostly it is about program design no matter language. But different languages have different scope rules and namespace rules, meaning that it may be more or less serious namespace pollution in...
(more)
about 1 year ago
Comment Post #291112 @#64656 The whole point is that program design-wise input sanitation should happen at the point where input is taken. And if that part is done correctly, strcpy is safer than strncpy. And memccpy is arguably a bit safer too since it has no misleading `str` prefix.
(more)
about 1 year ago
Edit Post #281519 Post edited:
Added note about memccpy
about 1 year ago
Comment Post #291112 I hope you don't mind that I now posted a complementary answer. The fight against `strncpy` is kind of a pet peeve of mine, see :)
(more)
about 1 year ago
Edit Post #291119 Initial revision about 1 year ago
Answer A: How can I manage multiple consecutive strings in a buffer (and add more later)?
When looking at this, we might pretty soon note that storing strings in the same buffer by using null terminators as separator is quite clunky. It blocks us from using handy functions like `strtok`, `bsearch` or `qsort`. And there's no obvious way to tell where all of it ends. To know where it ends, ...
(more)
about 1 year ago
Comment Post #291112 strncpy should pretty much never be used since it was never intended to be a function used on null terminated C strings. See [Is strcpy dangerous and what should be used instead?](https://software.codidact.com/posts/281518). In this case you added the null terminator manually, but people tend to forg...
(more)
about 1 year ago
Edit Post #291074 Initial revision about 1 year ago
Answer A: Is software system design on topic here?
Software design in itself has always been on-topic, as per https://software.codidact.com/help/on-topic. As for system design for a given purpose, I think it is fine within reason. Contrary to popular belief, a certain degree of domain expertise or at least insight is always necessary when writing...
(more)
about 1 year ago
Edit Post #290882 Post edited:
over 1 year ago
Edit Post #290882 Post edited:
Typo
over 1 year ago
Comment Post #290885 I don't use this feature, so I'll refrain from posting an answer. But there's a panel to the right "subscribe by email" where you can sign up and then supposedly it gets added to a list below your account -> Preferences -> Manage Email Subscriptions. Seems a bit crude though, I'm not sure if you can ...
(more)
over 1 year ago
Comment Post #290878 @#78383 Everything that's related to the actual trie implementation should sit alone in one .h/.c pair, without unrelated stuff like test cases and main(). You could also consider some manner of source code prefix for the public API functions, like for example having every function start with `trie_`...
(more)
over 1 year ago
Edit Post #290882 Post edited:
over 1 year ago
Edit Post #290882 Initial revision over 1 year ago
Answer A: Are there technical reasons to pick one struct coding style over the other?
Arguments in favour of "struct tag style": - Less namespace clutter. C has a peculiar name space system where all identifiers belong to one of: labels, tags, members, ordinary. Struct tag style only occupies a name in the tag name space. Meaning that struct tags will not collide with e...
(more)
over 1 year ago
Edit Post #290881 Initial revision over 1 year ago
Question Are there technical reasons to pick one struct coding style over the other?
C offers two different styles when it comes to structs (and union/enum too). Either declare them using a struct tag only ("struct tag style"): struct mytype { ... }; struct mytype x; Or by using a `typedef`, where the tag is optional ("typedef style"): typedef struct opt...
(more)
over 1 year ago
Edit Post #290878 Initial revision over 1 year ago
Answer A: Trie Implementation, Graph Visualization and Auto-Completion in C
General/program design: - I would have expected a public header file with the API for the whole thing, rather than having some main() test case calling `static` functions from the same file. Sure, this program is small, but having everything in a single file makes things less maintainable. - A ...
(more)
over 1 year ago
Comment Post #290316 @#53937 `stdin` is not necessarily a macro. C17 7.21.1: "`stdin` ... "which are expressions of type ‘‘pointer to FILE’’". You can't `#undef` expressions.
(more)
over 1 year ago
Comment Post #290488 Otherwise, I'm not opposed of having this migrated to Power Users if it fits better there.
(more)
over 1 year ago
Comment Post #290488 @#36396 Oh don't get me started on two factor authentication... it might just be the dumbest invention of this millennium. Chances of some mysterious hacker taking an interest in my little account at some site: non-existent. Chances of me misplacing/breaking/changing my phone: very high. I've alr...
(more)
over 1 year ago
Comment Post #290488 @#64277 I don't really see how anyone without software security knowledge would be able to answer this. It takes a programmer simply to understand the number of combinations enabled in the symbol table.
(more)
over 1 year ago
Edit Post #290488 Initial revision over 1 year ago
Question Are "strong passwords" at all meaningful?
Whenever registering to diverse sites on the net, you are often forced to enter a so called "strong password", which would ideally contain both upper case letters, lower case letters, digits, and some other character like punctuation. As hard to remember as possible. What I don't understand from a...
(more)
over 1 year ago
Comment Post #290316 On the other hand I don't understand the C rationale to make these macros either. If the intention was to allow evil things like `#ifdef stdin #undef stdin #endif #define stdin something_else` then it wouldn't be wise to use `stdin` as the name for the internal variable.
(more)
over 1 year ago
Comment Post #290316 As per your last code example, it would be fine for the library to name the variable `extern FILE *stdin;` and then do `#define stdin stdin`. This would still enable stuff like `#ifdef stdin` - it doesn't "flip off" any original intent. Why they didn't do that in the unknown standard lib mentioned, I...
(more)
over 1 year ago
Comment Post #290314 This requires digging into the specific library implementation - you don't mention which one - in search of a rationale or naming conventions. Without knowing that, the question cannot be answered. Though open source code bases in general tend to be quite irrationally written and do not necessarily f...
(more)
over 1 year ago
Comment Post #290215 @#53937 That's correct. The syntax for calling a function-like macro contains commas in itself so we can't pass comma operator arguments without surrounding the argument with parenthesis. The formal syntax is _identifier-list:_ which can either be _identifier_ or _identifier-list_ `,` _identifier_.
(more)
over 1 year ago
Edit Post #290223 Initial revision over 1 year ago
Answer A: When should I parenthesize macro arguments in C?
Simply put: parenthesis are used whenever we suspect that there may be operator precedence issues. - Either because the user passed an expression containing several operands and operators to the macro. To deal with this we need to surround the use of each macro parameter with parenthesis. ...
(more)
over 1 year ago
Edit Post #279576 Post edited:
over 1 year ago
Comment Post #290043 While questions about bash scripts are on-topic here, I think we expect such questions to mainly focus on the script itself, such as "here is my bash script for x, what's wrong with it." Maybe consider posting this at [Linux Systems](https://linux.codidact.com/) instead - I suspect it is a more suita...
(more)
over 1 year ago
Comment Post #290007 @#65944 If you have a "missing braces" bug, you can pretty much immediately tell if it was intentional, most often you got fooled by the indention. At the same time it is very hard to come up with a rationale for why you would _skip_ braces. ("I don't like typing" ought to be the worst rationale ever...
(more)
over 1 year ago
Comment Post #289415 I would guess that the gcc rationale is rather the one from 6.2.6.1 "When a value is stored in an object of structure or union type, including in a member object, the bytes of the object representation that correspond to any padding bytes take unspecified values.51)" Where the foot note says: "Thus,...
(more)
over 1 year ago
Comment Post #289415 @#53937 That seems like an unreasonable interpretation. The whole purpose of initializing something "as if it has static storage duration" with `{0}` is that the object may then potentially get allocated in .bss (rather than .data), which leads to faster initialization. Any implementation doing a sel...
(more)
over 1 year ago
Comment Post #290007 In fact the whole problem with SO's "opinion-based" close reasons is that they think that good program design is a matter of personal, subjective opinions. It is not that, it is not art. There are correct ways proven in use, such as object-orientation which has proven to be the best known way to desi...
(more)
over 1 year ago
Comment Post #290007 The point is that certain ways of writing programs are bad and it can be proven scientifically, beyond opinions and personal believes. You take a misbehaving program and track down the root cause. If you do that a million times on a million programs, bad practices emerge as hard evidence. For example...
(more)
over 1 year ago
Comment Post #278658 @#53937 That seems to be a common misconception. 6.3.2.3 always said "An integer constant expression with the value 0, or such an expression cast to type void *, is called a _null pointer constant_." With a foot note saying that NULL is a null pointer constant. What's implementation-defined about NUL...
(more)
over 1 year ago
Comment Post #289415 @#53937 Stop reading fishy blogs (JeanHeyd Meneide? he should know better) and instead read the mentioned part in C17 6.7.9 §10 (C23 6.7.10 §11) regarding implicit initialization of variables with static storage duration. It clearly states "if it is an aggregate, every member is initialized (recursiv...
(more)
over 1 year ago
Comment Post #281519 A rose by any other name... :) My post does mention `strlcpy` as an equivalent alternative though.
(more)
over 1 year ago
Comment Post #289415 And why should I care about some fiasco project for Linux made in the 90s where some open source people said "lets make _our_ way the standard way" then try to market that crap as some "standard for OS", while at the same time blatantly ignoring ISO C90 and every version of C ever released later. Als...
(more)
over 1 year ago
Comment Post #289415 @#53937 Please don't get me started on POSIX... POSIX isn't even compatible with conforming ISO C. A conforming implementation is not allowed to break the behavior of a strictly conforming program. By spewing non-standard identifiers inside standard headers, that's exactly what POSIX does. Which ...
(more)
over 1 year ago