<?
package MetarTools
;

use 
5.005;
use 
strict;
use 
vars qw($VERSION);

$VERSION '0.1';

# define weather types
my @wx_types qw(MI PI BC DR BL SH TS FZ DZ RA SN SG IC PE GR GS UP BR FG FU VA DU SA HZ PY PO SQ FC SS DS);
my $wx_pat join "|",@wx_types;

# define cloud condition types
my @sky_types qw(CLR SKC FEW SCT BKN OVC VV);
my $sky_pat join "|", @sky_types;

sub convertLST {
    eval { require 
Date::Calc };
    if ($@) { die 
"Date::Calc module required for time conversions\n" }

    
my $self shift;
    
my ($yr$mo$tz) = @_;
    
$tz = -6 unless $tz;
    
my @roundUTC;
    
my @roundLST;
    
my ($round,$dy,$hr,$mn,$hr_ampm,$ampm);
    
my @utc;
    
my @lst;

    if (!
defined($self->{DAY})) { $self->processDatetime() }
    if (
defined($self->{DAY})) {
        
$dy $self->{DAY};
        
$hr $self->{HOUR};
        
$mn $self->{MINUTE};

        @
utc = ($yr,$mo,$dy,$hr,$mn,0);

        @
lst Date::Calc::Add_Delta_DHMS(@utc,0,$tz,0,0);

        if (
$lst[3] == 0) { $hr_ampm 12$ampm 'am' }
        
elsif ($lst[3] == 12) { $ampm 'pm' }
        
elsif ($lst[3] > 12) { $hr_ampm $lst[3] - 12$ampm 'pm' }
        else { 
$hr_ampm $lst[3] ; $ampm 'am' }
        
$ampm "$hr_ampm:$mn$ampm";

        
$self->{DATE_LST} = sprintf("%4d%02d%02d %02d:%02d",@lst[0..4]);
        
$self->{YEAR_LST} = $lst[0];
        
$self->{MONTH_LST} = $lst[1];
        
$self->{DAY_LST} = $lst[2];
        
$self->{HOUR_LST} = $lst[3];
        
$self->{MINUTE_LST} = $lst[4];
        
$self->{TIME_LST} = sprintf "%d:%02d"$lst[3],$lst[4];
        
$self->{TIME_LST_ENGLISH} = $ampm;

        if (
$mn >= 45) { 
            @
roundUTC Date::Calc::Add_Delta_DHMS(@utc[0..3],0,0,0,1,0,0);
            @
roundLST Date::Calc::Add_Delta_DHMS(@lst[0..3],0,0,0,1,0,0);
            
$round++;
        }
        
elsif ($mn 15) {
            @
roundUTC = (@utc[0..3],0,0);
            @
roundLST = (@lst[0..3],0,0);
            
$round++;
        }
        if (
$round) {
            if (
$roundUTC[2] == 0) { $hr_ampm 12$ampm 'am' }
            
elsif ($roundUTC[2] == 12) { $ampm 'pm' }
            
elsif ($roundUTC[2] > 12) { $hr_ampm $roundUTC[2] - 12$ampm 'pm' }
            else { 
$hr_ampm $roundUTC[2] ; $ampm 'am' }
            
$ampm "$hr_ampm:00$ampm";

            
$self->{DATE_UTC_ROUND} = sprintf("%4d%02d%02d %02d:%02d",@roundUTC[0..4]);
            
$self->{YEAR_UTC_ROUND} = $roundUTC[0];
            
$self->{MONTH_UTC_ROUND} = $roundUTC[1];
            
$self->{DAY_UTC_ROUND} = $roundUTC[1];
            
$self->{HOUR_UTC_ROUND} = $roundUTC[2];
            
$self->{TIME_UTC_ROUND} = "$roundUTC[2]:00";
            
$self->{TIME_UTC_ROUND_ENGLISH} = $ampm;

            if (
$roundLST[2] == 0) { $hr_ampm 12$ampm 'am' }
            
elsif ($roundLST[2] == 12) { $ampm 'pm' }
            
elsif ($roundLST[2] > 12) { $hr_ampm $roundLST[2] - 12$ampm 'pm' }
            else { 
$hr_ampm $roundLST[2] ; $ampm 'am' }
            
$ampm "$hr_ampm:00$ampm";
            
            
$self->{DATE_LST_ROUND} = sprintf("%4d%02d%02d %02d:%02d",@roundLST[0..4]);
            
$self->{YEAR_LST_ROUND} = $roundLST[0];
            
$self->{MONTH_LST_ROUND} = $roundLST[1];
            
$self->{DAY_LST_ROUND} = $roundLST[1];
            
$self->{HOUR_LST_ROUND} = $roundLST[2];
            
$self->{TIME_LST_ROUND} = "$roundLST[2]:00";
            
$self->{TIME_LST_ROUND_ENGLISH} = $ampm;
        }
    }
}
?>
<?
class some_shity_php4_class {

    function 
some_random_method() {
        
$this dont_do_this_ever_horrible_practice;
    }

}
?>
stupid porgramming - TranceAddict Forums

Become a part of the TranceAddict community!Frequently Asked Questions - Please read this if you haven'tSearch the forums
TranceAddict Forums > Other > Technology & Gadget Zone > stupid porgramming
  Last Thread   Next Thread
Share
Author
Thread    Post A Reply
malek
drinks your milkshake!



Registered: Nov 2001
Location: Montréal
Sad stupid porgramming

I have to maintain software and some of the code I see is heart braking... its bad really bad.

If you have examples of your own, please post


example 1:


start = 1
if (start > 1) then
... code
else
... code
end if


example 2:

if (a > 0 )
...if (b > 0)
.......code
.......x = 2
...else
.......code
.......x = 2
...end if
else
...if (c > 0)
.......code
.......x = 2
...else
.......code
.......x = 2
end if


___________________
[/IMG]http://i54.tinypic.com/ngycqo.png[/IMG]

Old Post Apr-13-2007 15:01 
Click Here to See the Profile for malek Click here to Send malek a Private Message Visit malek's homepage! Add malek to your buddy list Report this Post Reply w/Quote Edit/Delete Message
_Nut_
North x NorthWest



Registered: Nov 2001
Location: 61.105423,-149.723555

PHP:




All part of a METAR reading subroutine. This is about 1% of it, and I just found an issue in the LST conversion... boo urns. broken

Old Post Apr-13-2007 16:23 
Click Here to See the Profile for _Nut_ Click here to Send _Nut_ a Private Message Add _Nut_ to your buddy list Report this Post Reply w/Quote Edit/Delete Message
winnowingfan51
Guest



Registered: Not Yet
Location:

PHP:







Yea... in our CMS that we use, the guy that wrote it assigned $this to something else. SERIOUSLY WTF?!

Old Post Apr-15-2007 23:57 
Add  to your buddy list Report this Post Reply w/Quote Edit/Delete Message
LeopoldStotch
Suapremae tranecadictt



Registered: Jan 2005
Location: Yawbs,Giaks,and Automobiles

seriously, i have seen this before at work.

code:
a=true; i=0; while(a == true) { i++; if (i>0) a = true; }


___________________

Old Post Apr-16-2007 01:39  United States
Click Here to See the Profile for LeopoldStotch Click here to Send LeopoldStotch a Private Message Visit LeopoldStotch's homepage! Add LeopoldStotch to your buddy list Report this Post Reply w/Quote Edit/Delete Message
witchsabbath258
Guest



Registered: Not Yet
Location:

quote:
Originally posted by LeopoldStotch
seriously, i have seen this before at work.

code:
a=true; i=0; while(a == true) { i++; if (i>0) a = true; }



Thats almost as bad as this.


code:
some_psuedo_function { if(x == 0) { return x; } else { //continue } }



Though technically its bad practice to have a return anywhere but the last statement (at least thats what I been told ).

Also I guess you could be checking something for x and then doing something special if it doesnt meet the return value or something, I dont know.

Over complexity.

Old Post Apr-16-2007 02:39 
Add  to your buddy list Report this Post Reply w/Quote Edit/Delete Message
LeopoldStotch
Suapremae tranecadictt



Registered: Jan 2005
Location: Yawbs,Giaks,and Automobiles

quote:
Originally posted by witchsabbath258
Thats almost as bad as this.


code:
some_psuedo_function { if(x == 0) { return x; } else { //continue } }



Though technically its bad practice to have a return anywhere but the last statement (at least thats what I been told ).

Also I guess you could be checking something for x and then doing something special if it doesnt meet the return value or something, I dont know.

Over complexity.


you are right, however i have been in many companies with many people touching the CVS, and i have learned the "less" changes, the better. i have seen that before, and i have also seen this.

code:
some_pseudo_function { if (x ==0) return x; //continue }


where everyone knows once the prog executes the return, it pops out of the function. bad programming practices, but sometimes the "less is more" philosophy works.


___________________

Old Post Apr-16-2007 03:06  United States
Click Here to See the Profile for LeopoldStotch Click here to Send LeopoldStotch a Private Message Visit LeopoldStotch's homepage! Add LeopoldStotch to your buddy list Report this Post Reply w/Quote Edit/Delete Message
malek
drinks your milkshake!



Registered: Nov 2001
Location: Montréal

quote:
Originally posted by LeopoldStotch
seriously, i have seen this before at work.

code:
a=true; i=0; while(a == true) { i++; if (i>0) a = true; }


wow


___________________
[/IMG]http://i54.tinypic.com/ngycqo.png[/IMG]

Old Post Apr-16-2007 05:42 
Click Here to See the Profile for malek Click here to Send malek a Private Message Visit malek's homepage! Add malek to your buddy list Report this Post Reply w/Quote Edit/Delete Message
Dr. Cfire
Supreme tranceaddict



Registered: Apr 2003
Location: Calgary

How about bad variable names.
In one function the idiot assigned these variables

Torque
torque
Ratio
ratio1
Maintorque
mainTorque

Old Post May-04-2007 03:56  Canada
Click Here to See the Profile for Dr. Cfire Click here to Send Dr. Cfire a Private Message Add Dr. Cfire to your buddy list Report this Post Reply w/Quote Edit/Delete Message
LeopoldStotch
Suapremae tranecadictt



Registered: Jan 2005
Location: Yawbs,Giaks,and Automobiles

quote:
Originally posted by Dr. Cfire
How about bad variable names.
In one function the idiot assigned these variables

Torque
torque
Ratio
ratio1
Maintorque
mainTorque


someone told me this quote ... "if you find yourself F3ing a lot, then the person who wrote the program sucks at naming variables" (he was referencing the F3 function to "goto variable decleration" in eclipse).


___________________

Old Post May-07-2007 02:05  United States
Click Here to See the Profile for LeopoldStotch Click here to Send LeopoldStotch a Private Message Visit LeopoldStotch's homepage! Add LeopoldStotch to your buddy list Report this Post Reply w/Quote Edit/Delete Message

TranceAddict Forums > Other > Technology & Gadget Zone > stupid porgramming
Post New Thread    Post A Reply

 
Last Thread   Next Thread
Click here to listen to the sample!Pause playback-=Champ_21=- Unknown song 1 [2005] [0]

Click here to listen to the sample!Pause playbackDJ Ladida - "Lifemaster" (Mundo EP) [2003]

Show Printable Version | Subscribe to this Thread
Forum Jump:

All times are GMT. The time now is 20:56.

Forum Rules:
You may not post new threads
You may not post replies
You may not edit your posts
HTML code is ON
vB code is ON
[IMG] code is ON
 
Search this Thread:

 
Contact Us - return to tranceaddict

Powered by: Trance Music & vBulletin Forums
Copyright ©2000-2026, Jelsoft Enterprises Ltd.
Privacy Statement / DMCA
Support TA!