Pages

Tuesday, December 28, 2010

Hacking Way: Download unlimited Videos or full high quality onl...

Hacking Way: Download unlimited Videos or full high quality onl...: "you can download unlimited videos from megavideo and download into many formats.. its very easy to use... Download Now"

Wednesday, December 22, 2010

10 Major Differences Between C And JAVA

The search analytics for the blog reveals that the most popular post on the site is on the differences
between C & C++ & moreover, people have been searching for C Vs Java and Java Vs C++.
So, here are the major differences between C And JAVA.

  1. JAVA is Object-Oriented while C is procedural. Different Paradigms, that is. Most differences between the features of the two languages arise due to the use of different programming paradigms. C breaks down to functions while JAVA breaks down to Objects. C is more procedure-oriented while JAVA is data-oriented.
  2. Java is an Interpreted language while C is a compiled language. We all know what a compiler does. It takes your code & translates it into something the machine can understand-that is to say-0’s & 1’s-the machine-level code. That’s exactly what happens with our C code-it gets ‘compiled’. While with JAVA, the code is first transformed to what is called the bytecode. This bytecode is then executed by the JVM(Java Virtual Machine). For the same reason, JAVA code is more portable. 
  3. C is a low-level language while JAVA is a high-level language. C is a low-level language(difficult interpretation for the user, closer significance to the machinelevel code) while JAVA is a high-level lagunage(abstracted from the machine-level details, closer significance to the program itself).
  4. C uses the top-down approach while JAVA uses the bottom-up approach.  In C, formulating the program begins by defining the whole and then splitting them into smaller elements. JAVA(and C++ and other OOP languages) follows the bottom-up approach where the smaller elements combine together to form the whole. 
  5. Pointer go backstage in JAVA while C requires explicit handling of pointers. When it comes to JAVA, we don’t need the *’s & &’s to deal with pointers & their addressing. More formally, there is no pointer syntax required in JAVA. It does what it needs to do. While in JAVA, we do create references for objects. 
  6. The Behind-the-scenes Memory Management with JAVA & The User-Based Memory Management in C. Remember ‘malloc’ & ‘free’? Those are the library calls used in C to allocate & free chunks of memory for specific data(specified using the keyword ’sizeof’). Hence in C, the memory is managed by the user while JAVA uses a garbage collector that deletes the objects that no longer have any references to them. 
  7. JAVA supports Method Overloading while C does not support overloading at all. JAVA supports function or method overloading-that is we can have two or more functions with the same name(with certain varying parameters like return types to allow the machine to differentiate between them). That it to say, we can overload methods with the same name having different method signatures. JAVA(unlike C++), does not support Operator Overloading while C does not allow overloading at all. 
  8. Unlike C, JAVA does not support Preprocessors, & does not really them. The preprocessor directives like #include & #define, etc are considered one of the most essential elements of C programming. However, there are no preprocessors in JAVA. JAVA uses other alternatives for the preprocessors. For instance, public static final is used instead of the #define preprocessor. Java maps class names to a directory and file structure instead of the  #include used to include files in C. 
  9. The standard Input & Output Functions. Although this difference might not hold any  conceptual(intuitive) significance, but it’s maybe just the tradition. C uses the printf & scanf functions as its standard input & output while JAVA uses the System.out.print & System.in.read functions. 
  10. Exception Handling in JAVA And the errors & crashes in C. When an error occurs in a Java program it results in an exception being thrown. It can then be handled using various exception handling techniques. While in C, if there’s an error, there IS an error.

10 Major Differences Between C And C++

C++, as the name suggests is a superset of C. As a matter of fact, C++ can run most of C code
while C cannot run C++ code. Here are the 10 major differences between C++ & C…

  1. C follows the procedural programming paradigm while C++ is a multi-paradigm language(procedural as well as object oriented) In case of C, importance is given to the steps or procedure of the program while C++ focuses on the data rather than the process. Also, it is easier to implement/edit the code in case of C++ for the same reason.
  2. In case of C, the data is not secured while the data is secured(hidden) in C++ This difference is due to specific OOP features like Data Hiding which are not present in C. 
  3. C is a low-level language while C++ is a middle-level language. C is regarded as a low-level language(difficult interpretation & less user friendly) while C++ has features of both low-level(concentration on whats going on in the machine hardware) & high level languages(concentration on the program itself) & hence is regarded as a middle-level language.
  4. C uses the top-down approach while C++ uses the bottom-up approach In case of C, the program is formulated step by step, each step is processed into detail while in C++, the base elements are first formulated which then are linked together to give rise to larger systems.
  5. C is function-driven while C++ is object-driven Functions are the building blocks of a C program while objects are building blocks of a C++ program. 
  6. C++ supports function overloading while C does not Overloading means two functions having the same name in the same program. This can be done only in C++ with the help of Polymorphism(an OOP feature)
  7. We can use functions inside structures in C++ but not in C. In case of C++, functions can be used inside a structure while structures cannot contain functions in C.
  8. The NAMESPACE feature in C++ is absent in case of C. C++ uses NAMESPACE which avoid name collisions. For instance, two students enrolled in the same university cannot have the same roll number while two students in different universities might have the same roll number. The universities are two different namespace & hence contain the same roll number(identifier) but the same university(one namespace) cannot have two students with the same roll number(identifier)
  9. The standard input & output functions differ in the two languages C uses scanf & printf while C++ uses cin>> & cout<< as their respective input & output functions 
  10. C++ allows the use of reference variables while C does not Reference variables allow two variable names to point to the same memory location. We cannot use these variables in C programming.

Friday, December 17, 2010

Normalization

Normalization is a method for organizing data elements in a database into tables.

Normalization Avoids
  • Duplication of Data  – The same data is listed in multiple lines of the database
  • Insert Anomaly  – A record about an entity cannot be inserted into the table without first inserting information about another entity – Cannot enter a customer without a sales order
  • Delete Anomaly – A record cannot be deleted without deleting a record about a related entity.  Cannot delete a sales order without deleting all of the customer’s information.
  • Update Anomaly – Cannot update information without changing information in many places.  To update customer information, it must be updated for each sales order the customer has placed

Normalization is a three stage process – After the first stage, the data is said to be in first normal form, after the second, it is in second normal form, after the third, it is in third normal form

Before Normalization

1.      Begin with a list of all of the fields that must appear in the database.  Think of this as one big table.
2.      Do not include computed fields
3.      One place to begin getting this information is from a printed document used by the system. 
4.      Additional attributes besides those for the entities described on the document can be added to the database.

Before Normalization – Example

See Sales Order from below:

Fields in the original data table will be as follows:
SalesOrderNo, Date, CustomerNo, CustomerName, CustomerAdd, ClerkNo, ClerkName, ItemNo, Description, Qty, UnitPrice
Think of this as the baseline – one large table

Normalization:  First Normal Form

  • Separate Repeating Groups into New Tables.
  • Repeating Groups  Fields that may be repeated several times for one document/entity
  • Create a new table containing the repeating data
  • The primary key of the new table (repeating group) is always a composite key; Usually document number and a field uniquely describing the repeating line, like an item number.

First Normal Form Example

The new table is as follows:
SalesOrderNo, ItemNo, Description, Qty, UnitPrice
The repeating fields will be removed from the original data table, leaving the following.
SalesOrderNo, Date, CustomerNo, CustomerName, CustomerAdd, ClerkNo, ClerkName
These two tables are a database in first normal form

What if we did not Normalize the Database to First Normal Form?

Repetition of Data – SO Header data repeated for every line in sales order.

Normalization:  Second Normal Form

  • Remove Partial Dependencies. 
  • Functional Dependency  The value of one attribute in a table is determined entirely by the value of another.
  • Partial Dependency A type of functional dependency where an attribute is functionally dependent on only part of the primary key (primary key must be a composite key).
  • Create separate table with the functionally dependent data and the part of the key on which it depends.  Tables created at this step will usually contain descriptions of resources.

Second Normal Form Example

The new table will contain the following fields:
ItemNo, Description
All of these fields except the primary key will be removed from the original table.  The primary key will be left in the original table to allow linking of data:
SalesOrderNo, Item No, Qty, UnitPrice
Never treat price as dependent on item.  Price may be different for different sales orders (discounts, special customers, etc.)
Along with the unchanged table below, these tables make up a database in second normal form:
SalesOrderNo, Date, CustomerNo, CustomerName, CustomerAdd, ClerkNo, ClerkName

What if we did not Normalize the Database to Second Normal Form?

  • Repetition of Data – Description would appear every time we had an order for the item
  • Delete Anomalies – All information about inventory items is stored in the SalesOrderDetail table.  Delete a sales order, delete the item. 
  • Insert Anomalies – To insert an inventory item, must insert sales order.
  • Update Anomalies – To change the description, must change it on every SO.

Normalization:  Third Normal Form

  • Remove transitive dependencies.
  • Transitive Dependency  A type of functional dependency where an attribute is functionally dependent on an attribute other than the primary key.  Thus its value is only indirectly determined by the primary key.
  • Create a separate table containing the attribute and the fields that are functionally dependent on it. Tables created at this step will usually contain descriptions of either resources or agents.  Keep a copy of the key attribute in the original file.

Third Normal Form Example

The new tables would be:
CustomerNo, CustomerName, CustomerAdd
ClerkNo, ClerkName
All of these fields except the primary key will be removed from the original table.  The primary key will be left in the original table to allow linking of data as follows:
SalesOrderNo, Date, CustomerNo, ClerkNo
Together with the unchanged tables below, these tables make up the database in third normal form.
ItemNo, Description
SalesOrderNo, ItemNo, Qty, UnitPrice

What if we did not Normalize the Database to Third Normal Form?

  • Repetition of Data – Detail for Cust/Clerk would appear on every SO
  • Delete Anomalies – Delete a sales order, delete the customer/clerk
  • Insert Anomalies – To insert a customer/clerk, must insert sales order.
  • Update Anomalies – To change the name/address, etc, must change it on every SO.

Completed Tables in Third Normal Form

Customers:  CustomerNo, CustomerName, CustomerAdd
Clerks:  ClerkNo, ClerkName
Inventory Items:  ItemNo, Description
Sales Orders:  SalesOrderNo, Date, CustomerNo, ClerkNo
SalesOrderDetail:  SalesOrderNo, ItemNo, Qty, UnitPrice