Articles from July 2007

Mixing Accessibility for Class Properties

By Michael Flanakin @ 6:51 AM :: 1023 Views :: .NET :: Digg it!

I’m sure just about all of us have happened upon a scenario where we needed to have a property read-only to consumers, but writable by child classes. Well, maybe it’s not something you run into every day, but I know I’ve run into it at least a dozen times since I picked up .NET when it was first released. The practice I’ve seen most often is a developer will create a public property and a protected method to set the field.

public class User
{
    private int _id;
    public int Id
    {
        get { return this._id; }
    }
    protected void SetId(int id)
    {
        this._id = id;
    }
}

Sure, this works. Nobody will really question it, but I don’t like it. I’ve always wanted the ability to use a property for that; not just any property, but the same one used to get the value. I was explaining my complaint to a coworker, Don Hurley, and, in the middle of that conversation, thought up with an ingenious way to implement such a feature.

public class User
{
    private int _id;
    public int Id
    {
        get { return this._id; }
        protected set { this._id = value; }
    }
}

Simply add the desired access modifier to the getter or setter, depending on which you want to be less accessible. Sure, you could probably decorate the more accessible getter/setter, but that seems backwards. Maybe it’s just me. Either way, I thought this was probably the best way to solve the problem. I’m so smart… or so I thought ;-)

The next day, I got an email from Don. Despite the fact that he asked me never to talk to him about something on a Friday afternoon that’ll keep the gears running on Saturday morning, he had some news... it works! I read the email a second time to make sure I wasn’t misunderstanding him. In disbelief, I replied asking, “Are you saying this works!?” You ask a stupid question… “I wouldn’t have sent it if it didn’t,” he answered. Umm… good point.

Don is officially my hero of the week. I have no idea why I never thought to try this. Then again, I did just think of it. Apparently, tho, I’m not the only one. I am somewhat curious as to how long this has been in the language. For now, I’ll just take advantage of it and spread the word. This is one of those great hidden gems that I love about C#.


New Features in Live Search Images

By Michael Flanakin @ 9:34 PM :: 1112 Views :: Technology :: Digg it!

Live Search Images now has a few interesting new features to filter your results. If you want portraits, add filter:portrait; faces, add filter:face; and/or black and whites, add filter:bw to any search query. I admit I'm not too sure about the portrait option, but the other two work quite nicely. I can definitely see these being of use in the future. Then again, that might be a niche search that doesn't come along too often. I know I could've used it for a project I was working on last October, tho, when I just needed pictures of people's faces. Damn... This would've made my job a lot easier!

If you're a Google Image Search user, I definitely suggest you check out Live Search Images. The experience is much, much better. I will say the result-set is smaller on Live, but at least everything was valid. On a basic search using both services, Google provided 216 results, where only 26 seemed accurate, while Live provided 14, where all were accurate. I admit, missing out on half the accurate images isn't cool, but neither is adding almost 10x's the real results with fluff. Neither service provided the full spectrum, tho. Google had a lot of the older images, while Live had the newer ones -- Live had 10 images Google didn't. Of course, that means Google had 16 images Live didn't. Obviously neither is perfect, but I still prefer Live. Look at them both and decide for yourself.


Bad Email Signatures

By Michael Flanakin @ 7:50 PM :: 4555 Views :: Digg it!

There have been a few weblog posts on bad email signatures Mobile-ready link, but after getting a few emails from one person, I feel I have to share this ridiculous email signature with others...

Michael - am on it and will get back to you on Tuesday!  Thanks - good news!

Oh, By the way...If you know of anyone who is buying or building a new home, or who wants to refinance their existing home, please call me with their name and phone number.  I will be happy to follow up with them and take care of their needs!

G... G...
Wells Fargo Private Mortgage Banking
Wells Fargo Home Mortgage
MAC ####-###
#### J B Drive, Suite ###
McLean, VA 22102
703.###-#### Tel

703.###.#### Fax
703.###-#### Cell
g___.g__@wellsfargo.com

https://www.wfhm.com/wfhm/g...-g...

For your protection, we remind you that this is an unsecured email service, which is not intended for sending confidential or sensitive information. Please do not include your social security number, account number, or any other personal or financial information in the content of the email. To see our privacy policy regarding how we use and protect customer information, please select the following link: http://www.wellsfargo.com/privacy/privacy.jhtml. To discontinue receiving all emails containing solicitation materials from Wells Fargo Bank N.A., including Wells Fargo Home Mortgage, please send an email to NoEmailRequest@wellsfargo.com with your name and email address.

Wells Fargo Home Mortgage is a division of Wells Fargo Bank, N.A. © 2005 Wells Fargo Bank. All rights reserved. Equal Housing Lender.
Wells Fargo Home Mortgage-2701 Wells Fargo Way-Minneapolis, MN 55467-8000

Seriously, you've gotta be kidding me, right? When looking at the email via WL Hotmail on my widescreen monitor, it's coming up as 19 lines in the signature, not counting spacing between paragraphs. All for half a line of email body. I seriously wish more people would take email signature etiquette into consideration. I just find this very annoying. Currently, I have two signatures I use. One for new email and one for replies/forwards.

__________________________________________________
Michael Flanakin | Microsoft Consulting Services | ###-###-####
www.michaelflanakin.com

...and...

Michael

Pretty simple. I revisit the idea of changing my signatures every month or two, but usually just stick with what works. It's always interesting to see different peoples' sigs.