Saturday, May 17, 2014

C# In Depth this weekend

My copy of Jon Skeet's book arrived on Friday, and I must say, I'm only 15 pages in and am finding tons of stuff I wish I was already using! Lambda's are awesome...

Thursday, May 15, 2014

What causes variables to change? A Software Newbie Story.

As a newbie software developer I was always tripped up about the concept of assigning a value or reference to a variable. I'd notice that sometimes the variable value changes automatically if some events happens, while other times, it never does. I knew the basic concept of value vs reference that I had learned in school, but had never really applied it (and knew that I had applied it!). Then, I ran into a few problems where my variable would change without reason (seemingly), and questioned the basic concepts of variables.

Little did I know that a variable that is a reference type (and assigned an actual reference to an object) will change if other related objects change. For example, the value of a DataGridViewCell variable will change if you re-fill the dataset. However, a row index assigned to a value type (i.e. integer) will never change without you directly re-assigning it. It's an interesting concept that honestly still trips me up sometimes.

Anyway - A random story for ya.

Wednesday, May 14, 2014

Calling a CLICK METHOD from another method!

You know what I hate? When a developer decides to call a btn_Click method from another method. I mean, seriously, what the fuck? I work with a lot of older applications and many of them weren't written well. I think putting a btn_click method in the Form_Load spells "code being on the verge of unmaintainability" because all kinds of crazy shit happens.

For example, I'd show FormA, which would run the Load method of FormA. That Load method would run a click event that starts FormB. So the next thing I see in the GUI is FormB, not FormA! I was like, "WTF! I did NOT show that form! Madness!!!"

Click events planted in other methods (or EVENTS) are like planting bombs. They will go off with a bang if you do not disarm them.