Some of the code I wrote 10 years ago is as bad as Tony’s (No 9000 line classes, mind, but all the other stuff with mixed responsibilities, procedural code shoe-horned in to classes, global state, etc… however, I was 18 with no real formal training or experience!),…
Hah, this promises to be fun.
My first paid gig ever I was hired to write a event administration system. One of the requirements was to make the database exportable as a CSV file to a (rather massive) spreadsheet - so all the keys in the system had to be unique. My boss suggested I use MD5 hashes for keys.
About 4 months later hilarity ensues…
Everyone (not just Tom), what’s your comical, maybe even embarrassing story from your beginner days?
2 Likes
TomB
April 30, 2015, 1:09pm
2
I couldn’t remember anything particularly bad so had a quick look through my backup drive. I found this eiffel gem from 2003:
Some nice long nested if/elses, no separtion of concerns, the GUI code and the logic are 100% mixed and some wonderful law of demeter violations!
if db.stock.item(ref_no).copies.item(copies_list.selected_item.i_th(1)).is_for_part_time_students_only then
XD
I also found this Torque Script from a file dated 2002:
function randpart(which) {
this.num = int(random(1,10));
//this.num = 1;
//setcharprop #c,#v(this.num);
if (this.num == 1) {
this.xpos=0;
this.ypos=0;
}
elseif (this.num == 2) {
this.xpos=33;
this.ypos=0;
}
elseif (this.num == 3) {
this.xpos=66;
this.ypos=0;
}
elseif (this.num == 4) {
this.xpos=0;
this.ypos=33;
}
elseif (this.num == 5) {
this.xpos=33;
this.ypos=33;
}
elseif (this.num == 6) {
this.xpos=66;
this.ypos=33;
}
elseif (this.num == 7) {
this.xpos=0;
this.ypos=66;
}
elseif (this.num == 8) {
this.xpos=33;
this.ypos=66;
}
elseif (this.num == 9) {
this.xpos=66;
this.ypos=66;
}
if (which == 1) {
changeimgpart 10,this.xpos,this.ypos,32,32;
this.num1 = this.num;
}
elseif (which == 2) {
changeimgpart 11,this.xpos,this.ypos,32,32;
this.num2 = this.num;
}
elseif (which == 3) {
changeimgpart 12,this.xpos,this.ypos,32,32;
this.num3 = this.num;
}
}
Clearly I didn’t know about arrays at that point!
1 Like
I think it’s a primitive search function…
if (isset($_POST['q']))
{
$q = $_POST['q'];
}else{
// $q = "#"
};
$gallerytags = "imagegallery_tags";
$galleryphoto = "imagegallery_title";
$gallerydecade = "imagegallery_decade";
$con = mysql_connect("localhost","user","pass");
if (!$con){die('Could not connect: ' . mysql_error());}
mysql_select_db("db", $con);
$sentence = $q;
$sentence = strtoupper($sentence);
$words = explode(' ', $sentence);
//echo 'The sentence has ' . count($words) . ' words.<br />';
$finaltags = array();
$finalsearch = array();
$finaltags_asize = 0;
for ($i = 0; $i < count($words); $i++)
{
if($words[$i] <> 'THIS'){if($words[$i] <> 'AND'){
if($words[$i] <> 'WITH'){if($words[$i] <> 'AN'){
if($words[$i] <> 'A'){if($words[$i] <> 'HERE'){
if($words[$i] <> 'UNDER'){if($words[$i] <> 'NEAR'){if($words[$i] <> 'TO'){
if($words[$i] <> 'THERE'){if($words[$i] <> 'THAT'){if($words[$i] <> 'THE'){
if($words[$i] <> 'IN'){if($words[$i] <> 'OF'){
if($words[$i] <> 'IS'){if($words[$i] <> 'GET'){if($words[$i] <> 'FROM'){
if($words[$i] <> 'UP'){if($words[$i] <> 'SO'){
if($words[$i] <> 'WE'){ if($words[$i] <> 'CAN'){
if (in_array($words[$i], $finaltags)) {
//Debug Check if value in array
//echo "in array".$finaltags[$finaltags_asize]."<br/>";
$finaltags_asize = $finaltags_asize -1;
}else{
$finaltags[$finaltags_asize] = $words[$i];
$finaltags_asize = $finaltags_asize +1;
}}}}}}}}}}}}}}}}}}}}}}}
for ($gia = 0; $gia < $finaltags_asize; $gia++)
{
$sqla = mysql_query("SELECT * FROM imagegallery WHERE imagegallery_year ='".$q."' ORDER BY imagegallery");
}
$num_rows = mysql_num_rows($sqla);
$USER = $_SESSION['user']
?>
2005, red face
I wish Geocities didn’t disappear the way it did I had this weird thing were I would only code and comment in caps lol
system
Closed
August 1, 2015, 11:46am
5
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.