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
Comment Post #289121 Just save a bookmark... On a decent browser like Firefox, you can drag bookmarks to a top panel so that they become buttons, accessible with a single mouse click or a few key strokes (Ctrl+B then type). What's the problem...
(more)
3 days ago
Comment Post #291479 If SE managed anything, it was to finally and irrevocably kill the myth "there are no bad questions". 10+ years of SE experience rather shows that "there are some questions which are not bad". And that's not really elitism or high standards: as an utter bare minimum of communication with other humans...
(more)
4 days ago
Comment Post #291463 @#82306 This is standard practice for critical systems. See for example MISRA C:2023 chapter 8.2 complete with sources and rationales - this in turn is derived from safety standards like IEC 61508 and DO-178. Now of course most code out there isn't mission-critical, but when you look at these standar...
(more)
6 days ago
Edit Post #291463 Initial revision 6 days ago
Answer A: Testing an opaque type's internals
- "Black box testing" makes sense when dealing with opaque types so that's the first thing you should be doing and probably the most meaningful test too, so that's where you should put most of your efforts. But that's not what you are asking about here. - Some philosophies like TDD would encourage...
(more)
6 days ago
Comment Post #291460 typedef struct followed by the struct definition means the struct cannot be opaque because the typedef identifier is only visible to the translation unit it is located in. You have to forward declare the struct in the header and then define it using the struct tag.
(more)
6 days ago
Comment Post #291404 The correct way to solve your actual problem is most likely with proper program design. Avoid preprocessor conditionals and use inheritance instead. "Widget without foobar" is either the parent or the child of the class "Widget with foobar". One could be abstract if it makes sense, or implement an em...
(more)
7 days ago
Edit Post #291119 Post edited:
20 days ago
Comment Post #291371 Except the application layer programmer typically won't have a clue about how the various containers are implemented internally. Which has always been a big problem with C++, `std::string` or `std::vector` silently using heap allocation etc. And if you don't know how they are implemented, you can't k...
(more)
20 days ago
Comment Post #291371 It's the same kind of argument as why computer scientists are _still_ being all smug about binary search over brute force linear iteration, even though in many situations, the latter is probably way faster on modern computers. Algorithm theory has not quite kept up with computer hardware development ...
(more)
20 days ago
Comment Post #291371 Now of course, the standard doesn't mandate how things are implemented "backstage". There's probably no good performance reason why a lot of things like `std::set` or `std::map` wouldn't be implemented as some sort of C style arrays. Namely because on most systems, arrays have superior performance fo...
(more)
20 days ago
Comment Post #291342 Hi there. As per the current scope of this site https://software.codidact.com/help/on-topic, embedded systems questions are off-topic and should be asked on https://electrical.codidact.com/ instead. But before posting there, your question should ideally be self-contained, as in don't link an entire G...
(more)
25 days ago
Edit Post #291342 Question closed 25 days ago
Comment Post #291310 Some would probably disagree and saying that "pointers are dangerous". However, if the programmer can't even write correct code for iterating over a linear sequence of data, then what correct code _can_ they write... It way easier to write than to implement some manner of iteration template monstrosi...
(more)
about 1 month ago
Comment Post #291310 The language design mistake from there was to enforce this unison iterator interface to all classes, even those that do not benefit from it what-so-ever. That's poor OO design of the language itself - proper OO would distinct from containers which are "linear" and those who aren't. There's no reason ...
(more)
about 1 month ago
Comment Post #291310 "However, while writing this code, I couldn't help but notice that I am essentially writing a wrapper around pointer arithmetic." Indeed. When writing C++, one often comes to the conclusion "WTF am I even doing, this is nothing but bloated meta programming". In many cases, an `iterator` is nothing b...
(more)
about 1 month ago
Edit Post #291249 Post edited:
about 1 month ago
Edit Post #291249 Initial revision about 1 month ago
Answer A: Can I access an array element from a pointer to an object contiguous with but outside the array?
The problem with undefined behavior due to array out of bounds happens whenever we use pointer arithmetic, which is only defined to work within the bounds of an array. Where plain variables, "scalars", are defined to behave just the same as arrays of 1 item, as far as pointer arithmetic is concerned....
(more)
about 1 month ago
Comment Post #291199 @#78383 The header is the exposed part to the caller so you could write documentation there regarding how to tweak them. The caller shouldn't mess with the .c file. Optionally you could have the memory pool itself take these as input parameters to an init function. But most often we want the size to ...
(more)
about 2 months ago
Comment Post #281518 @#80520 Then you might agree with the posted answer... "memcpy is always preferred when you know the size in advance. It's always faster than strcpy. It is safe and portable."
(more)
about 2 months ago
Comment Post #291199 @#80468 Start with the OO design. What use-cases are there and what makes sense to turn into classes? Is "door" a central thing to your application, to the point where it needs an abstraction layer. Or do you rather benefit of having abstraction layers on a much lower level, just above the ADC or GPI...
(more)
about 2 months ago
Edit Post #291199 Post edited:
about 2 months ago
Comment Post #291195 I know that I'm the one who lead you here, but just a note for the future that embedded systems programming questions normally goes to https://electrical.codidact.com/. But your question is all about software design and without much in the way of embedded systems aspects (save for how to allocate obj...
(more)
about 2 months ago
Edit Post #291199 Initial revision about 2 months ago
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 2 months ago
Edit Post #291195 Post edited:
about 2 months ago
Edit Post #291196 Post edited:
about 2 months ago
Edit Post #291196 Post edited:
about 2 months ago
Edit Post #291196 Initial revision about 2 months 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 2 months 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 2 months 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 2 months ago
Edit Post #281519 Post edited:
Added note about memccpy
about 2 months 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 2 months ago
Edit Post #291119 Initial revision about 2 months 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 2 months 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 2 months ago
Edit Post #291074 Initial revision 2 months 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)
2 months ago
Edit Post #290882 Post edited:
3 months ago
Edit Post #290882 Post edited:
Typo
3 months 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)
3 months 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)
3 months ago
Edit Post #290882 Post edited:
3 months ago
Edit Post #290882 Initial revision 3 months 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)
3 months ago
Edit Post #290881 Initial revision 3 months 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)
3 months ago
Edit Post #290878 Initial revision 3 months ago