Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some remarks about poor programming practices... #191

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

Some remarks about poor programming practices... #191

hajikelist opened this issue May 16, 2012 · 3 comments

Comments

@hajikelist
Copy link

        <?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
Copy link

faceleg commented May 17, 2012

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

@hajikelist
Copy link
Author

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
Copy link
Contributor

rmccue commented May 18, 2012

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

ifsnop added a commit to ifsnop/simplepie that referenced this issue Jul 20, 2012
ifsnop added a commit to ifsnop/simplepie that referenced this issue Jul 20, 2012
ifsnop added a commit to ifsnop/simplepie that referenced this issue Jul 20, 2012
ifsnop added a commit to ifsnop/simplepie that referenced this issue Jul 20, 2012
ifsnop added a commit to ifsnop/simplepie that referenced this issue Jul 20, 2012
ifsnop added a commit to ifsnop/simplepie that referenced this issue Aug 27, 2012
@rmccue rmccue closed this as completed in 7f138e3 Oct 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants