welcome folks
FAQ in android,FAQ in dotnet,DotNet, C#,DOT NET CODE, ASP.NET, VB.NET, TRICKS,Dotnetcode,Android and Latest Technology Articles in VB,Android and ASP.NET

Friday, September 14, 2012

Difference between DBMS and RDBMS?

Data base management system (DBMS) consists of collection of interrelated data and a set of programs to aceess that data in a persistant way. 
It takes care of storing and accessing data specifically related to the application. 

The main objectives of DBMS are 

Data Availability -- available to users in a meaning ful format that can easily access. 
Data Integrity -- Data base, maintains the data in reliable (correctness) manner. 
Data Security -- provides authorization to access the data in different levels at different scenarios. 
Data Independence -- It's nothing but 'abstraction' i.e., to store, update and retrieve data in effecient manner without changing the nature of data. 

RDBMS is nothing but Relational DBMS, uses a collection of tables to represent both data and the relationship among those data. The relational model is a combination of three components as 

Structural Part -- Defines the database as a collection of relations. 
Integrity Part -- maintains integrity using various keys like primary key, foreign key, super key and etc... 
Manipulative Part -- The relational algebra and relational calculus are the tools used to manipulate the data in database by introducing key features like tuples(rows), attributes(columns), keys, cardinalities, Domains and Degrees. 

A relational system may support the following items 
1. Data Definition 
2. View Definition 
3. Data Manipulation 
4. Integrity Constraints 
5. Authorization 
6. Transaction Management 
7. Data Recovery 

The following are main differences: 

1. The speed of operations on data base is very fast in RDBMS compare with ordianry DBMS 
2. RDBMS can be implimented by the concept of relationships (logical mapping). 
3. The concept behind the RDBMS is 'TABLE' but in 'Flat files' are used in DBMS. 

Advantages of polymorphism

Polymorphism means the ability to take more than one form. An operation may exhibit different behaviors in different instances. The behavior depends on the data types used in the operation

Advantages of polymorphism:

- Same interface could be used for creating methods with different implementations
- Reduces the volume of work in terms of distinguishing and handling various objects
- Supports building extensible systems
- Complete implementation can be replaced by using same method signatures

Advantages of dynamic binding:

- Compiling time is much lower and allows faster development
- The current state of the program is better known to the runtime linker, so that the memory and its resources can easily be reordered
- The addresses symbols which may not be known at compile time, can be resolved by the runtime linker. This process is ideal for networked systems
- Common resources could well be shared instead of duplicating them in each time of execution.

Difference between ref and out parameters in C#

Ref and Out Parameters: 

Both the parameters passed by reference, While for the Ref Parameter you need to initialize it before passing to the function and out parameter you do not need to initialize before passing to function. 

you need to assign values into these parameter before returning to the function. 

Ref (initialize the variable) 
int getal = 0; 
Fun_RefTest(ref getal); 


Out (no need to initialize the variable) 
int getal; 
Fun_OutTest(out getal); 


The out and the ref parameters are used to return values in the same variables, that you pass an an argument of a method. These both parameters are very useful when your method needs to return more than one values. 

In this article, I will explain how do you use these parameters in your C# applications. 

The out Parameter 

The out parameter can be used to return the values in the same variable passed as a parameter of the method. Any changes made to the parameter will be reflected in the variable. 

public class mathClass 

public static int TestOut(out int iVal1, out int iVal2) 

iVal1 = 10; 
iVal2 = 20; 
return 0; 

public static void Main() 

int i, j; // variable need not be initialized 
Console.WriteLine(TestOut(out i, out j)); 
Console.WriteLine(i); 
Console.WriteLine(j); 



The ref parameter 

The ref keyword on a method parameter causes a method to refer to the same variable that was passed as an input parameter for the same method. If you do any changes to the variable, they will be reflected in the variable. 

You can even use ref for more than one method parameters. 

namespace TestRefP 

using System; 
public class myClass 

public static void RefTest(ref int iVal1 ) 

iVal1 += 2; 

public static void Main() 

int i; // variable need to be initialized 
i = 3; 
RefTest(ref i ); 
Console.WriteLine(i); 


Comparisions between Vb.net and C#.net

 Visual Basic .NET

1.Variables can be declared using the WithEvents construct.
2.Auto-wireup of events, VB.NET has the Handles syntax for events.
3.IsNumeric evaluates whether a string can be cast into a numeric value (the equivalent for C# requires using int.TryParse)
4.COM components and interoperability was more powerful in VB.NET as the Object type is bound at runtime,[12] however C#4.0 added the dynamic type which functions as a late bound form of Object
5.Namespaces can be imported in project level, so they don't have to be imported to each individual file, like C#
6.Assigning and comparing variables uses the same token, =. Whereas C# has separate tokens, == for comparison and = to assign a value
7.VB.NET is not case-sensitive.
8.Visual Basic .NET terminates a block of code with End BlockName statements

 C#

1.Allows blocks of unsafe code (like C++/CLI) via the unsafe keyword and support for pointers
2.Partial Interfaces
3.Multi-line comments
4.Static classes
5.Can use checked and unchecked contexts for fine-grained control of overflow/underflow checking
6.String concatenation can be performed using the numeric addition token, +, in addition to the string concatenation token &.
7.C# is case-sensitive.
8.In C#, the braces, {}, are used to delimit blocks.

what is the difference between .dll and .pdb ?

DLL:
dll file stands for Dynamic Link Library. This is the compiled version of the program you write into the programming language.
PDB
.pdb stands for Program database - this generally contains information about the debugging and project state and it gets created in the debug folder of the bin directory only when you compile/build your project in the Debug mode.

Wednesday, September 5, 2012

Usage Interface and its advantage


Interface:
–> If your child classes should all implement a certain group of methods/functionalities but each of the child classes is free to provide its own implementation then use interfaces.
For e.g. if you are implementing a class hierarchy for vehicles implement an interface called Vehicle which has properties like Colour MaxSpeed etc. and methods like Drive(). All child classes like Car Scooter AirPlane SolarCar etc. should derive from this base interface but provide a seperate implementation of the methods and properties exposed by Vehicle.
–> If you want your child classes to implement multiple unrelated functionalities in short multiple inheritance use interfaces.
For e.g. if you are implementing a class called SpaceShip that has to have functionalities from a Vehicle as well as that from a UFO then make both Vehicle and UFO as interfaces and then create a class SpaceShip that implements both Vehicle and UFO .

Use an interface

  • When creating a standalone project which can be changed at will, use an interface in preference to an abstract class; because, it offers more design flexibility.
  • Use interfaces to introduce polymorphic behavior without subclassing and to model multiple inheritance—allowing a specific type to support numerous behaviors.
  • Use an interface to design a polymorphic hierarchy for value types.
  • Use an interface when an immutable contract is really intended.
  • A well-designed interface defines a very specific range of functionality. Split up interfaces that contain unrelated functionality.
For Examble:
interface Shape {

 public double area();
 public double volume();
}
public class Point implements Shape {

 static int x, y;
 public Point() {
  x = 0;
  y = 0;
 }
 public double area() {
  return 0;
 }
 public double volume() {
  return 0;
 }
 public static void print() {
  System.out.println("point: " + x + "," + y);
 }
 public static void main(String args[]) {
  Point p = new Point();
  p.print();
 }
}

Usage Abstract class and its advantage


Abstract Classes
When you have a requirement where your base class should provide default implementation of certain methods whereas other methods should be open to being overridden by child classes use abstract classes.
For e.g. again take the example of the Vehicle class above. If we want all classes deriving from Vehicle to implement the Drive() method in a fixed way whereas the other methods can be overridden by child classes. In such a scenario we implement the Vehicle class as an abstract class with an implementation of Drive while leave the other methods / properties as abstract so they could be overridden by child classes.
The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share.
For example a class library may define an abstract class that is used as a parameter to many of its functions and require programmers using that library to provide their own implementation of the class by creating a derived class.

Use an abstract class

  • When creating a class library which will be widely distributed or reused—especially to clients, use an abstract class in preference to an interface; because, it simplifies versioning. This is the practice used by the Microsoft team which developed the Base Class Library. ( COM was designed around interfaces.)
  • Use an abstract class to define a common base class for a family of types.
  • Use an abstract class to provide default behavior.
  • Subclass only a base class in a hierarchy to which the class logically belongs.

For exapmple:
abstract class Shape {

 public String color;
 public Shape() {
 }
 public void setColor(String c) {
  color = c;
 }
 public String getColor() {
  return color;
 }
 abstract public double area();
}
public class Point extends Shape {

 static int x, y;
 public Point() {
  x = 0;
  y = 0;
 }
 public double area() {
  return 0;
 }
 public double perimeter() {
  return 0;
 }
 public static void print() {
  System.out.println("point: " + x + "," + y);
 }
 public static void main(String args[]) {
  Point p = new Point();
  p.print();
 }
}