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
J

Jeroen De Dauw

@Jeroen De Dauw
About
Posts
110
Topics
21
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Is this bad or am I just picky?
    J Jeroen De Dauw

    Yep, PHP. Though some people consider this to be a horror on itself, that's not what I am getting at here :)

    Jeroen De Dauw (blog | Twitter | Identi.ca)

    The Weird and The Wonderful database data-structures debugging question code-review

  • Is this bad or am I just picky?
    J Jeroen De Dauw

    Came across this "class" during a code review. My reaction is pretty much "the fuck is this". Do you think this is good code or not?

    class Listalizer {

    public static function listalize( $convert, &$data ) {
        if ( is\_object( $data ) ) {
            try {
                $data = call\_user\_func( $convert, $data );
            } catch ( \\Exception $ex ) {
                try {
                    trigger\_error( "listalize: Callable " . self::callable2String( $convert )
                        . " caused an exception: " . $ex->getMessage(), E\_USER\_WARNING );
                } catch ( \\Exception $exx ) {
                    // Argh! We \*can't\* throw an exception!
                    $exx = (object)$exx; // this is just a breakpoint anchor.
                }
    
                $data = false;
            }
        }
    
        if ( is\_array( $data ) || $data instanceof \\ArrayObject ) {
            foreach ( $data as $key => &$value ) {
                self::listalize( $convert, $value );
            }
        }
    }
    
    public static function objectify( $convert, &$data, $role = null ) {
        if ( is\_array( $data ) ) {
            try {
                $data = call\_user\_func( $convert, $data, $role );
            } catch ( \\Exception $ex ) {
                try {
                    trigger\_error( "objectify: Callable " . self::callable2String( $convert )
                        . " caused an exception: " . $ex->getMessage(), E\_USER\_WARNING );
                } catch ( \\Exception $exx ) {
                    // Argh! We \*can't\* throw an exception!
                    $exx = (object)$exx; // this is just a breakpoint anchor.
                }
    
                $data = false;
            }
        }
    
        if ( is\_array( $data ) || $data instanceof \\ArrayObject ) {
            foreach ( $data as $key => &$value ) {
                self::objectify( $convert, $value, $key );
            }
        }
    }
    
    public static function callable2String( $callable ) {
        if ( is\_array( $callable ) && count( $callable ) === 1 ) {
            $callable = array\_pop( $callable );
        }
    
        if ( is\_string( $callable ) ) {
            return $callable;
        } elseif ( is\_object( $callable ) ) {
            return get\_class( $callable ) . '->\_\_invoke';
        } elseif ( is\_array( $callable ) ) {
            $target = $callable\[0\];
    
    The Weird and The Wonderful database data-structures debugging question code-review

  • The Code Repeater
    J Jeroen De Dauw

    You should commend them! Seriously, this is good work. If you consider that most people touching code are idiots, it's always good to duplicate code around, so that if someone messes up one copy, only a small part of your app gets broken, rather then the whole thing.

    Jeroen De Dauw (blog | Twitter | Identi.ca)

    The Weird and The Wonderful question

  • ISP hacked
    J Jeroen De Dauw

    One free interwebs, you just won it! :)

    Jeroen De Dauw (blog | Twitter | Identi.ca)

    The Weird and The Wonderful com tutorial

  • How to Train Your Programmer
    J Jeroen De Dauw

    He forgot to wrap each line in a try catch block! o_O

    Jeroen De Dauw (blog | Twitter | Identi.ca)

    The Weird and The Wonderful tutorial

  • Do you not understand booleans?
    J Jeroen De Dauw

    A true classic. I got thought to not do this first weeks in programming class, before learning stuff like functions.

    Jeroen De Dauw (blog | Twitter | Identi.ca)

    The Weird and The Wonderful data-structures question announcement

  • Do you not understand booleans?
    J Jeroen De Dauw

    Believe it or not, but my high school teacher recommended doing this "because it's more clear". I was the only one ignoring that and only got flak for it.

    Jeroen De Dauw (blog | Twitter | Identi.ca)

    The Weird and The Wonderful data-structures question announcement

  • A bad Case of comparison
    J Jeroen De Dauw

    #1, if you start counting at the first number.

    Jeroen De Dauw (blog | Twitter | Identi.ca)

    The Weird and The Wonderful database performance question lounge

  • The Perfect Loop
    J Jeroen De Dauw

    Why is he copying the code?! He could just call the function this stuff is in again, and have it be properly recursive as a bonus.

    Jeroen De Dauw (blog | Twitter | Identi.ca)

    The Weird and The Wonderful collaboration code-review

  • To Self-Close the BR or Not to Close the BR
    J Jeroen De Dauw

    Oh, it still works when omitting the opening tag? Cool, then I can omit that one in my code and have faster page loading!

    Jeroen De Dauw (blog | Twitter | Identi.ca)

    The Weird and The Wonderful question

  • Another coding horror
    J Jeroen De Dauw

    If it's the real name, it's a bigger horror then the relatively small mistake of redirecting to the wrong page...

    Jeroen De Dauw (blog | Twitter | Identi.ca)

    The Weird and The Wonderful

  • Arrays are overrated, let's use over9000 variables instead!
    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

    The Weird and The Wonderful help com

  • code for browser
    J Jeroen De Dauw

    #doingitwrong

    Jeroen De Dauw (blog | Twitter | Identi.ca)

    The Weird and The Wonderful com

  • The perfect teacher
    J Jeroen De Dauw

    How else would students learn to deal with crappy code? When they graduate, the crappy teacher will just be replaced by a crappy boss and crappy colleagues :)

    Jeroen De Dauw (blog | Twitter | Identi.ca)

    The Weird and The Wonderful csharp java visual-studio tutorial question

  • Javascript sleep
    J Jeroen De Dauw

    :omg: yeah :)

    Jeroen De Dauw
    Blog ; Wiki

    The Weird and The Wonderful javascript com

  • Javascript sleep
    J Jeroen De Dauw

    Presumably the intention is to suspend the thread and not hog the CPU, in which case you should use setTimeout.

    Jeroen De Dauw
    Blog ; Wiki

    The Weird and The Wonderful javascript com

  • Step Right Up, Get Yer Session 'ere
    J Jeroen De Dauw

    CSV is actually a great example of how not to design a text-based data format. UNIX-style DSV is much more sane, and there colon is the default separator. So I wouldn't make fun of using colons to delimiter values, even though the rest of the code is horrible.

    Jeroen De Dauw
    Blog ; Wiki

    The Weird and The Wonderful asp-net csharp javascript database com

  • Unnecessary Commented Code
    J Jeroen De Dauw

    Someone give them a git or svn already, srysly >_>

    Jeroen De Dauw
    Blog ; Wiki

    The Weird and The Wonderful sharepoint database tutorial

  • seeing a student code
    J Jeroen De Dauw

    Bleh. Can I nominate how the whole database connection crap works in .Net as horror? I really don't like it...

    Jeroen De Dauw
    Blog ; Wiki

    The Weird and The Wonderful database security

  • Regitration Activation Mail
    J Jeroen De Dauw

    I've actually never seen this; I guess I'm lucky to avoid such crappy sites :D Have seen an admin panel that only check if the user existed though... (and not if it's an admin, or even the password is correct) >_>

    Jeroen De Dauw
    Blog ; Wiki

    The Weird and The Wonderful com lounge
  • Login

  • Don't have an account? Register

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