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.

Wednesday, April 30, 2014

Tip of the Day

When working with column names in your DataGridView, always refer to them as Column.Name, rather than "ColumnName".

Example:

Select Case colCheckBox
            Case "colApprovedByExecutive"
                If desiredCheckboxStatus = True Then
                    cellDate.Value = DateTime.Now().ToString()
                    cellUsername.Value = GetLoggedInUser()
                Else
                    cellDate.Value = New DateTime(1753, 1, 1)
                    cellUsername.Value = String.Empty
                End If
End Select  
Simply, don't do this. When you remove columns, rename them, or whatever, you'd have to search through the solution for every last one. Instead, use:


Case colApprovedByExecutive.Name     ...

Since you're just referencing the actual columns, you will only get a compilation error. That is *much* more visible than the alternative and will make your code easier to work with.

P.S.: My recent posts may have had nothing to do with C#. I will probably be moving over to a more IT/General Development style. I will also be posting more tidbits such as this. :)

Monday, April 21, 2014

Team Foundation Server - Unshelving

Why does TFS ask us if we want to save changes to our local project when we unshelve a shelveset for that same project? The fact that we are unshelving changes obviously means we want to overwrite any local changes with the shelveset files. So why would they ask us that question? If you click No to saving changes, you're probably fine. But if you click yes - BOOM! Errors abound. You have to undo the pending changes you just unshelved, then unshelve them again. What a waste of time. Better hope you preserved the shelveset or took a backup, because if you didn't you're fucked.

Wednesday, April 9, 2014

Windows 7 update

Microsoft, if you can't restore all of our open programs and documents when you decide to update and restart without asking us, then don't fucking update.

Sunday, April 6, 2014

Oracle SQL Developer

As far as usability and presentment is concerned this program is seriously a joke. If you have been using SQL Server for years, and you try to use this DBMS, it's incredibly frustrating. Every common function you want to perform won't have a button, or even a menu option. It's a keyboard shortcut. For example, to start a new query tab in Oracle SD, you have to type Ctrl + Shift + N. There is no button, menu item, and to boot, it was not easy to find searching on the net. Are you fucking kidding me? Did you not think that would be a common feature that we would like to just click? In SQL Server, you just click New Query.

Similarly, code comments has no button either. It's a keyboard combination: Ctrl + /. Whoever made this software, I have a message for you: Welcome to the 2000s. We have GUIs now. Did you miss that?