Owner: SharpDeveloper.NET URL:http://www.sharpdeveloper.net Join Date: Fri, 25 Apr 2008 11:47:40 -0500 Rating:0 Site Description: Articles on .NET, C# and improving your work quality and code quality by learning from the mistakes of others. Site statistics:Click here
Moving from SourceSafe to Subversion 2008-04-24 18:25:09 This is an overview of some of the changes you will encounter when going from SourceSafe to Subversion.
Subversion is modeled on CVS, whereas SourceSafe is modeled on.... well... nothing (just a joke).
In SourceSafe, you work in a shared code base or line (known as a “Project” in SourceSafe) which you “share” into another line.
So you have a line that you work on, and then when you want to start adding new features or you want to change the functionality in certain pages, you share the entire line (aka “Projects”, represented by a small green folder icon ).
If our first project was called Development1.0, you can share this into a new project called Development1.1
At this point in time, they are identical twins. In fact, they both point to the same item, sort of like Read more:Moving
Copy A Database Diagram To Another Database 2008-04-19 16:18:13 For some reason SQL Server doesn't have an easy way to "Create TO" for database diagrams, unlike stored procedures, functions ,etc.
Here is how you can achieve moving a database diagram (or copying a database diagram) in SQL Server 2005
use Old_Database
go
--this will copy your database diagrams into a temporary table
select * into dbo.#tempsysdiagrams from sysdiagrams
use New_Database
go
insert into sysdiagrams ([name],principal_id,version,definition)
select [name],principal_id,version,definition from dbo.#tempsysdiagrams where [name]='Name_of_your_Diagram
'
That's it, so easy.
Five Points To Improve Your Estimation 2008-03-28 07:32:19
Software Estimation
is tricky business. You are often confronted with complicated technical (or even non-technical) work and asked “how long will it take?” on the spot. You are given fuzzy requirements (or no requirements) with ambiguous definitions and have to work with a code base that is best described as “chaos”. How can you give an accurate estimate with such a difficult environment?
I recently read an excellent book called “Software Estimation: Demystifying The Black Art"
Here are some amazing points that you can use.
1) We should not be pressured to reduce our estimates. Stick to your estimates – whatever they are. If management wants to reduce them, that’s fine, but stick to whatever you put in the first place. Managers trying to reduce Read more:Points
, Improve
My experiences with pair programming 2008-03-19 07:16:06 My initial thoughts on pair programming (definition).
Normally at our shop, we don't do pair programming. Each developer is assigned his or her own tasks and they are responsible for completing them. If they require assistance of explanation from another developer who is more familiar with that system they need to go and request that assistance on their own. I believe the vast majority of offices work in this manner.
However, yesterday we decided to try pair programming. We have a complicated CRM application where it takes months to learn the application, and the situation is that another fellow who works on the reporting side of things and I worked together to solve a few bugs in the system.
As we worked together (with a slightly decreased speed than the two of us seperately worki Read more:experiences
Convert your site from VB.NET to C# 2008-02-12 06:45:24 If you are tired of the headaches of using VB.NET code, and want to convert it to C#.. Here is a nice way to do it and get the comments too.
Why would you do that? Well if I have to explain to you, then you probably don't need to do it. One big reason for me is that VB.NET does not support multi line strings. You have to keep putting " & _ at the end of each line making it very difficult to go back and forth from another program with strings. You could technically create a tool to do this for you but that's so silly. Another thing is I really like using ?? operator in C#, for example txtLocation.Text = (GetLocation() ?? "").ToString() will ensure that even if SomeFunction returns null, this will always give you at least empty string.. I like to use this in cases whe Read more:Convert
Timing is EVERYTHING 2007-12-23 07:18:31 Being a person who believes in continual improvement, and being proactive instead of reactive, I suggested to one of my employers that I worked for that we should implement ELMAH (Exception Logging For .NET) to handle our uncaught exceptions. They weren't too interested when I made the suggestion and so I did not push it. I had found this gem of code here because I spend a bit of time each day doing research and improving my skills. (see point 2)
However, we had this continuing problem where customers would have a problem with the .NET site, maybe they had a crash and we had no way to diagnose the crash other than to remote into their machine and try to reproduce the error. What made it worse is that they had debug mode off, and we could not even see the exact crash details. Oft Read more:Timing
How Random is your Random?? 2007-12-05 07:52:22 How random is your random?
Computers are very deterministic. What that means is that you put something in, you get something out. In order to get computers to perform "randomness", it is very difficult.
Why is this important to understand? Because we want to write our code properly, if we depend on the random function for some security purpose, such as for generating passwords, we are actually putting security holes in our application without realizing it.
In .NET Using RNGCryptoServiceProvider would give you much better random results than just a Random
.Next()
-us/library/system.security.cryptography.rngcryptoserviceprovider.aspx
However, in order to truly randomize your number, you would have to do something like use data from customer mouse movements, or something wierd
Understanding Your 10 Days Vacation 2007-11-12 06:54:34 This article is based on Canadian vacation laws.
It seems that most people don't understand that by law we get 4% vacation. So where does this number of 2 weeks come from?
Well If you calculate 50 weeks * 4%, you will end up with 2 weeks, what that means is in 1 year, you get 2 weeks paid vacation and 50 weeks of work. So if your employer prorates your vacation for the first year, meaning that after 3 months they give you 3/12 of 10 days (i.e. 2.5 days or 25% of your total) but you need to take off 2 weeks and they refuse to give it to you, you shouldn't worry about because either it means at the end of the year thats all you took (2.5 days paid), and by law they will pay you for the other 7.5 days or 3.75% of your total salary at the end of the year (or whenever they reconcile their a Read more:Understanding
, Vacation
How To Debug Inside The Code Of Your 3rd Party Libraries 2007-11-06 07:08:55 Let's say you are using a 3rd Party
Library like ELMAH in your web site project to handle unhandled exceptions and it's throwing an exception and you don't know why. Since the code is open source, you would LOVE to see what line its crashing on and then submit your changes to the project so that others can benefit from the fix you made. It gives you that good feeling, right?
Well, unfortunately, you put the compiled DLL in the bin folder and when it crashes, it just crashes and burns.
How can you see the source code? Simple! Compile the source code on your machine, and copy the PDB ("Debug
ging Database") file to your bin folder along with the DLL, and then your web site crashes while in debug mode, it will go to the exact folder on your file system where the DLL was compiled from Read more:Libraries
SourceSafe Branch Recursively 2007-09-24 17:05:50 Did you know there is no way to branch sourcesafe projects recursively? Or so you thought!
Here is a work around:
From Visual SourceSafe Explorer, go to View -> Search -> WildCard Search
Then search for Wildcard: *
(a single asterisk) with "Search in current project and all subprojects" selected.
Then it will give you a list of ALL of your files in that project. Simply highlight them all and click on the Branch
button.
The only caveat is that you need to make sure the files are not checked out in that project in order to branch them.
And again,.. I would recommend you ditch SourceSafe and go for something better, like Perforce, Subversion, or Vault
Unit test your life! 2008-04-29 18:25:53 If you are not unit testing your code, chances are you are not unit testing in your life.
If you aren’t unit testing, START now! At the very least, do some “manual” unit testing in your code. How can you do this? Well, try running your code on a very basic case. Then try a bit more complicated case. Then another, then another. If you are smart, you are saving these cases using a testing framework like NUnit. If not, well at least you can have some confidence when your manager comes that you tried it comprehensively and that it’s not going to crash on you while you are showing it to him, or even worse, in a demo to the team or to your big boss.
I recently ran into some problems in my life which I managed to solve amazingly well by doing “unit testing”...
First prob
Manage your transaction chaos with Spring Framework 2008-04-30 17:51:24 Spring is a popular framework available in Java. It has also been published in .NET and is called Spring.NET
This framework is huge, but what I wanted to focus on is the section that deals with transaction management.
If you have ever worked with Transactions, (say SQLTransactions), you would realize how messy it can be when you have to keep your connection open and pass around a transaction to many different functions that are making updates or queries, and then you might make a small little change and find out you forgot to use the transaction object and you caused a deadlock!
How can you fix this? By having a generic transaction/connection object? Well, that's one way.. but how about using the Spring.NET framework to deal with the transactions?
Spring.NET allows you to specify w Read more:Manage
, Spring
20% Extra Security is Enough To Stop Kiddie Hackers 2008-05-05 17:39:30 Here's a security problem for you.
How do we stop people from using brute force attacks on our logon page?
Well, simple... just add a captcha.
Well, umm.. captcha is already broken. Even if it isn't, they can hire someone overseas to sit there all day and crack away at it.. right ?
Well, umm... fine, so we'll set up this security scanner, and add that vulnerability protector, and automatically ban this and that, and let's do this.. and that, and this, and that, and so on, and so forth, until we have a fortress.
Tell you the truth. Unless your site is heavily targetted, captcha is probably good enough. In fact, my experiences is that you just put in 20% effort and you will stop 80% of the hackers (there's that 80/20 rule again...!). For example, I had a web server that was getting d Read more:Extra
, Enough
, Hackers
PHP VS. ASP.NET 2008-05-08 16:42:05 This is a very shallow comparison of my experiences with PHP and ASP.NET
Don’t take this as a religious war or something, the idea is just some basic comparison.
Here is a summary: If you are choosing which technology to use to build an application, use .NET. You will get more bang for the buck. With the same effort you will be able to build a much more rich user interface.
My Disclaimer: Keep in mind there are a lot of great libraries and tools for PHP which I never got to use, I just had a simple PSPad text editor and my handy PHP web site. I really wanted some “Intellisense” style code completion but I could not get it to work with PHP since I couldn’t find a decent IDE (i.e. editor)
However, it all depends on your requirements. For example, if you are selling so