There's a nice article here on API design: http://nullprogram.com/blog/2018/06/10/
In BRL-CAD terms, this applies to many if not all of our library subsections (e.g., each separate file with related functions in BU/BN/BG).
there are still a lot of alloc's in bu/bn/bg/rt :-? i think 1 and 4 are pretty in line with the code base. lots of debug printing in the libs as well, but i don't see how else it could be done
maybe with a string buffer passed as argument, which is filled by the libs and printed by the caller :-?
another good read on solving linear equations in code: http://wordsandbuttons.online/programmers_introduction_to_linear_equations.html
there are still a lot of alloc's in bu/bn/bg/rt :-? i think 1 and 4 are pretty in line with the code base. lots of debug printing in the libs as well, but i don't see how else it could be done
yes, most of the modules (at least in bu) are few functions that work on a struct (e.g., bu_vls) .. but definitely not all of them
printing is a bit of a case by case as it depends on how the message is to be read and by whom -- if it's diagnostic/debug, the pattern we've been moving towards is only printing if an environment variable is set and removing all the debug options from userland. if it's to the user, that could be a string passed in (libged does this) or an application printing callback (mged/bu does this) or better eliminated and handled higher up via return status
There's a nice article here on API design: http://nullprogram.com/blog/2018/06/10/
The example in (4) contradicts (2).
haha, I noticed that too -- though to his credit, he says that too in the next sentence "this is difficult to pull off when the library doesn’t allocate its own memory" ... I guess one would pass an allocator or memory buffer in the "..." of the create function
another good read: https://uselessdevblog.wordpress.com/2018/06/24/why-we-all-choose-to-not-pay-back-tech-debt/
Last updated: Jan 09 2025 at 00:46 UTC