• olaf (unregistered)

    Great idea if you need one ID per element and want your code to be CSS-compliant ;)

  • (cs)

    border:0px solid #A7A9AC;

    Invisible solid grey borders? The invisible pink unicorn would approve.

  • (cs)

    Surely TRWTF is PHP?

  • (cs)

    $FileClassArr versus $FileCLassArr

    • is PHP case-sensitive? Sometimes.
  • (cs) in reply to eViLegion
    eViLegion:
    border:0px solid #A7A9AC;

    Invisible solid grey borders? The invisible pink unicorn would approve.

    No, I didn't write this article. There's no unicorns.

  • (cs)

    PHP: Hosing Programmers

  • (cs) in reply to AndyCanfield

    Arr!

  • Missus (unregistered)

    Obviously this was an effort to allow future styling of the individual items. You know that shitty IE does not support the CSS nth-child selector, right? Also this code works with literally thousands of files, which would be very impractical if you'd have to write it by hand with child selectors.

    People on this site lack an understanding of what is required in the business. It's best to add such code from the start so that when you later want to refine the layout you can adjust the CSS with a select few PHP commands. I shall use this snippet in my lecture on design patterns to show our students how they can write reusable CSS with very little PHP thrown in. It is good to have an illustrating case that exemplifies the need for generated CSS.

  • (cs) in reply to Remy Porter
    Remy Porter:
    eViLegion:
    border:0px solid #A7A9AC;

    Invisible solid grey borders? The invisible pink unicorn would approve.

    No, I didn't write this article. There's no unicorns.

    They're invisible. And pink.

  • Ded (unregistered) in reply to AndyCanfield
    AndyCanfield:
    $FileClassArr versus $FileCLassArr

    That's why wrote

    FileCLassArr = $FileClassArr;

    on the first line, to evade this problem. This line must have been elided by the editor in an effort to make me look bad.

  • Dave (unregistered)

    Nah, can't really assess the WTFiness here without knowing what's actually in that array (telling us they're "files" is vague and probably misleading) and what the developer is trying to achieve. Have to admit it doesn't look promising all the same.

    Using a for rather than a foreach in this case is certainly wasteful though.

  • (cs)

    At least he didn't use the shorttag.

  • Papa Gujio (unregistered) in reply to lucidfox
    lucidfox:
    Surely TRWTF is not understanding why people use PHP?

    FTFY

  • (cs) in reply to Dave
    Dave:
    Nah, can't really assess the WTFiness here without knowing what's actually in that array (telling us they're "files" is vague and probably misleading) and what the developer is trying to achieve. Have to admit it doesn't look promising all the same.
    Even if what they're trying to achieve is not in itself a WTF, repeating the literal CSS for every class rather than
    .<?php echo implode($FileClassArr[$i], ', .') ?>
        {
            height:26px;
            float:left;
            background:url(../images/input2.png) left top no-repeat;
            width:188px;
            border:0px solid #A7A9AC;
            font-family:Arial; font-size:12px; color:#4a4a4a; font-weight:normal; text-align:left;
        }
    is definitely a WTF.
  • The Manager (unregistered) in reply to Papa Gujio
    Papa Gujio:
    lucidfox:
    Surely TRWTF is understanding why people still use PHP?

    FTFY

    FTFY

  • R (unregistered) in reply to eViLegion
    eViLegion:
    border:0px solid #A7A9AC;

    Invisible solid grey borders? The invisible pink unicorn would approve.

    Bah, everyone knows that the IPU is nothing but a fake monster, only The Flying Spagetti actually exists.

  • moz (unregistered) in reply to R
    R:
    eViLegion:
    border:0px solid #A7A9AC;

    Invisible solid grey borders? The invisible pink unicorn would approve.

    Bah, everyone knows that the IPU is nothing but a fake monster, only The Flying Spagetti actually exists.

    Colourless green ideas are quite angry at that suggestion.

  • Anon (unregistered)

    TRWTF is Arial.

  • warlaan (unregistered)

    I have to side with the original coder here.

    As we all know code duplication is bad, so they decided to copy the code using a loop, so that the core problem of code duplication is eliminated: if they now want to change all pages they only have to change the code in the loop.

    Way better than code duplication!

  • TheSoftwareDev (unregistered) in reply to Liquid Egg Product
    Liquid Egg Product:
    PHP: Hosing Programmers

    Recursive Acronym?

  • Smouch (unregistered)

    Having just experienced what some have assured me is good PHP CGI, I can declare that there is no such thing as good PHP CGI.

    Web development is a hopelessly confused mess, and anyone who thinks it's programming is dead wrong. It's nothing like programming, and calling it such is really detrimental to the art and science of programming.

  • emaNrouY-Here (unregistered)

    This developer surely missed his chance to increase his number of LOCs

  • Your mom (unregistered) in reply to Smouch

    Ohh, calm down mister fancy pants. Finish your books, clean up your room and get to bed. You have college tomorrow.

    And stop pretending you are do god damn smarter than everyone. Cause you'll never find a job.

  • (cs)

    Any takers for a bet on whether the classes are used like this?

    ...

    ... or that these classes aren't even used?

  • Ben Jammin (unregistered)

    Well, I was able to hold back the tears, barely. Then I saw some comments here siding with the original coder or imploding the array and the dam broke.

  • Ben Jammin (unregistered) in reply to Coyne
    Coyne:
    Any takers for a bet on whether the classes are used like this?
    ...

    ... or that these classes aren't even used?

    I would, but I'd probably end up crying more.

  • (cs) in reply to olaf
    olaf:
    Great idea if you need one ID per element and want your code to be CSS-compliant ;)

    This does give a clue as to its origin. I'll bet these CSS definitions were originally for id tags: #file_1, #file_2 and so on. Of course, these would have to be unique.

    So someone said to the author of this mess, "Why are you repeating this CSS for every ID? Why not use a CSS class?"

    So the author of this mess converted it to use classes...

    ...but why rewrite all that good code? Especially since we have to be able to control every element individually.

    Come on, you've all seen them: Those CSS books that recommend "id on every element"; CSS defined by "id"; and subtly dis-recommend classes because they can control multiple elements.

    You know, the books published by, "WTF Publishers".

  • (cs) in reply to Missus
    Missus:
    Obviously this was an effort to allow future styling of the individual items. You know that shitty IE does not support the CSS nth-child selector, right? Also this code works with literally thousands of files, which would be very impractical if you'd have to write it by hand with child selectors.

    People on this site lack an understanding of what is required in the business. It's best to add such code from the start so that when you later want to refine the layout you can adjust the CSS with a select few PHP commands. I shall use this snippet in my lecture on design patterns to show our students how they can write reusable CSS with very little PHP thrown in. It is good to have an illustrating case that exemplifies the need for generated CSS.

    9/10, would definitely read again.

  • Lars Vargas (unregistered)

    I'll point out there's a nice typo ($FileClassArr vs $FileCLassArr a couple lines later) that would make things even worse.

    I will also point out that PHP is not to blame here. Is could have been written this incompetently in any language.

  • Chris V (unregistered) in reply to Missus

    Either my sarcasm detector is malfunctioning, or you sir are a contributor to problem. The loop is going to generate the same CSS regardless of individual item. You're STILL going to have to manually add code to customize specific items. The submitted code does nothing toward your stated goal of allowing for customization of individual items; it simply generates a ton of wasted CSS for no particular reason.

  • (cs) in reply to Missus
    Missus:
    It is good to have an illustrating case that exemplifies the need for generated CSS.

    Any of the CSS preprocessors (less) can do this, without having to resort to php.

  • dolor (unregistered) in reply to eViLegion
    eViLegion:
    border:0px solid #A7A9AC;

    Invisible solid grey borders? The invisible pink unicorn would approve.

    I can't believe I am seeing this. 'Invisible pink unicorn'? Really? Are some so called adults still clinging to these outdated belief systems and fantasies?

    By now, I thought even children could tell you that invisible unicorns are clearly purple.

  • (cs) in reply to dolor
    dolor:
    eViLegion:
    border:0px solid #A7A9AC;

    Invisible solid grey borders? The invisible pink unicorn would approve.

    I can't believe I am seeing this. 'Invisible pink unicorn'? Really? Are some so called adults still clinging to these outdated belief systems and fantasies?

    By now, I thought even children could tell you that invisible unicorns are clearly purple.

    No, this one is pink. That's why she is special. Duh.

  • Publius (unregistered) in reply to Dave
    Dave:
    (telling us they're "files" is vague and probably misleading)

    "files" is not misleading. That's exactly what they are. Pictures of files on a tabletop.

  • (cs) in reply to Missus
    Missus:
    Obviously this was an effort to allow future styling of the individual items. You know that shitty IE does not support the CSS nth-child selector, right?

    Sadly, this unavoidable truth has forced me to decorate generic HTML widgets (like, say, a Tab Container) with CSS classes like this

       
    • First
    • Second
    • Third
    • Fourth

    in order to have semi-sane CSS rules.

  • (cs)

    PHP is the new Visual Basic.

  • OldCoder (unregistered) in reply to warlaan
    warlaan:
    I have to side with the original coder here.

    As we all know code duplication is bad, so they decided to copy the code using a loop, so that the core problem of code duplication is eliminated: if they now want to change all pages they only have to change the code in the loop.

    Way better than code duplication!

    Well, I'm not stupid enough to have learned PHP, so can somebody tell me: does PHP not have some kind of #include statement?

  • YourNam (unregistered)

    Looks like someone went to the Microsoft Office school of HTML.

    Seriously, do an HTML export of a bunch of bulleted lists in office 2007 or 2010, just about each and every element will have it's own stylesheet.

    That one was a royal pain to clean up. (regular expressions are my friend)

  • Pastafarian4life (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    dolor:
    eViLegion:
    Invisible solid grey borders? The invisible pink unicorn would approve.
    By now, I thought even children could tell you that invisible unicorns are clearly purple.
    No, this one is pink. That's why she is special. Duh.
    Ramen, brother.
  • Paul M (unregistered) in reply to Missus

    All of these files have the same style. There is no excuse for not defining a single class and having all the files use that.

    Note that every file will be importing the CSS for potentially hundreds of files (depending on how many we are talking about), only one block of which they actually need.

  • Anonymous (unregistered)

    TRWTF is the code missing a class for the FILE_NOT_FOUND.

  • Ronald (unregistered) in reply to lscharen
    lscharen:
    Missus:
    Obviously this was an effort to allow future styling of the individual items. You know that shitty IE does not support the CSS nth-child selector, right?

    Sadly, this unavoidable truth has forced me to decorate generic HTML widgets (like, say, a Tab Container) with CSS classes like this

       
    • First
    • Second
    • Third
    • Fourth

    in order to have semi-sane CSS rules.

    Do you really align attributes content when you write HTML? If so, I insist that you should also align the "tab-navbar" from the UL element. Otherwise it's not feng shui enough.

  • gizmore (unregistered)

    #my-comment:before { background: #bad; content:' Actually that's a good way to keep the appearance of your files flexible.

    I'd go one step further and create copies of the background image on the fly, just in case you want a different background image for one of the files. '; }

  • Stupid enough to have learned PHP (unregistered) in reply to OldCoder

    Nope, there are definitely plenty of includes getting thrown around.

  • (cs)

    What purpose is this going to server?

  • jay (unregistered) in reply to Remy Porter
    Remy Porter:
    eViLegion:
    border:0px solid #A7A9AC;

    Invisible solid grey borders? The invisible pink unicorn would approve.

    No, I didn't write this article. There's no unicorns.

    How can you be sure that there are no unicorns if they're invisible? "I didn't see any invisible unicorns." Well, duh.

  • jay (unregistered) in reply to Chris V
    Chris V:
    Either my sarcasm detector is malfunctioning, or you sir are a contributor to problem. The loop is going to generate the same CSS regardless of individual item. You're STILL going to have to manually add code to customize specific items. The submitted code does nothing toward your stated goal of allowing for customization of individual items; it simply generates a ton of wasted CSS for no particular reason.

    Reading this makes we wonder if the programmer was thinking that down the road he's going to modify the loop to say things like:

    if $i == 1 || $i == 3
      color: #3f7;
    else if $i == 9
      color: #b26; border-width: 2;
    else
      ... etc ...
    

    Then I cried, too.

  • (cs) in reply to YourNam
    YourNam:
    Looks like someone went to the Microsoft Office school of HTML.

    Seriously, do an HTML export of a bunch of bulleted lists in office 2007 or 2010, just about each and every element will have it's own stylesheet.

    That one was a royal pain to clean up. (regular expressions are my friend)

    Reminds me when we were starting out with moving our documentation web-wide. We generated simple html using a DEC VAX (it was a long time ago) and ftp'ed it into place on the website itself.

    Then the stupid clown who called herself development manager decided she wanted to contribute to the site. So she opened the html in Word, did her edits and saved it. Not only did it add shitloads of cruft, but it completely fucked up the careful formatting that we had lovingly designed.

    The good news is that it inoculated me against using Word.

  • misting down (unregistered)

    Why are you misting up? Are you wearing your glasses in a sauna?

  • noland (unregistered)

    This code needs improvement, not enterprisy enough!

    1. loop over filenames
    2. inside the loop assemble a filename pointing to a related XML-file per filename
    3. comment this line and assign a fixed value to this variable
    4. read the XML-file
    5. parse the XML
    6. compile CSS-code based on XML-values
    7. output the generated CSS-class
    8. exit the loop
    9. as an extra, you could prefix the XML-filename by the value of $_REQUEST["theme"] just after step 3, adding theming on the fly and expressing sympathy for script kiddies.

    Now, this is a powerful implementation!

Leave a comment on “A Cascade of Failure”

Log In or post as a guest

Replying to comment #:

« Return to Article