Monday, March 21, 2011

Build and Rebuild solutions in .Net

Build and Rebuild solutions

Let’s now talk about one of basic thing about compiling project/website in visual studio .Net.
Visual Studio provides two options to compile or build application-
1.       Build solution
2.       Rebuild solution.

These options can be accessed from Build menu-


Difference between these two options are-


Build Solution
Rebuild Solution
1.
Build means compile and link only those project files and components that have changed since last build.
Rebuild means compile and link source files regardless of whether they changed or not.
2.
Build is the normal thing to do and is faster.
As it compiles all files it takes time.
3.
E.g. You have two projects A & B in your solution, when you compile the solution using Build option after making some changes in Project A, then only Project A will be compiled but project B will not as there are no changes in it.
E.g. You have two projects A & B in your solution, when you compile the solution using Re-Build option after making some changes in Project A, both projects A & B will be compiled and built even though there are no changes made in project B.
4.

Sometimes the versions of project components can get out of sync and at that time Rebuild is necessary to make build successful.


 Hope this information is useful.

Saturday, March 19, 2011

GUID Or Int which is better?

Recently I read a blog on, what is better GUIDs or Integer values. This is a long debate as both have some advantages and disadvantages; my answer to this is it depends!! J

It is dependent on your database design and overall architecture of your project, it’s not that usage of GUID is a bad practice there are some disadvantages of using GUIDs-

1.    Big storage size. At 16 bytes, the uniqueidentifier data type is relatively larger than other data types, such as 4-byte integers. This means indexes that are built using uniqueidentifier keys might be relatively slower than indexes using an Int key.

2.    The values are long and obscure. This makes them difficult for users to type correctly, and more difficult for users to remember in testing.

3.    Don't have the chronology assumption.

4.    Don't benefit from a mechanism to obtain the last generated primary key (MS SQL Server).

5.    There is no way to determine the sequence in which uniqueidentifier values were generated. They are not suited for existing applications that depend on incrementing key values serially.

6.    The values are random and cannot accept any patterns that may make them more meaningful to users.


Advantages of using GUIDs-
  1. If you want to merge tables then Using GUID it’s easy to merge table.
  2. It’s easy to work with distributed tables.
  3. The primary key is uniquely identified in the entire system (the number of machines or tables doesn't matter).
  4. Don't have problems when inserting a large number of operations.

Using INT-

Advantages of using INT-
  1. Small amount of storage size (integer is 4 bytes).
  2. Increased readability, practical use in testing, and easy to remember.
  3. Chronology of data; if two records are in ascending order, we can deduce that the second record was inserted after the first one.
  4. Support for functions that return the last primary key generated (@@IDENTITY, SCOPE_IDENTITY()).
Disadvantages of using INT-
  1. Difficulty in the case of merging tables (the need to make remapping because the primary keys may be duplicated).
  2. Hard to work with distributed tables.
  3. Primary key in the form of INT/BIGINT is LUID, local unique identifier, which is only used locally in a table.
  4. After a large number of operations (insert, delete), the counter for primary key can be reset, bringing the problem of chronology to 1.
Hope someone find this information useful.