May 10, 2012

Windows Registry file (.reg) doesn't register key

It was a nice test for me. I needed to give a .reg file for a collegue of mine (its a long story) to recreate a setting for something we're doing. Long story short - I needed to add a path under a certain key so I did the following:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Key1\SubKey1]
"PathKey1"="C:\SomeFolder\SomeSubFolder\SomeExecutable.exe"
When I ran it on my PC to verify it's working I saw it created the keys all the way to the "SubKey1" but the string value PathKey1 wasn't added. Can you say what the problem was? I wasn't sure as well. Then I've found you have a nifty little menu option in registry that says "Export" and it will create the reg file for you. I ran it and out of curriosity I opened the file in Notepad to see what was I missing. The thing is that RegEdit want to have the "\" escaped with another "\" so the successfull reg file will be:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Key1\SubKey1]
"PathKey1"="C:\\SomeFolder\\SomeSubFolder\\SomeExecutable.exe"
The catch here is that no matter RegEdit won't be able to create the String value it will tell you that it succeeded. I will most probably never use to manually add things in Notepad, I'll use Regedit Export functionality now that I know it but be sure to always check that paths added to the registry via .reg file are double escaped. Hope this helps.

Feb 27, 2012

2 ways to make estimations in the software world.



I've watched a presentation held by Joel Semeniuck. As his LinkedIn profile states, he is currently "Executive VP at Telerik", anyway, this post is not about Joel himself but about estimating how much does it take to complete a given software project.

I was thinking about this over and over again.
Actually - each time I gave an estimation while I was at Telerik - my team lead used to double it in order to get somewhat accurate estimation.
And I was pretty ashamed in the beginning. I always push as much as possible in order go be a great software developer, I stay night, I work weekends, whatever it takes. And still I can hardly meet my deadlines.
(Note: I wasn't working night / weekends @Telerik, this is a generalization of my whole life as a software developer.)

Why would that be? I am trying so hard and still no result.
(to be honest - there are lots of cases that I was able to meet deadlines, but they were about things I already knew how to do step by step so they don't count. Or do they?).

And it's the bolded sentence above that got me thinking.
And I came up with yet another software development law. Maybe it only applies to me so it is not actually a law that will cover the whole software development industry, but let me first say it and then I'll discuss it:

"You can estimate a software project using two algorithms - the algorithm that all Windowses prior Vista used to estimate file copy time and the way all Windowses including Vista and later use to estimate the time it will take to copy a file."

First of all what's the difference?
In Windowses prior Vista the way explorer will tell you how much time will it take to copy file / files would be somewhat random, then it starts to fluctuate during the copy progress. Ever started with 2 minutes, gone to 10 minutes? Well that's what I'm talking about.
In Windowses starting from Vista - the system will be much more acurate, except for one thing - it will not tell you how long will take to calculate how long would it take to copy the files. So you first wait for Windows to do some estimations by chunking the data it has to deal with. And then it will be more accurate in saying how long will you wait.
(Note: I probably miss a lot from their algorithms but this is the end user impression it leaves).

So basically if you start estimating like older Windowses - you will be looking at one large chunk of work and you will be able to estimate that chunk roughly.
If you give your estimation the way Vista and newer Windowses work - you will have much more acurate estimation as you would have chunked all the data upfront. And there will be much less room for errors. So in the ideal case you will have to split the big chunk into really really small tasks you know you can do in an hour.
The bad thing using the second approach is that when asked "What's your estimate on this?" you will need to say "Gee, I don't know, I will first need to take my time to estimate it, I'll then be more acurate.", "How much time would you need to estimate this?", "Gee I don't know. You'll have to wait for me.".

So to summarize:
Estimating like old Windows: "It will take 2 months and it may go up to 10 months. I may be able to complete it in 2 weeks though."

Estimating like new Windows: "Come back later. Or better - I'll call you when I have an estimation. I know you have a decision to take but I can't do anything about it yet.".

I am leaving you decide which one to use :). Maybe a mix of both?

P.S. If you think about it - this applies to known projects. Add some third party black box integration and you will fluctuate the same way windows fluctuates when it downloads a file - it tries to take into account a variable that is changing randomly - the speed of your internet connection. For such projects you can go from 1 hour to 1 year or even to work 1 year and understand that the project cannot be completed (well guess what - although Windows states it will get your file in 1 hour, it doesn't tell you what will happen if you decide to disable your internet adapter).

Jan 18, 2012

Find and open a file in Visual Studio.

I remember that a collegue of mine used that a lot. I forgot it so I will just post it here so anyone (including me can benefit of it).

In order to find a file / class in Visual Studio - use the "Find In Files" toolbar combobox. You will however need to write a magic word before it starts searching, just type "> of" before the file name, like "> of User". VS will help you with some of the files that contain this name:



Hope this raises a bit more of productivity out there.
If you need more - you may want to try Telerik Just Code ;).

Nov 23, 2011

Scroll event not fired in some Telerik Windows Forms Controls (maybe WPF as well)


First of all - this is not quite an issue.
Since the Telerik controls are compound controls (for example the list view has Root Element, List Element, things like that), what scroll are you subscribing to?

Do you subscribe to the whole control?
Do you subscribe to the RootElement? To the ListView?

To remove that kind of questions, Telerik came up with the idea that it will be better to rise the appropriate control scroll, instead the entire control scroll.
Consider this:

radListControl1.Scroll

vs:

radListControl1.ListElement.VScrollBar.Scroll

If you are called like the first one, how do you know who called you?
If you are called in response to the second one, however, you will know that the ListElement (the items placeholder) has changed its vertical scroll so you can respond to this easilly (for example in a case of Virtualization it will mean it may be hungry for some more items ;).

To be honest at first I was a bit frustrated but now when I got it it makes a lot of sense.

Disclaimer: I am not part of Telerik anymore so this is just my guess, why they did it that way and my own explanation. I may be wrong :).

Sep 29, 2011

Kindle Fire is comming! Amazon is taking orders on the new Kindle In Color (Kindle Fire)

Are you ready to get one?
Lot's of rumors that this little thing will be one of the main competitors to the Apple iPad. No one knows yet. With date of release set to 15 november, the Kindle Fire is a long awaited addition to the old Kindle.

Here is the old one (I have one and I'm pretty happy with it):


and here is the new, shiny tablet that Amazon will offer at the end of this year:




Honestly, I am thinking to get one, although pretty happy with the old Kindle, I need to stay in the business :). I would be happy to be able to optimize some of my upcomming products to work well in both - Kindle Fire and the old Kindle, so having both will be of great help to me.
On the other hand if you just need to read stuff, I belive to old Kindle will be enough.


+

= Happy developer.

Sep 2, 2011

LinkedIn API - request failed with 401 - unauthorized (cause #1 of N)


If you experience that, make sure you are encoding your request properly. For example http://api.linkedin.com/v1/people-search:(people:(id,first-name,last-name,picture-url,headline,location:(name)),num-results)?keyword=" + HttpUtility.UrlPathEncode(user.FullName).

In the above example if the user full name is Pavel Donchev, if you use HttpUtility.UrlEncode(user.FullName) the result will be Pavel%Donchev.
It should be Pavel%20Donchev, which is result of calling HttpUtility.UrlPathEncode instead HttpUtility.UrlEncode.

Almost unnoticeable difference mixed with generic message that may cause lots of head aches for you.

Aug 16, 2011

SQL Server–have another instance redirecting to existing SQL Server

I was in a need to have an SQL instance renamed.

This is because I have SQL instance on my server and wanted to have it on other computers as well so I don’t need to change the Connection Strings each time I deploy.

I first tried to rename it but to no avail. Then I found this little neat trick to have another instance that can “redirect” to the original server (e.g. you have (local)\Instance and want it to redirect to (local)).

To do this follow the instructions bellow:

1. Go to Start Menu => Microsoft SQL Server 2008 => Configuration Tools => SQL Configuration Manager.

image

2. In the SQL Configuration Manager expand the SQL Native Client 10.0 configuration node

image

3. Right click Aliases node and select “New alias”

image

4. In the Alias – new popup, in the Alias Name field type the name you want to have for redirection, in the server field type the server the alias will redirect to:

image

5. Go to management studio and type the new instance name in the server name text box to test the connection:

image

It worked pretty well for me, hopefully it will work for you as well!