Some remarks about poor programming practices... #191

Closed
hajikelist opened this Issue May 16, 2012 · 3 comments

3 participants

@hajikelist
        <?php 

        if($feed->get_link()) echo '<a href="' . $feed->get_link() . '">'; 

        echo $feed->get_title(); 

        if ($feed->get_link()) echo '</a>'; 

        ?>

What's wrong here is that you're calling a method three times (!) in order to achieve a result that can be determined by calling it once.
This whole approach is just strange to me, since the alternative is so much more efficient and simple... for example in this case:

        <?php 

        $link = $feed->get_link();
            $title = $feed->get_title();
        if($link) {
                $title = "<a href='$link' title='$title'>$title</a>"; 
        }    
        echo $title; 

        ?>

Not only is the code more efficient - it's far easier to visually parse and edit and the html being produced can be more beautifully/strictly formatted without headache.

Just my 2 cents...

@faceleg

I agree. @hajikelist why don't you fork, fix & commit the updates?

@hajikelist

ha ha. I would if my schedule were a little more relaxed. I feel compelled to address it across the board, perhaps I'll see if can squeeze it in...

@rmccue
SimplePie member

Unfortunately, I also have very little time, so if it ain't broke...

@ifsnop ifsnop added a commit to ifsnop/simplepie that referenced this issue Jul 20, 2012
@ifsnop ifsnop Issue #191 Some remarks about poor programming practices... 02c7359
@ifsnop ifsnop added a commit to ifsnop/simplepie that referenced this issue Jul 20, 2012
@ifsnop ifsnop Issue #191 Some remarks about poor programming practices... 4351107
@ifsnop ifsnop added a commit to ifsnop/simplepie that referenced this issue Jul 20, 2012
@ifsnop ifsnop Issue #191 Some remarks about poor programming practices... 01fdd97
@ifsnop ifsnop added a commit to ifsnop/simplepie that referenced this issue Jul 20, 2012
@ifsnop ifsnop Issue #191 Some remarks about poor programming practices... e370cf4
@ifsnop ifsnop added a commit to ifsnop/simplepie that referenced this issue Jul 20, 2012
@ifsnop ifsnop Issue #191 Some remarks about poor programming practices... 4e901d0
@ifsnop ifsnop added a commit to ifsnop/simplepie that referenced this issue Aug 27, 2012
@ifsnop ifsnop Issue #191 Style fixes... ad9fb15
@rmccue rmccue closed this in 7f138e3 Oct 11, 2012
@skyzyx skyzyx added a commit to skyzyx/simplepie that referenced this issue Nov 28, 2012
@ifsnop ifsnop Issue #191 Some remarks about poor programming practices... daa1f21
@skyzyx skyzyx added a commit to skyzyx/simplepie that referenced this issue Nov 28, 2012
@ifsnop ifsnop Issue #191 Some remarks about poor programming practices... c54eefc
@skyzyx skyzyx added a commit to skyzyx/simplepie that referenced this issue Nov 28, 2012
@ifsnop ifsnop Issue #191 Some remarks about poor programming practices... 9c4e4c8
@skyzyx skyzyx added a commit to skyzyx/simplepie that referenced this issue Nov 28, 2012
@ifsnop ifsnop Issue #191 Style fixes... cb44992
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment