JavaScript document.getElementById

If you want to quickly access the value of an HTML input give it an id to make your life a lot easier.
This small script below will check to see if there is any text in the text field "myText". The argument that getElementById requires is the id of the HTML element you wish to utilize



<script defer="defer" type="text/javascript">

function notEmpty()

{

var myTextField = document.getElementById('myText');

if(myTextField.value != "")

alert("You entered: " + myTextField.value)

else

alert("Would you please enter some text?")

}

</script>

<input type='text' id='myText' />

<input type='button' onclick='notEmpty()' value='Form Checker' />





Difference between Abstraction and Encapsulation

Abstraction:

It is virtual class design.
Representation of data that how we represent it.
Before actually defining class developer will think about about the properties, methods and events will be there in class.

Encapsulation:

Hiding of unnecessary data.
At the time of class definition developers will think about which should display to end user and which should not.

Conclusion:
Abstraction is collection of data and Encapsulation is exposure of data in appropriate access specifier.

Difference between Rule and Check Constraint

Check Constraint:

Check constraint is associated with columns in a Table. So these can't be re-used.

Suppose if "Emp" table having the coulmn "Salary" then
alter table Emp add constraint ck_op Check (Salary between 15000 and 45000)

Rule:

Rules are defined with in a database and can be applied to any number of columns.
Creating Rule:
CREATE RULE SAL_RANGE
as
@Sal > 15000 and @Sal > 45000
Binding Rule to a Column:
SP_BINDRULE 'SAL_RANGE','Emp.Salary'


Encapsulation

When designing a class, it is generally a good practice to only reveal the necessary interfaces needed to interact with the object, and hide the implementation details that are not precisely relevant. This hiding of details is known as encapsulation.

The concept of encapsulation is better enforced with the definitions of interfaces and implementations. An interface is defined by the services of communication between objects. Classes declare some methods and properties as visible to outside objects, and hide the other details. The visible, or public, methods and properties become the interface to the object. Interfaces typically only include methods, since any need to access an attribute should be made available through a public method.

public class ClsEncapsulation
{
int SqrOutput;
public ClsEncapsulation()
{
}
//Visible method
public void AssignNumber(int GivenNumber)
{
CalculateSqluare(GivenNumber);
}
public void Display()
{
Console.WriteLine("Square of given number is " + SqrOutput.ToString());
}
//Hiding Method
private void CalculateSqluare(int GnNumber)
{
SqrOutput = System.Math.Pow(GnNumber,2);
}

}

Process Vs Thread

Process:
  • Process is a heavy weight running instance of a program.
  • A Process has its own memory space, runtime enivorment and process ID. One process can have multiple threads(It has atleast one main thread).
  • Processes must use interprocess communication to communicate with silbing processes.
  • Process is an architectural construct.

Thread:
  • A thread is the smallest schedulable unit of execution in aWindows application.
  • A thread always is associated with a particular process.Threads runs the code inside the process and share the address space with other threads inside the process i.e share process handles.
  • Threads can directly communicate with other threads of its process.
  • Thread is coding construct.