php-general Digest 25 May 2012 12:39:00 -0000 Issue 7826

Topics (messages 317994 through 317997):

Re: Function size
        317994 by: Ashley Sheridan
        317997 by: Tedd Sperling

Simple XML, (x)html, and xpath
        317995 by: Gary
        317996 by: marco.behnke.biz

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On Thu, 2012-05-24 at 15:48 -0500, tamouse mailing lists wrote:

> On May 23, 2012 9:14 AM, "Tedd Sperling" <t...@sperling.com> wrote:
> >
> > Hi gang:
> >
> > On May 21, 2012, at 8:32 PM, tamouse mailing lists wrote:
> > >  A rule of thumb is no more than 50 lines per
> > > function, most much less. Back in the day when we didn't have nifty
> > > gui screens and an 24 line terminals (yay green on black!), if a
> > > function exceeded one printed page, it was deemed too long and marked
> > > for refactoring.
> >
> > You hit upon a theory of mine -- and that is our functions grow in size
> up to our ability to view them in their totality. When our functions get
> beyond that limit, we tend to refactor and reduce.
> >
> > I know from the last several decades of programming, my functions have
> increased in number of lines. But, they have reached a limit that limit is
> generally about the number of lines I can read in half of my monitor's
> height. This of course, is dependent on monitor resolution, font-size, and
> how far I am sitting from the monitor. But I think this is a natural and
> physical limit that we don't normally recognize. I can cite studies that
> support my theory.
> >
> > It would be an interesting survey to ask programmers to review their code
> and provide the average number of lines in their functions AND how many
> lines of code their monitor's can display. In other words, look at your
> editor; count the number of lines your monitor can display; estimate the
> number of lines in your average function; and report the findings.  For
> example, mine is about half -- my monitor can display 55 lines of code and
> my average function is around 25 lines. YMMV.
> >
> > Interesting, yes?
> >
> > Cheers,
> >
> > tedd
> >
> >
> > _____________________
> > tedd.sperl...@gmail.com
> > http://sperling.com
> >
> >
> >
> >
> >
> 
> Yes, I think that is *exactly* the criterion-- not a mystery or an emergent
> thing, really, was a pretty expicit reasoning--being able to see/scan the
> entire function on one page (or now in one screenful) makes it much easier
> to see what happens in the function, where blocks open/close, and it forces
> one to break up code into logical units.


With the odd exception being where code is more readable in a longer
format, as seen with my and several others examples of long functions
that rely heavily on switches. 

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On May 24, 2012, at 4:48 PM, tamouse mailing lists wrote:

> Yes, I think that is *exactly* the criterion-- not a mystery or an emergent 
> thing, really, was a pretty expicit reasoning--being able to see/scan the 
> entire function on one page (or now in one screenful) makes it much easier to 
> see what happens in the function, where blocks open/close, and it forces one 
> to break up code into logical units.

While it may be obvious to you, there is considerable study on the ways we 
perceive things -- this is just one we apparently take for granted ... at least 
now.

Cheers,

tedd


_____________________
t...@sperling.com
http://sperling.com


--- End Message ---
--- Begin Message ---
If I use simplexml_load_string to create an XML object with the
following XHTML
,----
| <?xml version="1.0"?>
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
| "http://www.w3.org/TR/
| xhtml1/DTD/xhtml1-strict.dtd">
| <html xmlns="http://www.w3.org/1999/xhtml";>
| <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
| />
| <title>test title</title>
| </head>
| <body>
| <!-- comment -->
| </body>
| </html>
`----

I get this SimpleXMLElement back
,----
| object(SimpleXMLElement)#1 (2) {
|   ["head"]=>
|   object(SimpleXMLElement)#2 (1) {
|     ["title"]=>
|     string(10) "test title"
|   }
|   ["body"]=>
|   object(SimpleXMLElement)#3 (1) {
|     ["comment"]=>
|     object(SimpleXMLElement)#4 (0) {
|     }
|   }
| }
`----

but I cannot seem to get anything out of an xpath expression, no matter
what I try.

If, however, I remove the 'xmlns="http://www.w3.org/1999/xhtml";' in the
html element, it works fine. So yeah, I can just remove that text,
but... is there something wrong here, in my expectation or in the xpath
function?

TIA.

-- 
Gary        Please do NOT send me 'courtesy' replies off-list.


--- End Message ---
--- Begin Message ---

Gary <listgj-phpgene...@yahoo.co.uk> hat am 25. Mai 2012 um 09:57
geschrieben:

> If I use simplexml_load_string to create an XML object with the
> following XHTML
> ,----
> | <?xml version="1.0"?>
> | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> | "http://www.w3.org/TR/
> | xhtml1/DTD/xhtml1-strict.dtd">
> | <html xmlns="http://www.w3.org/1999/xhtml";>
> | <head><meta http-equiv="Content-Type" content="text/html;
charset=UTF-8"
> | />
> | <title>test title</title>
> | </head>
> | <body>
> | <!-- comment -->
> | </body>
> | </html>
> `----
>
> I get this SimpleXMLElement back
> ,----
> | object(SimpleXMLElement)#1 (2) {
> |   ["head"]=>
> |   object(SimpleXMLElement)#2 (1) {
> |     ["title"]=>
> |     string(10) "test title"
> |   }
> |   ["body"]=>
> |   object(SimpleXMLElement)#3 (1) {
> |     ["comment"]=>
> |     object(SimpleXMLElement)#4 (0) {
> |     }
> |   }
> | }
> `----
>
> but I cannot seem to get anything out of an xpath expression, no matter
> what I try.
>
> If, however, I remove the 'xmlns="http://www.w3.org/1999/xhtml";' in the
> html element, it works fine. So yeah, I can just remove that text,
> but... is there something wrong here, in my expectation or in the xpath
> function?


Maybe you can show us your xpath expression?


>
> TIA.
>
> --
> Gary        Please do NOT send me 'courtesy' replies off-list.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

--- End Message ---

Reply via email to