# Tuesday, 17 February 2009

I have a favourite piece of advice, and I give it even though it frustrates many recipients. If you want to write, write! If you want to get into public speaking, speak in public! If you want to start a user group, start a user group! If you want to be an MVP, do what MVPs do (advise others and solve problems and volunteer for stuff) and you'll start to get the benefit even before you get the award. I'm not quite saying Just Do It but the fact is the barriers to entry are very very small these days and possibly non existent. Technical writing especially - start a blog or get active on newsgroups and presto, you're writing! Listen to feedback (people telling you you're wrong is bad, people thanking you for your answer or quoting you elsewhere is good) and you will get better. Public speaking isn't much harder to crack because the world is full of user group leaders and similar folks who need someone to speak to them month after month. It's also full of Code Camps and other places to get started (they tend to come with coaching and encouragement too.)

Still some people don't like this advice. They feel held back from what they want to do, and they don't like to be told "nothing is holding you back, you can start whenever you want." Alternatively, they don't want to speak or write or lead for free, they want to be paid for it, and they don't like the idea of starting for free and working hard for years to get that overnight success. So here's a rephrasing that maybe you'll prefer: "80% of success is just showing up." It's attributed to Woody Allen, not a guy I would normally take advice from, but it sure is accurate. Go to the meeting, open the document you're supposed to be writing, be there when someone asks for volunteers, go to the whiteboard and draw as much as you know, put your shoes on and go outside, ... not all at once of course, but these are the "just showing up" tasks that get you on the road to success. Try it.


Tuesday, 17 February 2009 17:06:42 (Eastern Standard Time, UTC-05:00)  #    Comments [0]
# Monday, 16 February 2009

Paul and Kimberly are so romantic! Paul started it with a Valentines Day post about how to be a better speaker, giving lots of credit to his lovely wife. So naturally she followed up with a post of her own. If you've never seen Kimberly speak, you really should, even if you don't know anything about her topics. We're often speaking at the same time but the few times I've managed to get free time and sneak into the back of her room, I've been tremendously entertained and learned more about SQL Server as well. I know, too, how much time sweating demos, rewriting things, practicing, and just plain working hard goes into being so entertaining and accurate. You start to get a sense of that by reading these posts - from the tiniest detail of what to wear to the vital "practise your demos" and "show up for your tech check" you can understand that what matters most is caring. If you want to give a great talk you will do all that it takes to give that great talk.

None of their tips are SQL-specific. Read them and you're on the way to getting better. Get out there and do some talks with this in mind, and you're really starting to get it.


Monday, 16 February 2009 16:54:45 (Eastern Standard Time, UTC-05:00)  #    Comments [0]
# Sunday, 15 February 2009

Well perhaps not all the way to Considered Harmful but Allen Holub is willing to call them Evil. I came across this article because I'm teaching OO Analysis and Design again this year and my students have generally already heard that the way you do encapsulation is you make all your attributes private and then add a public get and set method for every attribute. What's more, they generally feel if you change the type of the attribute then you need to change the return type of the get and the parameter type of the set. This of course gets you pretty much nowhere, and this is what Allen is railing against.

Now I am OK with Get methods as long as you swear you will never change the return type. The example I give the students is a bank account class with a balance. In the original design you keep the balance as a floating point number, 12.34000000 for 12 dollars and 34 cents. You add a GetBalance() method that returns a float, and Deposit() and Withdraw() methods that take (among other things) floats to represent the amount being deposited or withdrawn. Now when implementation time rolls along you discover that floating point arithmetic is expensive computationally, and needs lots of rounding to stay accurate: add 1.00 to 1.00, then add another 1.00 and the time may come when your number ends .01 or .99 ... neither of which banks care for tremendously. So you decide to store the balance as an integer number of pennies. Everything is OK in my book as long as you DO NOT CHANGE the signature of GetBalance(), nor of Deposit and Withdraw. These methods don't need to know what you just did. When Deposit tells you the amount is 50.00 dollars, your code can multiply by 100 to get 5,000 pennies, and add that to the balance. GetBalance() can divide by 100 (and round) to change pennies to dollars. That's a good use of a Getter method.

I am less OK with Set methods. I sure don't want a SetBalance() method. Deposit(), Withdraw(), and their cousins will change the balance. But there's no business rule in which it becomes necessary to announce that account 123456 now has $183.27 in it, and set the balance to that number. Having the method just encourages some code outside the class to do things that belong in the class - calculating service charges, or giving interest perhaps. Locking up access to the value means that if your business rules change, you don't need to look outside the bank account class for code that implements those business rules.

So do I think Get and Set methods are Evil? No, but I do think they should not be your first reflex, one of each per attribute. Make them earn their place.


Sunday, 15 February 2009 16:47:44 (Eastern Standard Time, UTC-05:00)  #    Comments [0]
# Saturday, 14 February 2009

Here's another Channel 9 Video you need to watch: Rico Mariani: Visual Studio Today, Tomorrow and Beyond - Your Questions Answered. I love that in addition to planning for version 10 of Visual Studio, he's planning for 11, 12, and to a certain extent 13. To have the courage to start on a feature that won't really be done for ten years is very impressive. I'm looking forward to "Dev10" for a lot of reasons ... even more after watching this video.


Saturday, 14 February 2009 16:31:21 (Eastern Standard Time, UTC-05:00)  #    Comments [0]
# Friday, 13 February 2009

You know the blog, now watch the Channel 9 video featuring Damien Watkins, Rick Molloy, and Don McCrady. I like this one because they talk about how they ended up changing their minds over the course of development, moving from a language-based approach to a libraries-based one. They get into why that's better and what C++ 0x features they needed to make it possible. A nice way to spend a little under an hour.


Friday, 13 February 2009 16:20:06 (Eastern Standard Time, UTC-05:00)  #    Comments [0]
# Thursday, 12 February 2009

Yochay has been very busy talking to Channel 9 and preparing Windows 7 material for developers. Here's a blog post from early January that lists some taskbar related videos you will want to watch. Screenshots of the taskbar really don't convince you of how much easier it is to use.

Still I can't keep from trying. Let me show you how I close things now. Imagine I have (among other things) a Notepad instance open on my machine. The "old way" to close it, if it doesn't have focus, is to right-click the icon on the taskbar and then choose close. You can still do that in Windows 7:

That's a right click, let go, move the mouse, left click. We know how to do that, and it's a ton less mouse moving than left click, wait while window paints, go on all the way up to the top right, click the red X. But I like this even better:

If I just move the mouse (no clicking) over the icon of one of the Notepad instances, they all show their thumbnails. One of them (the one I moused over) has a little red x showing in the thumbnail. Without clicking, if I move the mouse onto the thumbnail and pause a moment, I get the "peek" where that window appears (in case I can't tell from these tiny little thumbnails) and everything else goes transparent. If I click the little red x in the thumbnail, the instance closes. It's less clicks, it's noticeably faster and smoother.

These are the sorts of things that are making me so glad I put Windows 7 on the prime laptop. I would not go back!


Thursday, 12 February 2009 20:47:40 (Eastern Standard Time, UTC-05:00)  #    Comments [0]
# Wednesday, 11 February 2009

Jennifer Marsman points out her favourite new Windows 7 feature - different default printers when you're on different networks. To bring up the dialog she shows in her blog post, bring up the Devices and Printers dialog (I do that by clicking Start and typing printer), then select a printer. That will give you a printer-related toolbar:

And yes "no network" counts as a network, so I can have the XPS writer as my default when I'm not on the network (if you've ever accidentally clicked a Print icon on a toolbar and then had to wait over a minute while the search for the printer timed out, you'll know why my default isn't really a printer at all) but I can have a useful default printer when I am on the network. Fantastic, and thanks Jennifer for telling us about it!


Wednesday, 11 February 2009 19:14:29 (Eastern Standard Time, UTC-05:00)  #    Comments [0]
# Tuesday, 10 February 2009

There's been a reasonable amount of blog talk about the removal of the "quick launch" area from the Windows 7 taskbar. What isn't coming across in the blogs I read is how there is an across-the-board attempt to make the taskbar more useful. Sure, making it easy to flip focus to a background window to see how it's doing is a good idea. But saving you from having to flip focus is a better idea, right? Take a look at this:

It's a piece of my taskbar, and the icon with the green on it is an Internet Explorer download dialog. That's a green overlay progress bar going across it. Here's another a few minutes later:

This is really, genuinely useful. And if you're thinking that getting your own applications to take advantage of this will require you to learn a bunch of API calls and the like - think again! If you have a progress bar control on screen, the overlaying in the taskbar will be done for you automatically on Windows 7. How's that for fun?


Tuesday, 10 February 2009 18:27:42 (Eastern Standard Time, UTC-05:00)  #    Comments [2]
# Monday, 09 February 2009

We all face times when we have a picture and we want the text. Maybe we have a printout we can scan, but we don't have one of those cool photocopiers that scans to a true text format like PDF or XPS. Maybe we took a screenshot during a web cast and don't want to retype all the code. That sort of thing. There used to be OCR in Word, but in Word 2007 it seems to have disappeared. No worries though, it resurfaced in One Note.

Here's a screenshot from a private web cast last summer (the actual content is in a recent Visual C++ team blog, so no worries about revealing super secret info):

Now, I open a new One Note document, paste this jpg into it, then right-click:


You can hit paste right in One Note if you like, but it tries to capture formatting etc. I pasted into Notepad and got this:

Some samples
void meow(constX&)cout<<”meowconstX&):Copying.”<<endI;}
void meow(X&&) cout << “meow(X&&): Moving.’ <<endl;}
XfooOIreturn XO;}
const X bar() return X(); }
mt main()
meow(a); I/Copying
meow(b); I/Copying
meow(fooO); ii Moving
meow(barO); II Copying

OK, it needs some spaces, and it's not too smart about {} or //, but it's quicker than typing it all yourself. And if you have a boatload of ordinary typed text (say a paragraph from a printed RFP that you want to quote in an email to various folks, or a powerpoint presentation) then it's even more accurate. And it's probably on your machine already!


Monday, 09 February 2009 17:58:44 (Eastern Standard Time, UTC-05:00)  #    Comments [0]