Today I was going through some code that we use for this site and found this.

if( $this->disp_params['show_recently'] )
        {
            echo $this->disp_params['item_start'];
            echo '<strong><a href="'.$Blog->get('url').'">'.T_('Recently').'</a></strong>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_search'] )
        {
            echo $this->disp_params['item_start'];
            echo '<strong><a href="'.$Blog->get('searchurl').'">'.T_('Search').'</a></strong>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_postidx'] )
        {
            echo $this->disp_params['item_start'];
            echo '<strong><a href="'.$Blog->get('postidxurl').'">'.T_('Post index').'</a></strong>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_archives'] )
        {
            // fp> TODO: don't display this if archives plugin not installed... or depluginize archives (I'm not sure)
            echo $this->disp_params['item_start'];
            echo '<strong><a href="'.$Blog->get('arcdirurl').'">'.T_('Archives').'</a></strong>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_categories'] )
        {
            echo $this->disp_params['item_start'];
            echo '<strong><a href="'.$Blog->get('catdirurl').'">'.T_('Categories').'</a></strong>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_mediaidx'] )
        {
            echo $this->disp_params['item_start'];
            echo '<strong><a href="'.$Blog->get('mediaidxurl').'">'.T_('Photo index').'</a></strong>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_latestcomments'] )
        {
            echo $this->disp_params['item_start'];
            echo '<strong><a href="'.$Blog->get('lastcommentsurl').'">'.T_('Latest comments').'</a></strong>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_owneruserinfo'] )
        {
            echo $this->disp_params['item_start'];
            echo '<strong><a href="'.$Blog->get('userurl').'">'.T_('Owner details').'</a></strong>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_ownercontact'] && $url = $Blog->get_contact_url( true ) )
        {   // owner allows contact:
            echo $this->disp_params['item_start'];
            echo '<strong><a href="'.$url.'">'.T_('Contact').'</a></strong>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_sitemap'] )
        {
            echo $this->disp_params['item_start'];
            echo '<strong><a href="'.$Blog->get('sitemapurl').'">'.T_('Site map').'</a></strong>';
            echo $this->disp_params['item_end'];
        }

And what I needed was this.

if( $this->disp_params['show_recently'] )
        {
            echo $this->disp_params['item_start'];
            echo '<a href="'.$Blog->get('url').'">'.T_('Recently').'</a>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_search'] )
        {
            echo $this->disp_params['item_start'];
            echo '<a href="'.$Blog->get('searchurl').'">'.T_('Search').'</a>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_postidx'] )
        {
            echo $this->disp_params['item_start'];
            echo '<a href="'.$Blog->get('postidxurl').'">'.T_('Post index').'</a>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_archives'] )
        {
            // fp> TODO: don't display this if archives plugin not installed... or depluginize archives (I'm not sure)
            echo $this->disp_params['item_start'];
            echo '<a href="'.$Blog->get('arcdirurl').'">'.T_('Archives').'</a>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_categories'] )
        {
            echo $this->disp_params['item_start'];
            echo '<a href="'.$Blog->get('catdirurl').'">'.T_('Categories').'</a>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_mediaidx'] )
        {
            echo $this->disp_params['item_start'];
            echo '<a href="'.$Blog->get('mediaidxurl').'">'.T_('Photo index').'</a>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_latestcomments'] )
        {
            echo $this->disp_params['item_start'];
            echo '<a href="'.$Blog->get('lastcommentsurl').'">'.T_('Latest comments').'</a>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_owneruserinfo'] )
        {
            echo $this->disp_params['item_start'];
            echo '<a href="'.$Blog->get('userurl').'">'.T_('Owner details').'</a>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_ownercontact'] && $url = $Blog->get_contact_url( true ) )
        {   // owner allows contact:
            echo $this->disp_params['item_start'];
            echo '<a href="'.$url.'">'.T_('Contact').'</a>';
            echo $this->disp_params['item_end'];
        }
 
        if( $this->disp_params['show_sitemap'] )
        {
            echo $this->disp_params['item_start'];
            echo '<a href="'.$Blog->get('sitemapurl').'">'.T_('Site map').'</a>';
            echo $this->disp_params['item_end'];
        }

That’s right, I just had to remove all the strong-tags.

And I was like, really? Did the person that wrote that not think before writting, was he not lazy enough? Was he to lazy to write an extra method and make it eassier to maintain?

Perhaps the person that wrote this thought it did the job and moved on, and he was right. But he did not think someone else was going to read and have to maintain his code.

So next time you write something like this, remember this. I will come after you and find you and slowly kill you. Remember me.

BTW coding for reuse in mind is always a good thing untill you discover that your reuse libraries have become bigger than the application you are going to need it in and that application will only use 5% of the library, thus adding bloat to your application.

It is always difficult to know when to write for reuse (being DRY) and when to give up and just do some things twice. I guess experience is the only way how you can learn such things. The biggest problem is that you don’t know what the future will bring. Because if a user says they ain’t gonna need it today, he might just change his mind … 10 minutes later.