Thursday, March 11, 2010

Difference between Interface and Abstract Class

When To Use Interfaces

----------------------------------------------------------------------------------
An interface allows somebody to start from scratch to implement your interface or implement your interface in some other code whose original or primary purpose was quite different from your interface. To them, your interface is only incidental, something that have to add on to the their code to be able to use your package.


When To Use Abstract classes

----------------------------------------------------------------------------------
An abstract class, in contrast, provides more structure. It usually defines some default implementations and provides some tools useful for a full implementation. The catch is, code using it must use your class as the base. That may be highly inconvenient if the other programmers wanting to use your package have already developed their own class hierarchy independently. In Java, a class can inherit from only one base class.


When to Use Both

---------------------------------------------------------------------------------
You can offer the best of both worlds, an interface and an abstract class. Implementors can ignore your abstract class if they choose. The only drawback of doing that is calling methods via their interface name is slightly slower than calling them via their abstract class name.

Interfaces vs Abstract Classes
------------------------------

1> :multiple inheritance-interface: A class may implement several interfaces.
abstract class :A class may extend only one abstract class.
=======================================================================
***********************************************************************
=======================================================================
2 :default implementation-interface: An interface cannot provide any code at all, much less default code.
abstract class: An abstract class can provide complete code, default code, and/or just stubs that have to be overridden.
=======================================================================
***********************************************************************
=======================================================================
3 :constants-interface: Static final constants only, can use them without qualification in classes that implement the interface. On the other paw, these unqualified names pollute the namespace. You can use them and it is not obvious where they are coming from since the qualification is optional.
abstract class: Both instance and static constants are possible. Both static and instance intialiser code are also possible to compute the constants.
========================================================================
***********************************************************************
========================================================================
4 :third party convenience-interface: An interface implementation may be added to any existing third party class.
abstract class: A third party class must be rewritten to extend only from the abstract class.
=======================================================================
***********************************************************************
=======================================================================
5 :plug-in-interface: You can write a new replacement module for an interface that contains not one stick of code in common with the existing implementations. When you implement the interface, you start from scratch without any default implementation. You have to obtain your tools from other classes; nothing comes with the interface other than a few constants. This gives you freedom to implement a radically different internal design.
abstract class: You must use the abstract class as-is for the code base, with all its attendant baggage, good or bad. The abstract class author has imposed structure on you. Depending on the cleverness of the author of the abstract class, this may be good or bad.
==========================================================================
************************************************************************
=========================================================================
6 :adding functionality-interface: If you add a new method to an interface, you must track down all implementations of that interface in the universe and provide them with a concrete implementation of that method.
abstract class: If you add a new method to an abstract class, you have the option of providing a default implementation of it. Then all existing code will continue to work without change.

______________________________________________________________________________
*********************************************************************************** ================ Important =================

Recognition of cost of downsizing and layoffs

A study of approximately 100 surplus workforce situations revealed that it would have been more cost effective not to have laid-off workers in 30 percent of the situations and to have laid off fewer workers in 20 percent. Layoffs have been criticized on the grounds that they are sometimes inefficient, relative to other cost-reduction strategies.
 A major inefficiency or cost associated with downsizing or layoffs is that a firm’s layoff practices may make it less attractive as a potential employer.
 A typical result of downsizing is that another 10 to 15 percent of an organization’s workforce will often quit after layoffs.
 The uncertainty of future employment often causes some of the better, more mobile employees to leave.
 In addition to bumping costs, there are also severance, administrative, and intangible costs. Intangible costs sometimes involve declines in morale of the remaining workforce and disruption of work group synergy.
Costs of Layoffs
Cost related to “Bumping” less senior employees
• Reduced productivity during Learning Period
• Cost of training employees assigned to other jobs
• Wage supplements for reassignments to jobs receiving Lower compensation
Cost Related to the termination of employees
• Separation payments
• Higher rates for unemployment compensation
• Depletion in the firm’s investments in training employees
Administrative Costs
• HR processing activities
• Clerical expenses
• Cost of conducting medical examination of laid-off employees
• Increased supervisory obligations for managers of reassigned employees
Intangible Cost
• Decline in morale of remaining employees
• Disruption of efficiency in work process
• Higher incidence of Accidents
• Depletion of Goodwill
• Irregular age distribution
• Voluntary turnover prompted by laid off

Wednesday, March 10, 2010

Summary of Operators : Computer Languages


Summary of Operators
The following quick reference summarizes the operators supported by the Java programming language.
Simple Assignment Operator
= Simple assignment operator
Arithmetic Operators
+ Additive operator (also used for String concatenation)
- Subtraction operator
* Multiplication operator
/ Division operator
% Remainder operator
Unary Operators
+ Unary plus operator; indicates positive value (numbers are positive without this, however)
- Unary minus operator; negates an expression
++ Increment operator; increments a value by 1
-- Decrement operator; decrements a value by 1
! Logical compliment operator; inverts the value of a boolean
Equality and Relational Operators
== Equal to
!= Not equal to
> Greater than
>= Greater than or equal to
< Less than <= Less than or equal to Conditional Operators
&& Conditional-AND
|| Conditional-OR
?: Ternary (shorthand for if-then-else statement)
Type Comparison Operator
instanceof Compares an object to a specified type
Bitwise and Bit Shift Operators
~ Unary bitwise complement
<< Signed left shift >> Signed right shift
>>> Unsigned right shift
& Bitwise AND
^ Bitwise exclusive OR
| Bitwise inclusive OR