Saturday, March 12, 2005

I know, I haven't posted in awhile. Work has been very hetic, with big deadlines for one of the biggest projects my departments has even done. So with big deadlines looming, it is really easy to let some code that is less than perfect slip through the cracks. Less then perfect code would be something that, while it works as in it doesn't have memory leaks or anything like that, just doesn't subscribe to good design patterns and practices. So why is the post titled "Learn Bad Code". Well, you need to learn to recognize when you've written bad code. Actually it needs to bother you when you've written bad code, or are using code that someone else's. It should bother you so much that you get up in the middle of the night to fix it. How do you do that? Well there is a couple of ways.

First learn the right way to right code. Learn to use N-Tier design structures. If your application is connecting to a database, your presentation layer should have no idea what kind of database it is. It shouldn't even matter. Your should write a data layer, that takes care of all of those things, and handles the data off to the business layer in a generic way. The business layer can then pass the data to the presentation layer in a generic, or more correctly abstracted way. I'm not the first one that has ever said this, in fact most developer, well .NET, C++ and Java developer work this way.

The second way, look at bad code. Hopefully it isn't your own bad code but someone else. At work we go to http://thedailywtf.com/ everyday. Here are examples of bad code posted daily and discussed. Don't get me wrong this code works, but it works in the most convoluted way possible. The other thing that comes from reading this daily as a group is the threat factor. Yes, I have threatened people in my team with posting their bad code, and vise versa. Let's face it, none of us wants laughed at for being a lazy programmer.

Let's go back the first method for a moment. Like I said earlier, there has been a lot written on how to write a N-Tier application, I'm going give you a practical example of why. I'll start by telling you a little bit about my team at work. There are three of us, including myself. Which makes each person's role very important. We have the Front-End Web Developer, The .NET Developer and me The Senior Web Developer. Our Front-End Developer works on the User Interface, design and things like that, he is an Expert in HTML and can do amazing things with it, yet he is new to ASP.NET and .NET in general. Our .NET Developer is a back-end programmers, programmer. He does all of the Database work, the stored procedures, the data layer stuff and so on. Then there is me, I do a lot of the architecture and design, as well as writing the business logic with our .NET Developer, and Front-End design with our Front-End Web Developer. So you can see by the way the team is structure that we are set up in to an N-Tier architecture. Okay, with that being said, why, is the N-Tier important to us?

One of the reasons why a N-Tier architecture is important to us is flexibility. Let's say, hypothetically, the company decides that Oracle is the way to go and that all of our applications have to be converted to use Oracle as it's database. Of course we had written all of our appliations for Microsoft SQL. Well with the N-Tier design model, we just change our data layer (or data access layer, which ever you like to call it), and we are in business. We didn't have to change the presentation layer (web page, or windows app front end) or our business layer (business logic) to accommodate the change because we wrote the application in such a way that those two layers were abstracted from the database. Simply put, they didn't care able the database, because they never knew it was there.

Another reasons why a N-Tier architecture is important to us is knowledge. My team is really diverse in their knowledge, so I can't expect them to all know the same thing. I wouldn't expect my Front-End Developer to write stored procedures, just as I wouldn't expect my .NET Developer to create photoshop comps of web pages. With the N-Tier architecture in place, the Front-End Developer doesn't have to know ADO.NET, or SQL. He just calls the business object and can intellisense his way though the fields without having to ask about them. Adversely, my .NET Developer doesn't have to sort through the ASP.NET code to firgure out where to try and put some inline SQL. And this touches on our third reason, speed. Now with both of the Developers, (Front-End and Back-End) doing what they do best, they aren't slowed down by trying to figure out how to do each other's job. They don't have to deal with the speed bumps of code.

In the end Learning what "bad code" looks like keeps you from writing it, just as much as learning what "good code" looks like helps you write flexible applications.

 

3/12/2005 1:01:35 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Thursday, March 10, 2005
 
###########################################################################
##########################################################################W
##########################################################################W
W#########################################################################W
W##########################################WW##W##########################W
W#########################################WWWWW#W#########################W
###################################################WW#####################W
#######################################WMMW###WW###WM#####################W
W#######################################WWWWW##W####WWW###################W
##########################################W#WW############################W
###########################WWW##########W##WWWWW#W######W#################W
W##########################WWW############WWMMMMWWW###################WBM#W
##########################################WMMMMMMWW####################BB#M
##########################################WWWMMBBM########################W
W#############################################WWMMW#######################W
W################################################WMWW#####################W
W#########################W#######################W#WW####################W
##########################W############WWWMBBBMWWW###WWW############WW####W
W#####################################WBRXVYYYVVBBBW###W#W#######WWWWMW###W
###########################W###MWW###WBXYIttttIIYYVRBMW#WWW######WW#WWW###W
W##########################WMBRXYVRBRVItttittttItIYVVXBMWWW###WW#WWW#WW###W
###########################BXVYIttYYIti++iiiittttIIYYVXRMW#W##WW#WWWWWW####
#########################WMRYIIttttttii+tiiiiitttttIIYYYRW#####WW########WM
########################WBRVIItttittiiii+ii++iiitttIIIIYVM#W##WWW########BR
W#######################MBXVIIttttiiii++++++++iitttIIIIYVBMWWWW#W#########W
W######################WBRXYIIttttttii+++++==++iitttIIIIYRMMMWW###########W
#######################MBRXYItttttitti+++++==+++itttttIYYRBMMW######WWWW##W
W######################WBXVYItttttttti+++i++++iiittittIYIYXRBW#####WWWMMW#W
#######################WBXVIIIttttttti+iititittittttttIIYIYXRM#####WWMMWW#W
#######################WBVYYIItttttttiiitttttttiittIIItIIIIIVB#####WWWWWW#W
W######################WRVYIIIIttttttiitittttttitttIIIIIIIIIYRW####WWW#WW#W
W######################MRXVYIIIItItttiittttiiiiittttIIIIIIIYIYRW###WW##WW#W
#######################BRXYYIIIIttttttttititiiittIYYYIIIIIIIIIVB#W#WMW##W#W
#######################BRVVYYIItttttttitttiittttIYVVVVYYYYIIIIYRWWWWWMMW##W
######################WBRXVYItttttttiii+ittIYYYYVYVVXXRRXYIIIIYXW#WWMMW###W
W#####################WBBXVVYYIIIIttii++ttIYVVYYIIIIYYXXXVYIIYYXW#WMBM#MW##
######################MBBRRRRXVVYYIItii+tIYYIIti++ttIIYYYIIIIIYXW#WMW#BVVW#
W#####################MMMBBBRRXVYVYYItttIIIIItttttItIIIYIIIYYIYXMWWMWBYtYRW
######################WMWMRXVYYYYYVVYIIIIIItIYXXVRVVYYYYIttYYIIVRMMMRItIYIB
######################WWWBVItttIIYVXVItIIYIIVXBBVBVRBBRYtiitIYIYRMMMV+tVI+R
######################MWWXIIIYVVXVYXYIIIYIIYXVVXXYIYVVYIt++tIIIYXBWBtitYI+X
W#####################MRBRVRBMMXRRXRVItIYYYYYIIIi+iitttIIttttIYYVRWBtttIY+V
####################W#MXVRMMBBRXVVVXYttIYYYYIIIt+++iiiittttttIIYYRBRttItI+V
####################RBMVIRBRVYYIItYXYIIIYYYIIIIt+++ttttiiitIIYYYVXRVtItttiR
####################RRBYIVVYIItttIVRYIIIYYIIItIttttttttttitIIIYYVXXVIi++iIB
W###################WMRYIYYYIItIIIVRVIIIYIIIIttttttttttttttIIIYYYXRVt+=itYM
######################RYVYYYIIIIIYXRVYIYYYIItittIttttttttttIIYYYYXRVti+tIRW
######################RXXYYIIYIIIYXXYItIYVYIi+++i+i++iiitttIIYVVYVXVYIItYBW
W#####################BXVYIIIItItIVXYIIIYVVYti++i++=++iitttIIYVYYVRXYIIIYWW
#####################WRXVIIttttttIXVIi+tIYVYYIiti+===++ittIIIYVVYVXXIiIYV#W
W####################WRXVIttttiiiYXVt++tIYIIYIttti+==+iittIIIIYVVVXXt+IYB#W
#####################WRRYIttii+itYXVt+iIYYIIYIittti+++iittttIIYVVVXXIitVW#W
W#####################BXYItti+ittYXVYIIIVYYYYItiItt+++ittttItIYVVVRRIIYM##W
######################BXYIIt+iittYXXXVYYIIYYIIt+tttti+tttttttIIYVVXRtIB###W
W#####################MXYIIttittIYVXVYYYIttIIIItitttt+iittittIIYVVXXIV####W
######################MXVIItttttIYVVYIIIttiitIIttiittititiiitIIYVVRXYW####W
######################MXXVIttItIIYYYYtiiti+iitttttiiti+iiiitttIYVXRXB######
######################WXVVYIItIIYYYIIItt+itttIIIYIIti++i+iiittIYVXRRM#####W
W#####################WXYYYIttIIIYYYYYYIttIIYYVVXVYIi++++itittIYVRRBW#####W
W######################XYIIIttItYXRXVVYYIIIYYYYYIIti+=+++iiittIIVRRM######W
W######################RYIIIttttVRBXYYYYYYYYYYIIttti+=+++itittIYXRRW#######
W######################BVIIIttttIVRXVYIIttitttttttti+=++iiiitIIVXRBW######W
W######################MVIIIItitIYXXVItitiiitiiitii++++iiiiitIYVRRRW######W
W######################WVYIIIt+ttIVYYIIItt+iii+tiiii+++ii++tIIYXRRBW######W
W#######################BIYYIttitIYYItttttii++ii+i++++++itttIYVRRRRM######W
W#######################MYIYIItttIYIIttIItti+++++ii+++++iittIYXRRRRM######W
########################WXYYYItttIIIttIIYIItii+++ii++iiiitttYVRRXRRW######W
#########################BVIYIttIIIttIIIIIIIttttii+++iittttIYXRXXXRM######W
##########################BYYYIIIIIIYYYItttItIItIt+iiittttIYYXRVXXRM######W
W#########################WXYYYYIIYYYYIttittttIIIttittttttIYXXXVVVXM######W
###########################BVYYYYYVVYItti+iiitIIIItttttttIIVXXVVVVXM######W
W##########################WXYYYVVXVYItti++ittIItIItitttIIYVXVYYVVXM######W
############################MVYYVVVVYItiiitiitItIIIItItIIIYVVVYYIVXRM#####W
W############################BVVVVXVYIIttttttIItIIItIIIIIYVVVYYYYYXY;Y####W
W############################WRVVVXVYIIItIIIIItIIIttIIIIIVVVVYIIYYVX+;I###W
##############################BXVXVVYYIIIItItIttIIIIIIIIYVVYYYIIIYXXi;=tW#W
W###########################WRRRXVVVYYItttttttItIIIIYIYYYVYYYIIIIIYRI+=;IWM
W##########W##W#W########WWWXtYBXXVVYIIIttiiitIIIIYYYYYYYVYIIttIIYYXXYI+=RB
#####WWWWWWWWWWWWWWWWWWWWWWXi;YMRXVVYYIItttttIIIIIYYYYYYYYIIttttIIYXVVVI;IB
W##WWWWWWWWWWWWWWWWWWWWWWWWt;=YBBRVVVYIIIttIIIIIIIIYIYYYYIIttttttIYYYYYt;tB
MWWWWWWWWWWWWWWWWWWWWWWWWWB=;+VRBRXVVYYYIIIIIIIIIIIIIIIIIttittttIIIIYYY+;VM
MWWWWWWWWWWWWWWWWWWWWW#WW#X;;iVRRRXXVVYYIIIIIIIIIIIIIIIIIttttttttIIIIYI;+BB
MWWWWMWWWWWWWWWWWWWWWWWWWWt;;tXRXXRXVVYYYIIIIIIItIttIIItttttitttttIIII+;VWB
MWWWWMWMWWWWWWWWWWWWW#WWWMi;;tXXXXXVVYYIIIIIIIttttttItti+iiiiiitIitttt+YMMB
MWWWWMWWMWWWWWWWWWWWWWWWWWt:;iXXXVVVVYIIIttttttitttttti+++++iititItttiYMWMB
MWWWWMWWWWWWWWWWWWWW#WWWWWY:;iVXVVYYYYYIIttttiiiittii+++++++iitittttiYBMMMB
MWWWMWWMWWWWWWMMWWWWW#WWW#B+:+Y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MMMMMMMMMMMMMMMMMMMMMMMMBMMBMMMMMMMMMBBMMMMMMMBMBMMMMMMMMMMMMMB
BMMMMMMWMMMWMMMMMMMMMMMMMMMMMMMMMMMBMMMMBMMMMMMMBBMBMMMMBBMBMMBMMMMMMMMMMMB
BMMMWMWWMMWMMMMMMMMMMMMMMMMMMMMMMBBMMMMMMMMMMMMMMMMMMBBMBBBMBMMBMMMMMMMMMMB
BMMMMMWWWMMWWMMMMMMMMMMMMMMMMMMMMMBMMMMBMMMMMBMMBMMMMBMBMBBMMMMMMMMMMMMMBMB
BMMMMMWWMMMMMMMMMMMMMMMMMMBMMMBBMMBMMMMMMMMMMBBBMMBBBBMBMBBMBMMMMMMMBBMMMMB
BMWWMMWMMMMMMMMMMMMMMMMMMBMMMBBMMMBMMMMMBMMMBMBBMMBBBBBMBBMMBMMMBMBMBMMMBMB
BMMMMMMMMMWMMMMMMMMMMMMMMBMMMBMMMBMMMMBBMMMBBBMMMMBBBMMBMBMMMBMBMMMMBMMMMMB
BMMMMMMMMMWMMMMMMMMMMMBMMMBMMMBMMBMMMMBBMMMBBBMMBBBMMBMBBBMMMMMBMBMBMMBBMMB
BMMMMMMMMMMMMMMMMMMMMMMMMMBMMBMMMBBMMMMBBMMBBBMBBBBBBBBMBBMMMBMMBBMMMMMMMMB
 
This is was created by a fun little utility that converts any jpeg in to "ascii" Art!
3/10/2005 8:51:22 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Monday, March 07, 2005
Today I learned that Kids know how things should work. Today the Little Boy was using a cellphone (yes the 4 year old was using a cellphone, don't pretend like you haven't handed one to your youngin' )and he wanted to show the person he was talking too what he just got, so he pointed the phone at the object and and said "See". Now Really this is how it should work. It's 2005 we don't have cars that fly, so we should at least have cellphones that have video conferencing built in.
3/7/2005 6:56:00 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Friday, March 04, 2005

Every morning I tell myself the same thing. As I pour one of my asthma pills out of its bottle I say, or think to myself, "Don't take the big pill!" You see, that particular medication can't be exposed to humidity till taken, so they have one of those little cylinders that keep packaged goods dry. Well, it is a little larger in diameter then the regular pill, and abou three times taller, so every morning, in my sleepy state I have to make sure that I take the right pill.  I said it again this morning, and my Beautiful Wife heard, she commented, "you say that allot don't you", to which I replied, "yup everyday"

3/4/2005 8:14:54 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Wednesday, February 23, 2005

First, I think it really says something about the state of things, that this evening I learned my Sister got injuried from her blog. Not a phone call, not an email, not even a voicemail, but by reading her blog. That being said she has carried on a fine family tradition. The tradition of course is completely down playing injuries and emergencies. You see she was sewing, to make a long story short she had the needle stab her in the finger and break off. Of course if that wasn't bad enough, the machine tried to keep going and really crushed her finger. What did she scream? What words of anger or panic came from her lips? None! That's right in the family tradition she just freed herself with her free hand, cleaned the wound and then went and told Mom.

Now this is just something we do. We don't yell or cry or cuss we just either let out a little growl or say something very subtle. An example of this, when I was fourteen, through a series of unfortunate events I managed to set the entire hallway floor on fire.  Flames are about three feet high and all along the floor, so did I scream, or cry or going running out the door? Of course not, I went and got Mom and sais "Mom, we have a problem". Of course the statement was completely true, but maybe just a little subtle for the Event.

Another example, my Brother J was framing up some walls, and we heard a misfire and a "errrr". Now anyone else we would think, that he was upset that they had a misfired, but in my family it means something happened. So we ran into the room were he working, he turned towards us with his thumb, in the cool Fonzie, "Aaaaa" position. We see that the nail went right through his thumb. So Dad without missing a beat, grabed his linemans pilers, grabed Js hand, and goes for the nail. Brother J was afraid that he was going to take his whole thumb off, and at the last second, Dad turns his hand and cuts the head of the nail off. Well, now the nail had to come out, and it has to go through, you can't back them out. So of course Dad says on the count of three. One, Two (now we know that Dad is going to pull it on two, he's been doing it since we were little kids), but just in case brother J braces for it on one. It was on two, and nail was out. And the only thing that J says is " I thought you were going to cut my thumb off".

Yet another example, Brother K is doing some framing, a making rip strips for fering out the walls. Well, as happens from time to time, the blade on the table saw reached up and bite him. Right on the top of his index finger. Of course in typical family style, he let out a growl. Well, J knew that it  was a "I am hurt bad come help me" growl. Anyone else would have wondered if he kicked a board or something. K, in typical K style, went down to the first aid kit and with the help of J, and bandaged up the finger so well that most medical professions would marveled at his handy work.

Family traditions, you have to love'em 

2/23/2005 9:18:33 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Tuesday, February 22, 2005
Okay, so driving would of been faster today. I usually wouldn't say anything remotely like that, but apparently because of the heavy rains, the trains can't go over 40 mph. Of course right now, we are currently not going over 4 mph since we are stopped. I left work at 4:40 and it's 6:35, and we are at least 20 minutes away from my station, if we start going right now  which we won't. So I am sitting on the train, listening to techno/celtic music (yes it does exist) and bloggin, what else is a poor commuter to do.
2/22/2005 6:38:28 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]

So, I've finally done it. I went out and bought a digital camera. Of course this feat didn't happen without lots of homework, research and agony. I am sure that I drove my Beautiful Wife up the wall with this one. But of course in her wonderful way she answered my barrage of questions with her sweet, your a silly man, but  I love you anyway. So what did I get? Well I got a Panasonic Lumix FZ20s. Okay, what's a Panasonic Lumix FZ20s. Well, it is a cool looking silver camera. (silver is what the s stands for). It is a 5.3 megapixel camera with a Lecia 12x optical zoom lense. The 35mm equivalent lense would be 36mm-432mm. Overall it is a really nice camera. Instead of writing a long review (which I am not very good at), here is one by steves-digicams.com

I do have to say so far I am really happy with it, and it lets me do almost everything that my old Pentax spotmatic does. Of course being a digital camera, it does have the whole instant gratification of seeing the photo right after it is taken thing going for it. So between the new camera, and the images I've been taking lately, I figured it was finally time to start a photoblog. We'll see if my hectic work schedule will allow me keep both my blog and it going.

2/22/2005 6:22:54 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]