Tuesday, November 11, 2008

Mentoring techniques

Yesterday while at work I was asked by a junior developer what type of data access layer my team is using on our project.  He was wondering about the use of data sets or business objects.  Do we use inline SQL or stored procedures.  So I sat with him and had a short conversation about his inquiries.  After he left, I got to thinking, I better go see what he's working on before he tries to kill a mosquito with a canon.  Good thing to.  His initiative on his application was to take some ideas from a data access layer that another senior developer had wrote, and try and improve on it.  I love the young sponges in the world.  They just want to learn, push their abilities, and absorb as much knowledge as they can.  But where do you draw the line with them?  The data access layer he was going to try and enhance was solid, and has pasted the test of time.  Its been implemented in several other applications as well.  I'm all for enhancing and trying to find a better way, but the path he was going down I was skeptical about.  It is my job after all to set him up for success.  So I worked through some scenarios with him.  I asked him how would you unit test your data layer?  Would it be easier to maintain your design, or the current design?  Does your design or the current design make more logical sense?  My goal with him was to try and get him to understand the challenges that he'll face instead of telling him to just do it this way and be bombarded with a series of "what if's" and "ya but's".  After he started to see the light, we talked about maybe some other technologies he could use instead of rolling his own data layer.  One technology we talked about was the use of the ADO.NET Entity Framework.  It basically builds the entire data layer for you, but its still cutting edge technology and maybe hasn't yet pasted the test of time yet.  What other techniques do you use?

Monday, September 15, 2008

Scientific Notation to Decimal

I recently had a situation come up where I needed to convert numeric data that was in scientific notation to a decimal. As an example I would receive a string that was in the form 1E-9. The decimal representation of this is 0.000000001. Seems simple enough.

string sVal = "1E-9";
decimal val = Convert.ToDecimal(sVal);

The above code fails because ToDecimal uses NumberStyles.Number which doesn't include the AllowExponent switch. You'll receive a FormatException exception that states the input string was not in a correct format. Use the following to convert to a decimal.

string sVal = "1E-9";
decimal val = 0M;

if(!Decimal.TryParse(sVal, NumberStyles.Float, NumberFormatInfo.InvariantInfo, out val))
val = 0M;

Jefferson

Friday, September 12, 2008

Mirra, Mirra, who's the fairest of them all.

I've always wanted a nice home office. Back in December we bought a new house and I finally had the opportunity to set up a nice home office. Now that my office is on its way to being a sanctuary of productivity, I needed a nice office chair to finish the package. I shopped all over for office chairs. The the major retailers, and online. None really fit what I wanted. I had bought cheep chairs before, and they only really last a couple of years and don't support your body the way it should be. Then I started a new job, and the chair they provided was a nice ergonomic chair. Its a Hon. I finally thought I found the chair. I searched down a local retailer and went into their show room to check them out. Turns out this retailer does sell Hon chairs, but they are primarily a Herman-Miller dealer. I never really sat in a Herman-Miller so I tried out the Herman-Miller Mirra. The fit was right. The support was there. But that much money, and I wasn't sure how it is sitting in front of my desk with it. The selling point, they let me take home a trial Mirra chair for two weeks before I bought. Wow...lets do it. When I got the Mirra home, I immediately put it in front of my desk and I was sold. Hands down it is the best chair out there. After my two weeks was up I returned the trial chair and ordered one of my very own. Its a small investment, mine was $710.00. But if you spend a lot of time at your desk, its worth the investment. The construction is solid, the support is second to none. And it has a 12 year warranty. That right there pays for itself. If you're serious about getting a nice chair check out the Mirra.

Sunday, July 27, 2008

Hello World

This is my first post. I've been meaning to start blogging, but never got around to setting one up. What was holding me up? Trying to find a meaningful name. Something catchy, easy to for readers to remember. What best fits what I want to write about. Something all encompassing. Well maybe not all encompassing, but close enough. I've been a computer programmer professionally now for about 7 years. The latest bit of technology I'm reading about is a Microsoft product called Linq (pronounced Link). Linq stands for Language Integrated Query. If you are not a programmer, you won't find this interesting at all. But if you are, and you don't know what Linq is, check it out. Its great. Basically its a way to interact with several types of data sources all in a very common way. Linq is very extensible, and several flavors of it have been popping up all over the web. Linq to SQL and Linq to Xml are apart of .NET 3.5. Linq to Amazon, Linq to Active Directory, Linq to Oracle, Linq to SAP, some very cool stuff here. It hit me one night, Linq 2 You. Thats what blogs are anyway. Scribing my thoughts, for the world to read. This blog is my Linq 2 you.

Thanks for joining me,

Jefferson