My comment was not about the CSS -- if you saw my earlier post, I actually
told the OP to never hardcode color/style if possible:

> -----Original Message-----
> Sent: Wednesday, October 03, 2007 12:58 PM
> 
> Add this to your default.css file... Or to the page...
> 
> <style>
> TR.dataRow1 { background-color: #e8f5f7; } /* light */
> TR.dataRow2 { background-color: #dce8ea; } /* dark */
> </style>
> 
> Then just do this:
> 
> <TR class='<?= ($r = !$r) ? "dataRow1" : "dataRow2" ?>' > 
> 
> Forget all that $i++ and (mod) % stuff...
> And NEVER hardcode the colors in the page. Use CSS !

What I was shocked at was the use of a class to do what takes not even an
entire line of code to accomplish. You realize that the object-oriented-ness
(word?) and the overhead of a class is silly right? Even calling a function
is slow. Something like alternating table rows generally is used when you
have lots of tabular data to show, therefore shaving off a few microseconds
here and there actually adds up. We have pages that render thousands of
rows, and if it takes 2 or 3 seconds less to show, that is significant and
noticeable.

I'm sure you were just trying to be funny or illustrate a point, but what
concerns me is that some people take OO WAY too far -- Ruby is an example.
Sometimes it is NOT the best way to implement something and is actually
detrimental. Since the OP seemed sorta newb, I fear that he would be
learning bad habits and not "get" that you were being facetious about the
PHP example...

Anyways, this is a dead horse.

D.Vin
http://daevid.com

> -----Original Message-----
> From: Robert Cummings [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, October 04, 2007 1:04 PM
> To: Daevid Vincent
> Cc: 'PHP eMail List'
> Subject: RE: [PHP] Alternate Colors in Rows
> 
> On Thu, 2007-10-04 at 12:28 -0700, Daevid Vincent wrote:
> > This was a joke right? You don't seriously do this in r.l. 
> just to alternate
> > row colors I hope? 
> 
> This certainly was NOT a joke. I do use CSS classes. As for 
> using a PHP
> class to implement the cycle-- No, I don't do that IRL. As I 
> said in my
> post:
> 
>     "I show a simple OOP example (because I felt like it)"
> 
> There's nothing wrong with using a class though. Some people like that
> kind of encapsulation.
> 
> If you're hung up on the use of CSS classes to do something simple.
> Imagine a site with hundreds of pages, many of which contain 
> tables with
> alternating row styling. By using classes, I've ensured a single
> location to update the way my rows are presented across the 
> entire site.
> I don't need to touch the markup or code to change how they look. This
> is how separation of markup and styling is supposed to work. If you
> didn't know that then you may need to go read about CSS. If 
> you thought
> you knew about CSS and still disagree, then you need to go 
> reread about
> CSS because you didn't absorb it properly the first time.
> 
> Cheers,
> Rob.
> -- 
> ...........................................................
> SwarmBuy.com - http://www.swarmbuy.com
> 
>     Leveraging the buying power of the masses!
> ...........................................................
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to