Switch to full style
Codes,problems ,discussions and solutions
Post a reply

Data Type in Programming

Wed Feb 24, 2010 12:03 pm

Data Type in Programming!!

Here I am sharing some of my early experiences in Programming. When we write code for any application, generally we concentrate on Business Logic and different features available to meet the Business Logic. Whatever applications we are working on, we are ultimately playing with data .The placeholder for the Data is the variables/fields/properties, etc. When we are declaring data type for a variable, generally we don’t give much emphasis at that point. Here some points we need to take care
My Experience No 1:

I declared a variable as “int” data type for a PatientId. It worked fine in local, but when that code went to LIVE, the application gave exception because in LIVE PatientId is too long to accommodate in int data type.

So before declaring any variable we need to consider all the situations, application scope, environment .Even one code may be working fine today, after 1/ 10/20 days/months/years it will fail due to just due to data type declaration mistake.

Think more; write less is the policy for better programming.

My Experience No 2:

I declared a variable as int data type which was a placeholder for a result status (meaning, based on the result status that variable varies from 0/1/2/3. It can contain only these four values).

“int” data type is 4 byte integer in C#. But I can declare this variable as “sbyte” which represents a 1 byte integer. Since that variable contains only 1 or 2 or 3 or 4, declaring the variable as “int” is wastage of memory space.

Before declaring any variable we need to just think of the memory space needed for that variable, our requirement, any other good alternative for this variable.

Eliza

http://www.mindfiresolutions.com/Data-Type-in-Programming-426.php



Post a reply
  Related Posts  to : Data Type in Programming
 range of data type     -  
 Is String a data type     -  
 Type Conversion     -  
 Type conversions     -  
 set MIME type in link     -  
 range of the short type     -  
 range of the char type     -  
 Boolean type constant     -  
 Create Object and get its type     -  
 String type default value     -