Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Arrays are overrated, let's use over9000 variables instead!

Arrays are overrated, let's use over9000 variables instead!

Scheduled Pinned Locked Moved The Weird and The Wonderful
helpcom
3 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jeroen De Dauw
    wrote on last edited by
    #1

    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

    S B 2 Replies Last reply
    0
    • J Jeroen De Dauw

      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

      S Offline
      S Offline
      StM0n
      wrote on last edited by
      #2

      ... 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)*

      1 Reply Last reply
      0
      • J Jeroen De Dauw

        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

        B Offline
        B Offline
        Brad Barnhill
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups