Click here to Skip to main content
15,890,947 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
Generalimplementing interface method, same signature, from two interfaces Pin
raddevus25-Apr-24 9:55
mvaraddevus25-Apr-24 9:55 
GeneralRe: implementing interface method, same signature, from two interfaces Pin
Jon McKee25-Apr-24 12:27
professionalJon McKee25-Apr-24 12:27 
GeneralRe: implementing interface method, same signature, from two interfaces Pin
Richard Deeming30-Apr-24 0:30
mveRichard Deeming30-Apr-24 0:30 
GeneralRe: implementing interface method, same signature, from two interfaces Pin
honey the codewitch17hrs 15mins ago
mvahoney the codewitch17hrs 15mins ago 
RantGiven enough eyeballs - a Sunday rant... Pin
Mircea Neacsu21-Apr-24 7:32
Mircea Neacsu21-Apr-24 7:32 
... after a frustrating week, this could be taken as a general rant at the quality of open-source software with applications to particular pieces.

Given enough eyeballs, where are those eyeballs looking? Surely not at libpng[^] - the reference implementation for the PNG format. It is a smallish library of about 20 kLOC but the configuration file with all the possible options has over 200 different options. That makes for 200x200 = 40k potentially different ways you could build the library. Either that or some of the options are redundant.

The code quality is atrocious. I understand that it's a project started in the '90es but that's no excuse for not cleaning it up from time to time. You cannot let one test program get to 12000 lines in a single file. And those 12000 lines are full of miracles like parameters and structure members called this! Don't you worry! At the beginning of the file there is this fragment:
C++
#ifdef __cplusplus
#  define this not_the_cpp_this
#  define new not_the_cpp_new
OMG | :OMG:

Also, if the byzantine compile time configuration options make it impossible for the program to run would you think of throwing an error using a #error directive? NO, good quality open-source code just wraps the whole program in an #if block with the #else clause, 12000 lines below:
C++
#else /* write or low level APIs not supported */
int main(void)
{
   fprintf(stderr,
      "pngvalid: no low level write support in libpng, all tests skipped\n");
   /* So the test is skipped: */
   return SKIP;
}
#endif
Remember: these are compile time conditions; why would you fail at run time?

Have you heard of semantic versioning? Well, check this out (straight from the LIBPNG) web site:
Quote:
At present, there are eight branches:

master (actively developed)
libpng16 (equivalent to master)
libpng17 (frozen, last updated on 2017-Sep-03)
libpng15 (frozen, last updated on 2017-Sep-28)
libpng14 (frozen, last updated on 2017-Sep-28)
libpng12 (frozen, last updated on 2017-Sep-28)
libpng10 (frozen, last updated on 2017-Aug-24)
libpng00 (frozen, last updated on 1998-Mar-08)
These translate in version numbers as 1.6.x, 1.7.x, 1.5.x, and so on. So, let me get this straight: version 1.7 is frozen and version 1.6 is actively developed? Have you guys ran out of numbers? And, guess what, in code you find many tests like these:
C++
#if PNG_LIBPNG_VER >= 10700
        if (!for_background && image->bit_depth < 8)
          image->bit_depth = image->sample_depth = 8;
#endif
???
I will stop here although, after a week of frustrations, I could go on and on.

There is a well-known commencement speech: Make your own bed - University of Texas at Austin 2014 Commencement Address - Admiral William H. McRaven - YouTube[^]. As a developer, and specially as an open-source maintainer, before writing a single line of new code, do everyone a favour: clean the project you are working on; make your own bed!
Mircea


modified 21-Apr-24 13:44pm.

GeneralRe: Given enough eyeballs - a Sunday rant... Pin
Greg Utas21-Apr-24 8:10
professionalGreg Utas21-Apr-24 8:10 
GeneralRe: Given enough eyeballs - a Sunday rant... Pin
Mircea Neacsu21-Apr-24 8:18
Mircea Neacsu21-Apr-24 8:18 
GeneralRe: Given enough eyeballs - a Sunday rant... Pin
Greg Utas21-Apr-24 10:11
professionalGreg Utas21-Apr-24 10:11 
GeneralCountry code Pin
PIEBALDconsult16-Apr-24 17:07
mvePIEBALDconsult16-Apr-24 17:07 
GeneralRe: Country code Pin
Peter_in_278016-Apr-24 17:50
professionalPeter_in_278016-Apr-24 17:50 
GeneralRe: Country code Pin
Jörgen Andersson16-Apr-24 20:15
professionalJörgen Andersson16-Apr-24 20:15 
GeneralRe: Country code Pin
snorkie17-Apr-24 2:40
professionalsnorkie17-Apr-24 2:40 
GeneralRe: Country code Pin
trønderen17-Apr-24 4:26
trønderen17-Apr-24 4:26 
GeneralSQL (Transact-SQL) needs a proper FOR loop! Pin
PIEBALDconsult1-Apr-24 17:30
mvePIEBALDconsult1-Apr-24 17:30 
GeneralRe: SQL (Transact-SQL) needs a proper FOR loop! Pin
#realJSOP2-Apr-24 9:07
mve#realJSOP2-Apr-24 9:07 
GeneralRe: SQL (Transact-SQL) needs a proper FOR loop! PinPopular
snorkie4-Apr-24 8:08
professionalsnorkie4-Apr-24 8:08 
GeneralRe: SQL (Transact-SQL) needs a proper FOR loop! Pin
PIEBALDconsult4-Apr-24 8:16
mvePIEBALDconsult4-Apr-24 8:16 
GeneralRe: SQL (Transact-SQL) needs a proper FOR loop! Pin
Sander Rossel8-Apr-24 1:11
professionalSander Rossel8-Apr-24 1:11 
GeneralRe: SQL (Transact-SQL) needs a proper FOR loop! Pin
PIEBALDconsult8-Apr-24 3:27
mvePIEBALDconsult8-Apr-24 3:27 
GeneralRe: SQL (Transact-SQL) needs a proper FOR loop! Pin
Sander Rossel10-Apr-24 4:29
professionalSander Rossel10-Apr-24 4:29 
GeneralRe: SQL (Transact-SQL) needs a proper FOR loop! Pin
GuyThiebaut8-Apr-24 23:53
professionalGuyThiebaut8-Apr-24 23:53 
GeneralRe: SQL (Transact-SQL) needs a proper FOR loop! Pin
Sander Rossel9-Apr-24 0:15
professionalSander Rossel9-Apr-24 0:15 
GeneralRe: SQL (Transact-SQL) needs a proper FOR loop! Pin
ChandraRam12-Apr-24 1:16
ChandraRam12-Apr-24 1:16 
GeneralRe: SQL (Transact-SQL) needs a proper FOR loop! Pin
honey the codewitch9-Apr-24 21:58
mvahoney the codewitch9-Apr-24 21:58 
GeneralRe: SQL (Transact-SQL) needs a proper FOR loop! Pin
jsc4210-Apr-24 0:24
professionaljsc4210-Apr-24 0:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.