Thursday, April 27, 2006

Against Globalization

No, this isn't a political rant. I'm discussing global variables; in our case the collection of globals in Rng, Inp, and Outp.

Let me preface the discussion by saying that I understand that there is a good reason the globals exist (they go way back).

The following happened on Monday and illustrates one of the problems with globals:
I was making last minute changes to a product. I was setting an Rng variable in the product, but by the time the output code ran, that boolean always had a reverse value. I searched the code for all places that changed that global, but didn't find any that I wasn't already aware of. To temporarily solve the problem I implemented a hack.

Cindy later explained to me why the global seemed to be changing, but no matter; the root problem is globals themselves.

I'm sure you're all aware of all or part of the following, but I wanted to put together a good list of reasons why globals are bad with few exceptions:
  • They make the code less modular; in fact they make it anti-modular - everything is tied to the globals.
  • When globals are used, it's exponentially more difficult to determine what to change. When all variables are in their own (smaller) object, you can find what needs to change much more quickly.
  • Using globals leads to duplicated and unused variables (of which Cindy and I have found several just since I've been here).
  • Better memory footprint: more objects, but fewer in memory at any given time.
  • Much easier debugging. Even when you have a simple "dummy" member variable with an accessor at least you can set a breakpoint on the accessor and easily track down all callers.
  • This from a portion of the coding standards that Rob referenced in a previous post (and another reason to always have accessors even if they're just dummy accessors): "If you avoid exposing fields directly to the developer, classes can be versioned more easily because a field cannot be changed to a property while maintaining binary compatibility. Consider providing get and set property accessors for fields instead of making them public. The presence of executable code in get and set property accessors allows later improvements, such as creation of an object on demand, upon usage of the property, or upon a property change notification."
  • They make test driven development (even though we may never actually adopt this) virtually impossible because you can't test objects individually; they all need globals that are manipulated by other parts of the main app.
  • For more, see Code Complete | Chapter 13 | 13.3: Global Data.
So, bottom line; I think we should begin avoiding them going forward if we want the app to evolve more easily.

In the specific case outlined above, I should have added a member variable to the product class and accessed it from the output code (even though it's a little funky to access the product object at that point).

Wednesday, April 26, 2006

Don't ever ask me to buy another book again!

I was just in a meetng were the ING Learning Centre has partnered with Skill Soft to provide ING employees with an electronic book library. It is called Books 24X7. It is amazing.

I was taking a quick look at it and we already have access to the latest Delphi 2006 and Delphi 2005 books that were written. From what I can tell certain books you can download and other are viewable through browser only.

I think this is very exciting. There was even a category for algorithms which I know Steve and Dennis will have a hay day with.
Here is asome additional informaiton about Books 24/7:

- ACCESSING Books24x7: Access to Books24x7 is through the icon on the Other Resources tab of the ILC. If you do not see the Other Resources tab, look for the Books24x7 Referenceware course in the Knowledge Tools section of your ILC homepage. If you had a previous subscription to Books24x7 and accessed their site directly, you will now need to go through the ILC to access it. Direct access to the Books24x7 site is no longer available.

- HELP AND SUPPORT: There is an extensive help system in the Books24x7 site available from the Help tab at the top of the screen. If you require technical support, please contact your ILC Administrator for your business area (click on the ILC Contact button on the logon page or homepage of the ILC).

- NEW BOOK NOTIFICATIONS: You will receive periodic email notifications from Books24x7 about interesting new books available through the service. If you want to access those new titles, enter Books24x7 through the ILC and search on those titles within the Books24x7 site.

- DOWNLOADING BOOKS: Not all books are available for download or audio access. If you find a book that has these options, refer to the Help guide within Books24x7 for instructions.

- CHANGING YOUR SETTINGS: Personal settings (except ID, name and email), can be changed using the Settings tab at the top of the screen in Books24x7. If your personal information changes (e.g., name, email address, etc.) you will need to make sure it gets changed in the ILC for it to reflect in Books24x7.

SlickRun

Since Rob sent us a list of useful freeware, I couldn't resist posting about one of the utilities on the list that I cannot live without; SlickRun

I can't live without it mostly because I despise that evil little monstrosity next to my keyboard most people refer to as the "mouse". But that doesn't mean you have to hate the hand manipulation device of doom to benefit from SlickRun. It makes launching common tasks way more efficient.

Here's what it is:
  • A place to centralize and manage all of the apps you commonly run.
  • A scratchpad for temporary pasting text.
  • A quick calculator.
The command launcher is something you use to create and launch shortcuts. So to open VSS I hit -> Window Key + A, "s", enter. As soon as I type "s" it completes my keyword for VSS ("sourcesafe") and hitting enter launches the app. Any time I open something more than twice, I add it to SlickRun and make opening it the next time faster (while laughing at my mouse). Any command you can enter at the run prompt works as well.

But there's more. You can add dynamic parameters to your commands. So one of my commands is "compare". When I run that command it prompts me for 2 file paths. I browse to and right click (using the right click key of course) on 2 files I want to compare and put their paths on the clipboard (using FileTargets, another handy utility), paste them into the prompt and it launches a file compare utility passing the paths to it which immediately shows me whether the files match.

The "jot" scratchpad comes up with a keystroke and always auto saves. So I invoke it, paste in some text and hit escape; it'll be there the next time I invoke it.

The same little window that you type your commands into serves as a calculator. I like to use it in favor of the windows calculator most of the time because I can easily enter several numbers with lots of parentheses. You can see each step of the calc all at once.

Coding Standards

Well, since the Web Illustrations project came together so fast we never really took the time to hammer out any good coding standards for our new .NET code, as well as HTML, scripts, etc. Now that the dust is settling a bit I'm going back and trying to clean up and comment some of my code. We now have Delphi.NET, C#, JavaScript, HTML, CSS, and XML files just to name a few. We do have documentation on Win32 Delphi coding standards, albeit a bit old.

For our C# code we should follow the Microsoft recommendations. It can be found on MSDN at:

Design Guidelines for Class Library Developers

Would it also make sense for our Delphi.NET code to follow this standard as well? Or should it follow closer to the Win32 Delphi standards we currently use? Perhaps Rich or Steve could speak as to what they've been doing in the .NET code sections.

I did some looking but could not find an authoritative JavaScript coding standard. There were several mentions to a document on the Netscape developers site but it appears to be gone. The Mozilla project doesn't seem to have anything similar. It appears to me that most sites (including Microsoft) appear to use Camel Case for most of their JavaScript variables and methods. I've tried to follow suit.

HTML, CSS and XML standards are sort of a whole other animal and perhaps would be worthy of a thread all their own if anyone is interested.

So I pose it to the group, what are your thoughts/feelings/recommendations on new and improved standards? Perhaps some of the new people have experience from their previous lives?

Wednesday, April 19, 2006

Intro to OneNote

For those who don't know what it is, OneNote is a new app in the MS Office suite (so we all have a license). I decided to try it out from day one here at ING.

My motivation is this: I (like most people) frequently take notes with paper and pencil. For years, I've been in the habit of maintaining to-do lists with little boxes next to each item. But this is inefficient:
  • I type much faster than I write.
  • It's easier to type while talking on the phone.
  • I can take notes on computer in more places using a laptop.
  • All my notes are in one place - on my machine.
OneNote is a tool for managing lots of notes.

At first it didn't seem too much different from a plain old word processor. But here are some important differences:
  • You never have to create or save files. Rather, you set a directory as your designated OneNote directory (and back it up of course) and OneNote manages the files (including auto-saving).
  • You can tag items paragraphs/sentences/bullets with "note flags". You tag items with stars, question marks, rememeber for later, or check boxes. Then you can search all your notes for a given note flag.
  • You can also simply draw something on your page freehand or easily take snapshots of some portion of your screen.
  • The organization for notes is section - page - subpage. Within a page/subpage you create paragraphs/bullet lists/whatever. Each of these items is automatically grouped into a draggable object thingy that makes it very easiy to cut and paste or drag and drop logically grouped info.
So here's a visual. I have a section titled "Trackers", and each page is titled with a tracker ID.














Under my "Meetings" section I have pages titled for each type of recurring meeting. I haven't yet used subpages.

Anyway, I'm really liking it. There are other features of course; these are just the basics. Maybe you will find it useful too!