I put little "reminders" when I comment my code. Reminding myself what everything does...
Printable View
I put little "reminders" when I comment my code. Reminding myself what everything does...
When I do VB6, I always comment my stuff so when I look back in the future, I will think "wtf?" but then I look at comments XD
Ok I found some of my code at work yesterday that I wanted to share with you.
First of all this is a small tidbit of a script I wrote in Perl.
Second I love Perl, and I've always been pretty darn good at it despite its crazy possibilities of obfuscation. ^^
I've read lots of other peoples comments and some are really funny, you don't always have to be totally serious. I know anytime I read some old code with a nice witty comment I always appreciate it, but that doesn't mean they aren't useful.
Honestly myself and my Sys admin can read and understand this perfectly, of course it is extremely simple and if it was more complex I would use much better comments. So while I don't recommend this at your job, I thought someone might find it amusing. I personally was laughing hysterically when I wrote it and when I read it.Code:foreach $line (@filelines){
@splitline = split(/:/, $line);
$whoibe = $splitline[0];
if ($flinghash{$whoibe} == 1){
#then it is already in the hash foo
}
else{
#fling that puppy into the hash
$flinghash{$whoibe} = 1;
#bam add that spice
print FILE3 "$line";
}
Then i will also share with you some code from my word, it's a function wrote by the guy who worked on my place before me, well as you see there is not a single letter as a comment, also all other code looks similar and the only coments are like
And that's all for the 400 lines long class,PHP Code:<?php
class fooClass
{
function fooClass()
{
// this is a constructor
}
?>
And now the promised code.
PHP Code:function get_condition($jaki, $typ)
{
if($jaki==1 && $typ=='firma'){
if(isset($this->keys[$jaki][11]) && (($this->today<=$this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1))&&$this->keys[$jaki][2]=="MK" ){return array_push($this->abonament,2,2);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1) && $this->keys[$jaki][2]=="MK" ){return array_push($this->abonament,315,315);} else{ return array_push($this->abonament,2,2);}
}
if($jaki==2 && $typ=='firma'){
if(isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="FK"){array_push($this->abonament,4,4);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="FK"){array_push($this->abonament,316,316);}
else{array_push($this->abonament,4,4);}
}
if($jaki==3 && $typ=='firma'){
if(isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="CR"){array_push($this->abonament,6,6);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="CR"){array_push($this->abonament,317,317);}
else{array_push($this->abonament,6,6);}
}
if($jaki==4 && $typ=='firma'){
if( isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="ST"){array_push($this->abonament,8,8);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="ST"){array_push($this->abonament,318,318);}
else{array_push($this->abonament,8,8);}
}
if($jaki==5 && $typ=='firma'){
if( isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="LS"){array_push($this->abonament,14);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="LS"){array_push($this->abonament,320);}
else{array_push($this->abonament,14);}
}
if($jaki==6 && $typ=='firma'){
if(isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="EF"){array_push($this->abonament,12,12);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1) && $this->keys[$jaki][2]=="EF"){array_push($this->abonament,319,319);}
else{array_push($this->abonament,12,12);
}}
if($typ=='stowarzyszenie'){
if($jaki==1){
if(isset($this->keys[$jaki][11]) && (($this->today<=$this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1))&&$this->keys[$jaki][2]=="MK" ){return array_push($this->abonament,2);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1) && $this->keys[$jaki][2]=="MK" ){return array_push($this->abonament,321);} else{ return array_push($this->abonament,2);}
}
if($jaki==2){
if(isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="FK"){array_push($this->abonament,46);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="FK"){array_push($this->abonament,322);}
else{array_push($this->abonament,46);}
}
if($jaki==3){
if(isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="CR"){array_push($this->abonament,6);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="CR"){array_push($this->abonament,323);}
else{array_push($this->abonament,6);}
}
if($jaki==4){
if( isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="ST"){array_push($this->abonament,8);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="ST"){array_push($this->abonament,324);}
else{array_push($this->abonament,8);}
}
if($jaki==5){
if( isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="LS"){array_push($this->abonament,14);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="LS"){array_push($this->abonament,326);}
else{array_push($this->abonament,14);}
}
if($jaki==6 ){
if(isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="EF"){array_push($this->abonament,12);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1) && $this->keys[$jaki][2]=="EF"){array_push($this->abonament,325);}
else{array_push($this->abonament,12);
}}
}
if($typ=='biuro'){
if($jaki==1){
if(isset($this->keys[$jaki][11]) && (($this->today<=$this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1))&&$this->keys[$jaki][2]=="MK" ){return array_push($this->abonament,33);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1) && $this->keys[$jaki][2]=="MK" ){return array_push($this->abonament,327);} else{ return array_push($this->abonament,33);}
}
if($jaki==2){
if(isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="FK"){array_push($this->abonament,35);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="FK"){array_push($this->abonament,328);}
else{array_push($this->abonament,35);}
}
if($jaki==3){
if(isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="CR"){array_push($this->abonament,6);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="CR"){array_push($this->abonament,317);}
else{array_push($this->abonament,6);}
}
if($jaki==4){
if( isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="ST"){array_push($this->abonament,37);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="ST"){array_push($this->abonament,329);}
else{array_push($this->abonament,37);}
}
if($jaki==5){
if( isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="LS"){array_push($this->abonament,14);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="LS"){array_push($this->abonament,320);}
else{array_push($this->abonament,14);}
}
if($jaki==6 ){
if(isset($this->keys[$jaki][11]) && ($this->today<=$this->keys[$jaki][11] && $this->keys[$jaki][3]==1)&&$this->keys[$jaki][2]=="EF"){array_push($this->abonament,12);}
elseif(isset($this->keys[$jaki][11]) && ($this->keys[$jaki][3]==1) && $this->keys[$jaki][2]=="EF"){array_push($this->abonament,319);}
else{array_push($this->abonament,12);
}}
}
if($typ=='part_handl'){
}
}
I love your spaghetti code Danse ;)
i do not, there is a mistake somewhere and it's not a syntax one -.-
Wow, i see that function could give you quite a bit of trouble >.> That truely is spaghetti code.
A code like this does not make me laugh in any sense of humour. Especially it's not the only flower in CMS i must work on.