Posts

Showing posts with the label programming

Your code sucks and I hate you

It's been a while since I posted any code. I've been very very busy actually working and haven't had a chance to update the 'ol blog. Today we're getting away from straight code and getting more into the soft side of programming. I read an interesting article on code reviews. You should take a look at it over here: Your code sucks and I hate you Code reviews are something we do every time code gets checked into the main base line. They are important and help ensure high quality of code. However if you don't take some care they can quite easily get out of hand and develop into a personality/pissing contest between people. If you follow some decent guidelines you will find yourself amazed by the results. I know I hated code reviews in the past but have found them very helpful in uncovering bugs before they went into production. It does take some letting go of the ego but if you go in with the right attitude they will make you a better programmer/engineer/...

Notify Icon Text vs BalloonTipText

Ok so I have a small application that shows a users ip address via a tool tip when it sits in their system tray. Everything is going fine until someone sends me a bug that there was a problem. Investigating this I find that the method I was using to display tool tips in the system menu is somewhat flawed. I was using a notify icon control to show the tool tips while in the system tray. This works but I was setting the Text property of the control like this: // old way of setting text, with 64 character limit this.notifyIcon1.Text = "Show me in the toolbar"; This works but only for up to 64 characters. When I was designing the application I was thinking about ip addresses using the v4 format not the v6 format. Sure enough v6 ip addresses kick out more then 64 characters a lot of the time. So the search was on and I found using the balloon text can show more data but is a wee bit harder to use. Balloon tool tips don't show automatically like the text does. You h...

New software in unleashed!!!

Well it had to happen sooner or later. I have released a new version of the IP Viewer tool. It now hides from the alt-tab menu and runs quite a bit faster. For some reason it was hitting the .config file way to much. Now it keeps those values in memory until the settings get updated and then it re-reads them. Also Tile Puzzle 1.0 has been released. You can take an image from your PC and turn it into a tile puzzle game. It took me about a week of hard coding to get it working. It's pretty cool actually, it uses GDI+ to cut an image, and uses collections, and sorting methodology to manage the puzzle pieces. No source yet but the game is working pretty bad ass. Head on over to: JRL Software and check out the goods.

Copying data to the clipboard using C#

So you need to copy data to the clipboard using .net. Usually Ctl-C, Ctl-V is good enough for me. But there arose a need to copy data from a context menu. Microsoft has actually made it pretty easy to get data to/from the clipboard. They have conveniently created a class to do this and called it Clipboard. For my uses I just needed to copy some basic text to the clipboard. To achieve this I simply use the method SetText. Easy as pie! so a qucik and dirty example is Clipboard.SetText( "Hello World!"); Will put the text Hello World in your clipboard. There are of course different methods for copying all sorts of data into the clipboard. Read the MSDN for the complete breakdown. Read the MSDN article

String.Empty vs ""

Image
So I've always heard you should use String.Empty vs "" the dreaded blank string in C#. So I decided to write a little test program to find out. It simply takes a string variable and assigns it to "" or String.Empty. I do this 1 million times each and time how many milliseconds it takes to do that assignment. My system is a p4 1.5 GHz RAM running .net 2.0. Source code can be sent upon request. The results are surprising and can be seen below. Other then the first run the String.Empty beat the "" by a few milliseconds. Hardly the creaming I've read about. But perhaps if you were doing some severe number crunching you would notice a difference. However this test is hardly definitive and should probably be run several more times and had the numbers aggregated. I've run the app a lot more since yesterday but only added one more screenshot. I may just post the screen UI and then keep track of the results in a spreadsheet or modify the app...