Arrays are overrated, let's use over9000 variables instead!
-
I just went in to fix a compatibility issue in some code and ran into this beautiful 27 lines long list of variables set to an empty string. Then the code has a loop going through the provided data, which has a list of if statements in it, of which you can probably guess the length. All but 5 or so of these ifs have duplicate code. After the loop all these variables are passed to a constructor, which holds another nice long list of if statements... Code: http://pastebin.com/uz3uMy0g[^] It's GPL v2, so do feel free to use it!
Jeroen De Dauw (blog | Twitter | Identi.ca)
modified on Sunday, June 5, 2011 10:42 AM
-
I just went in to fix a compatibility issue in some code and ran into this beautiful 27 lines long list of variables set to an empty string. Then the code has a loop going through the provided data, which has a list of if statements in it, of which you can probably guess the length. All but 5 or so of these ifs have duplicate code. After the loop all these variables are passed to a constructor, which holds another nice long list of if statements... Code: http://pastebin.com/uz3uMy0g[^] It's GPL v2, so do feel free to use it!
Jeroen De Dauw (blog | Twitter | Identi.ca)
modified on Sunday, June 5, 2011 10:42 AM
... art... it's art...
public function SMWBibTeXEntry( $type, $address, $annote, $author, $booktitle, $chapter, $crossref, $doi, $edition, $editor, $eprint, $howpublished, $institution, $journal, $key, $month, $note, $number, $organization, $pages, $publisher, $school, $series, $title, $url, $volume, $year ) { if ( $type ) $this->bibTeXtype = ucfirst( $type ); else $this->bibTeXtype = 'Book'; $fields = array(); if ( $address ) $fields['address'] = $address; if ( $annote ) $fields['annote'] = $annote; if ( $author ) $fields['author'] = $author; if ( $booktitle ) $fields['booktitle'] = $booktitle; if ( $chapter ) $fields['chapter'] = $chapter; if ( $crossref ) $fields['crossref'] = $crossref; if ( $doi ) $fields['doi'] = $doi; if ( $edition ) $fields['edition'] = $edition; if ( $editor ) $fields['editor'] = $editor; if ( $eprint ) $fields['eprint'] = $eprint; if ( $howpublished ) $fields['howpublished'] = $howpublished; if ( $institution ) $fields['institution'] = $institution; if ( $journal ) $fields['journal'] = $journal; if ( $key ) $fields['key'] = $key; if ( $month ) $fields['month'] = $month; if ( $note ) $fields['note'] = $note; if ( $number ) $fields['number'] = $number; if ( $organization ) $fields['organization'] = $organization; if ( $pages ) $fields['pages'] = $pages; if ( $publisher ) $fields['publisher'] = $publisher; if ( $school ) $fields['school'] = $school; if ( $series ) $fields['series'] = $series; if ( $title ) $fields['title'] = $title; if ( $url ) $fields['url'] = $url; if ( $volume ) $fields['volume'] = $volume; if ( $year ) $fields['year'] = $year; [...]
jep... it is...(yes|no|maybe)*
-
I just went in to fix a compatibility issue in some code and ran into this beautiful 27 lines long list of variables set to an empty string. Then the code has a loop going through the provided data, which has a list of if statements in it, of which you can probably guess the length. All but 5 or so of these ifs have duplicate code. After the loop all these variables are passed to a constructor, which holds another nice long list of if statements... Code: http://pastebin.com/uz3uMy0g[^] It's GPL v2, so do feel free to use it!
Jeroen De Dauw (blog | Twitter | Identi.ca)
modified on Sunday, June 5, 2011 10:42 AM
Ohh that makes my brain hurt. He uses arrays but cant pass an array. Either the language limits passing arrays or he is a moron. Let me just assume the answer to that and we will move on :)
Brad Barnhill