This blog is subject the DISCLAIMER below.

Sunday, April 27, 2008

How to save image in SQL Server database?

Q: How to save image in SQL Server database?

A: It's the most common question asked in technical forums, the answer is so simply is to convert your image to binary and save the equivalent binary data to the database.

I am expecting you know how to Insert\get data to\from SQL Server.

To convert image to binary you need to write this piece of code

   1: System.IO.FileStream fs = new System.IO.FileStream(@"ImagePath", System.IO.FileMode.Open);
   2:             byte[] imageAsBytes = new byte[fs.Length];
   3:             fs.Read(imageAsBytes, 0, imageAsBytes.Length);
   4:             fs.Close();


You need a table with column of binary\image datatype to be able to insert the equivalent binary data of image.

And what about retrieving binary data to be converted to image

You just need to initiate new Image from MemoryStream object which takes array of bytes as an argument -Array of bytes comes from SQL Server-



1: Image img = Image.FromStream(new System.IO.MemoryStream(imageAsBytes));


.. more.

Friday, April 25, 2008

How to bind ComboBox to an array of object?

Q: How to bind ComboBox to an array of object?

A:

Assume we have class like Student class

   1: public class Student
   2:     {
   3:         int id;
   4:  
   5:         public int ID
   6:         {
   7:             get { return id; }
   8:             set { id = value; }
   9:         }
  10:         string firstName;
  11:  
  12:         public string FirstName
  13:         {
  14:             get { return firstName; }
  15:             set { firstName = value; }
  16:         }
  17:         string lastName;
  18:  
  19:         public string LastName
  20:         {
  21:             get { return lastName; }
  22:             set { lastName = value; }
  23:         }
  24:  
  25:         public string FullName
  26:         {
  27:             get { return firstName + " " + lastName; }
  28:         }
  29:  
  30:         public Student(int id, string firstName, string lastName)
  31:         {
  32:             this.id = id;
  33:             this.firstName = firstName;
  34:             this.lastName = lastName;
  35:         }
  36:     }



what we need is to bind an array of Student to ComboBox and let the ComboBox shows the student FullName and bind their IDs to be used later.



So, what we need is to use some ComboBox properties like DisplayMember and ValueMember




   1: Student[] students = new Student[3];
   2:  
   3:             students[0] = new Student(1, "Ramy", "Mahrous");
   4:             students[1] = new Student(2, "FCI", "Helwan");
   5:             students[2] = new Student(3, "X", "Y");
   6:  
   7:             comboBox1.Items.AddRange(students);
   8:             
   9:             comboBox1.DataSource = students;
  10:             comboBox1.ValueMember = "ID";
  11:             comboBox1.DisplayMember = "FullName";




And now, ComboBox shows the FullName without overriding ToString method which is not the solution if we need to bind some properties.



Untitled

.. more.

Wednesday, April 23, 2008

Ubuntu 8.04 will be released tomorrow

The official site of Ubuntu promise the next major LTS version will be 8.04 (Hardy Heron), scheduled for release on April 24 2008 (tomorrow) .

Ubuntu is a community developed, Linux-based operating system that is perfect for laptops, desktops and servers. It contains all the applications you need - a web browser, presentation, document and spreadsheet software, instant messaging and much more ...

Ubuntu's URL : http://www.ubuntu.com/

.. more.

Wednesday, April 16, 2008

Cosmos Operating System

Cosmos is an open source operating system project that aims to be completely implemented in CIL compliant languages, that is currently 100% C#. It signifies everything that is important in Operating Systems: Universalization, Security, and Simplicity.


Design Overview

  • Completely .NET based.
  • Microkernel or close hybrid
  • Configurable using modules
  • Cross platform architecture

User Kit

Build your own shell, build and deploy in 30 seconds or less! See for yourself. The basic steps are:

  1. Install Cosmos user kit
  2. File, New, Cosmos Boot project from within Visual Studio.
  3. Modify the entry point. The default project has just a WriteLine.
  4. Run (F5). Cosmos will now build a boot disk and ask you what emulator to use. Press 3 to use included QEMU, or choose from VMWare, Virtual PC, ISO, PXE and more!
That is all you need to do! User kit tutorial.

Video Demo

Source :- http://www.gocosmos.org/index.en.aspx
http://www.codeplex.com/Cosmos
http://www.facebook.com/pages/Cosmos-Operating-System/102358427

.. more.

Nokia Games Innovation Challenge

The competition aim to encourage new concepts in mobile gaming world ,advanced features and functionalities .This competition target all Nokia platform ( Nokia N-Gage, Java or Symbian-based Series 40 or S60 device).

There are three prizes for first three innovative concepts ,in addition to produce this concept on the corresponding Nokia platform.
The first winner will be awarded 40,000 Euros .
The second winner will be awarded 20,000 Euros.
The third winner will be awarded 10,000 Euros.

The competition is open to game designer and developer companies worldwide. NOT to individual persons, employees of the Organizer and affiliated companies of the Organizer .

the deadline for submitting on 20th of August and the announcement for the winners will be on 29 of October.

The details can be read from here :
http://www.gamingchallenge.org/main.php

.. more.

Microsoft Visual Studio Team System Code Name "Rosario"

Microsoft® Visual Studio® Team System code name “Rosario” is the version of Team System that follows Visual Studio Team System 2008. It is an integrated Application Life-cycle Management (ALM) solution comprising tools, processes, and guidance.

i heard in the last EDC - Egyptian developers conference- that Rosario will not be released with a new dotnet framework, it will work with dotnet framework 3.5 like VSTS2008.

Some of the major scenarios and features in this release will include:

  • Joint prioritization and management of IT projects through integration with Microsoft Project Server
  • Project management across multiple projects for proactively load balancing resources according to business priorities
  • Full traceability (inc. hierarchical work items) to track project deliverables against business requirements and the ability to conduct rapid impact analysis of proposed changes
  • Comprehensive metrics and dashboards for shared visibility into project status and progress against deliverables
  • Powerful new features to enable developers and testers to quickly identify, communicate, prioritize, diagnose and resolve bugs
  • Integrated test case management to create, organize and manage test cases across both the development and test teams
  • Testing automation and guidance to help developers and testers focus on business-level testing rather than repetitive, manual tasks
  • Quality metrics for a ‘go/no-go’ release decision on whether an application is ready for production and has been fully tested against business requirements
  • Rapid integration of remote, distributed, disconnected and outsourced teams into the development process
  • Easy customization of process and guidance from Microsoft and partners to match the way your team works
  • Integrated support to build setup packages using Windows Installer XML technology
  • Improvements to multi-server administration, build and source control.
Source :- http://msdn2.microsoft.com/en-us/vstudio/bb725993.aspx
for more information :- http://msdn2.microsoft.com/en-us/vstudio/bb936702.aspx

.. more.

Tuesday, April 15, 2008

FCI-H rocked ImagineCup competition


Yes, FCI-H rules; whenever we are; we have the big share, last Saturday 12April 2008 ImagineCup local finals held in Smart Village and 2 teams from Faculty of Computers and Information -Helwan University- have won, they catch the first and the third place, and the first will fly to France to represent Egypt not just their University and we all hope for them the big success.
The first place team:
Mahmoud Hassan
Ramy Essam
Ahmed Galal
Abd-ALLAH Haza'e
The Third place team:
Mona Rageb
Ahmed Gamal
Yassmin Abbas
Ahmed Shawe'y
Congratualtion and really thank you; we are proud of you.

.. more.

Sunday, April 13, 2008

UX REVEALED!


The event is mainly targeting designers and developers in Egypt, focusing on .NET developers to enrich the User Experience in their application and unveil the Usability to build a new Rich Internet Applications. Also empowers the Adobe Technology and increase the awareness between students and fresh graduates to give them a shed light on updated technology in the market.

To register: http://barmagy.com/adobe/default.aspx

.. more.

Friday, April 04, 2008

Vodafone Betavine Egypt competition


Welcome to the Vodafone Betavine Egypt competition!

Vodafone is offering all University students in Egypt the chance to win up to 5,000 euros, in its first mobile software development competition in Egypt. We believe students in Egypt have great innovation, resourcefulness and creativity, and we'd like to help you bring your ideas to life!If you've got what it takes to win the competition – hurry up, register now and make sure you tell all your friends who are also University students in Egypt.
Be sure to also read our Competition Guidelines for more information about how to enter competitions on Betavine.

The Brief
Develop an innovative mobile application based around one of the four concepts:
Social Networking and Communications
Information & Entertainment
Ofice & Business to Business
Social Impact

Description
The competition is deliberately left open and flexible in order to not inhibit the imagination and inventiveness of students. The application should be based around the four aforementioned areas.
Get started by following the Student Competition Guidelines 2008 instructions on How to enter a Student Competitions. The four areas that an application can compete in are described in more detail below:
Social Networking - Serving the needs of communities which share the same interests, providing a total communications experience E.g. at home, out and about, at play and at work.
Information and Entertainmnet - Serving the needs of people users encounter each day, getting news, local information, listen to their favourite music, TV, play games, at home or on the move.
Office and Business to Business - Serving the needs of companies and their employees, e.g. business travellers, sales people, payment systems.
Social Impact - Serving the needs of the big trends and challenges in future societies, e.g. healthcare, energy conservation, traffic control and logistics.

Read more on: http://betavine.net/web/guest/projects/students/egypt_competition

.. more.

Thursday, March 27, 2008

Amazon S3 via C#

Amazon Simple Storage Service (Amazon S3) via C#

Amazon S3 is storage for the Internet. It is designed to make web-scale computing easier for developers. It’s provides a simple web services interface that can be used to store and retrieve any amount of data, at any time, from anywhere on the web.

It uses standards-based REST and SOAP interfaces so it is platform independent and language independent.

It `s commercial but highly scalable, reliable, fast and inexpensive data storage infrastructure.

To know more about its advantage and the cost click here:

http://www.amazon.com/gp/browse.html?node=16427261

I am writing here to give you my experiences and tricks which I faced it when I started in develop the service using Dot Net (C#) and soap.

First trick:

When you work using .Net, you must use WSE 2.0 NOT WSE 3.0 as Amazon support DIME (WSE 2.0) NOT MTOM (WSE 3.0).

Second trick:

You can only using the class System.Web.Services.Protocols.SoapHttpClientProtocol, if you want upload files to AWS (Amazon Web Service) that are less than one Megabytes.

Here is an excellent example that server the required (files less than megabyte) with complete demo code for view and upload files.

http://developer.amazonwebservices.com/connect/entry.jspa?externalID=774&categoryID=55

Third trick:

If your files are bigger than one Megabytes (ten, twenty or may be 50 megabytes), you must to change the class System.Web.Services.Protocols.SoapHttpClientProtocol to Microsoft.Web.Services2.WebServicesClientProtocol . (As mentioned in this link)

http://developer.amazonwebservices.com/connect/entry!default.jspa?categoryID=103&externalID=689&fromSearchPage=true

Then follow the last trick...

Last trick:

You must raise the Timeout property that inherits the Microsoft.Web.Services2.WebServicesClientProtocol (the AmazonS3class if you opened the following example) more time out (this property measures in milliseconds) .

Here it an excellent example that server the required (more than one megabyte) with complete code.

http://developer.amazonwebservices.com/connect/entry!default.jspa?categoryID=47&externalID=690&fromSearchPage=true

The Amazon S3 Developer Guide :

http://docs.amazonwebservices.com/AmazonS3/2006-03-01/

.. more.

EDC registration is open!

Microsoft EDC
EDC 2008 is the biggest Developers Conference of the year in Egypt, and is a critical event for any developer who wants to see the newest as well as the next-generation technology. EDC is full of sessions and activities that help you to learn the current and the future of the Microsoft Platform and get to know people who are as passionate about software as you are.

Benefits of Attending EDC 2008
Egyptian Developer Conference is designed to help those who build, deploy, or operate solutions based on Microsoft technologies. It helps professional developers, designers, analysts and architects to learn the capabilities and the possibilities with the current Microsoft .Net Platform. It also helps technology managers evaluate the range of technologies to consider for the future growth and management of their ongoing IT systems needs and requirements.

Who should attend
Whether you are an amateur developer, a "code-guru" or anything in between, you need to be at the biggest developer conference in the region. Code developers, webmasters, web designers, infrastructure architects, applications & database developers, hobbyists or just plain geeks: If your job title has even a passing resemblance to any of these, be sure to be there. This developer conference is your window into the future of the Microsoft platform and the software industry as a whole. After the event, you'll be more informed, more skilled, and more inspired than ever before.

Hurrrry up registration is limited...
Registration: http://www.edc2008.com/Register.aspx
Agenda: http://www.edc2008.com/Agenda.aspx

.. more.

CNAME

In the name of Allah,

Today I will present a common name or definition between networks administrator and we (as developers) may hear it specially if you are a web developer. It is a CNAME or CNAME record.

CNAME is abbreviated term to canonical name. CNAME is a record in DNS database to domain name aliases.

Any computer sure has a domain name (IP) to be visible throw the internet, but what about you if you want to call by more than one name (domain aliases )!!! What about your site if you want to change the old site’s name to new one and you want your site to be available for the users from the both the two domains (old and new name)!!!

How www.googel.com (as you see el NOT le ... googel NOT Google ) opens the right site www.google.com (*le NOT *el)!!!

The all previous scenarios are done by the same way CNAME (adding DNS record for domain aliases)…

Simple example :

www.abc.com CNAME www.xyz.com

www.12345.com CNAME www.xyz.com

so any requests ordered as www.abc.com or www.12345.com will be serve to open www.xyz.com .

you may browse Wikipedia’s DNS page for more information .

http://en.wikipedia.org/wiki/Domain_Name_System

.. more.

Sunday, March 23, 2008

The Building Information Model (BIM)

The Building Information Model (BIM) is a set of information generated and maintained throughout the life cycle of a building. BIM is the process of generating and managing a building information model.

BIM covers geometry, spatial relationships, geographic information, quantities and properties of building components (for example manufacturers' details). BIM can be used to demonstrate the entire building life cycle including the processes of construction and facility operation. Quantities and shared properties of materials can easily be extracted. Scopes of work can be isolated and defined. Systems, assemblies, and sequences are able to be shown in a relative scale with the entire facility or group of facilities.

BIM is able to achieve such improvements by modeling representations of the actual parts and pieces being used to build a building. This is a substantial shift from the traditional computer aided drafting method of drawing with vector file based lines that combine to represent objects.

Read more about BIM:

http://en.wikipedia.org/wiki/Building_Information_Modeling

http://bim.arch.gatech.edu/?id=402


-> Check Autodesk Green Research
http://usa.autodesk.com/adsk/servlet/item?id=10262483&siteID=123112

Watch the video on youtube.

-> Check also BIM by Professor Charles M. Eastman at Georgia Institute of Technology

http://bim.arch.gatech.edu/


.. more.

Friday, March 14, 2008

The Singularity Research Development Kit

At Tuesday, February 13, 2007 Shereef Saker has posted article on FCI-H about Singularity: A research OS written in C# while going through Microsoft Student Partners forum I found a post sent by Matthieu Suiche an MSP from France informing about Singularity first release...

Microsoft research page: http://research.microsoft.com/os/singularity/
The Singularity Research Development Kit (RDK) 1.1 is now available for academic non-commercial use. You can download it from CodePlex, Microsoft's open source project hosting website, here. http://www.codeplex.com/singularity

Overview:
Singularity is a research project focused on the construction of dependable systems through innovation in the areas of systems, languages, and tools. We are building a research operating system prototype (called Singularity), extending programming languages, and developing new techniques and tools for specifying and verifying program behavior.
Advances in languages, compilers, and tools open the possibility of significantly improving software. For example, Singularity uses type-safe languages and an abstract instruction set to enable what we call Software Isolated Processes (SIPs). SIPs provide the strong isolation guarantees of OS processes (isolated object space, separate GCs, separate runtimes) without the overhead of hardware-enforced protection domains. In the current Singularity prototype SIPs are extremely cheap; they run in ring 0 in the kernel’s address space.
Singularity uses these advances to build more reliable systems and applications. For example, because SIPs are so cheap to create and enforce, Singularity runs each program, device driver, or system extension in its own SIP. SIPs are not allowed to share memory or modify their own code. As a result, we can make strong reliability guarantees about the code running in a SIP. We can verify much broader properties about a SIP at compile or install time than can be done for code running in traditional OS processes. Broader application of static verification is critical to predicting system behavior and providing users with strong guarantees about reliability.

.. more.

Monday, March 10, 2008

OOP Design Concepts - Abstract Classes

hey all, and specially soli who asked about abstract classes.
In this post we discuss abstract classes, however, it would be better if you read the post titled OOP Design Concepts - Interfaces first.

- What is an abstract class?

Abstract classes are partial classes, in other words, they are classes that needs to be inherited by other classes to be used. The word abstract means that methods inside such class are not completely implemented, an abstract class can mark some methods as abstract, so, the child class needs to implement them according to its behavior. An abstract class works as a generalized type that needs specialization for each subtype.



Well, i hate those complex descriptions, so lets get to the example mentioned previously in OOP Design Concepts - Interfaces. The case was that we had different types of cars and we specified their behavior by an interface named "iMovable", now, lets consider an extension to that design. Suppose that all cars starts using the same way using the same method of ignition, so, it is not relevant for every car to implement the method named "Start" with the same implementation. In this case we will introduce the abstract class named "Car", this class implements the "iMovable" interface and introduces a new method named "Start" and implements it. Now, any new car will extend the abstract car instead of directly implementing "iMovable".

- A closer look.
So, we did not forget that the abstract car implements iMovable, but we did not mention any thing about implementing iMovable's methods?. yes, the methods are still treated the same way, as the classes extending the abstract car are still responsible for providing the actual implemenation of such methods, in our case, it is the single move method. Methods in interfaces are abstract by default, and marking a class as abstract indicates that this class is not yet complete, so it has the option to implement what it wants from the interface, and in our case, we need nothing from the interface to be implemented in the abstract car.
Now, any car extending the abstract car can use the start method directly but it still have to implement how the move method will be implemented.
An abstract class may implement methods declared in an interface, thus, making it an option for subclasses to override those methods or not.

-Why?
The previous modification makes classification perfect, as we said before, it is all about logical thinking, reconsidering the first design that rely only on interfaces, you will find it not logic that every movable object is a car!!, so, abstract classes provides an extra level of specialization, as we can introduce an extra specification level to more subtypes. In our case, we defined a common behavior for cars, if we have planes, we will introduce the plane type the same way we did with cars.

-Coding
lets see an java code segment declaring our example class.

public abstract class Car implements iMovable{

public void start()
{
//code for starting engine
}

//Another method marked abstract for implementation by child classes
public abstract void koko();
}


public class NormalCar extends Car{

//The method declared by the iMovable interface.
public void move()
{
//code for moving...
}

public void koko()
{
//Code for the koko method which does anything.....
}

}


Marking a method as abstract, makes it a must for child classes to implement such a method or the code will not compile, thus forcing the same kind of behavioral description provided by interfaces in the older design.

.. more.

Saturday, March 08, 2008

Wikimania 2008, Alex, Egypt, Call for participation Deadline is drawing near

Wikimania 2008
For those who visit my blog probably you know since long but I just realized that I (myself) don't visit my friends blogs, for more than a year, may be (long live Google, Reader.. or is it "Don't"..lol)..

Anyway, I'm just making sure that you know that Wikimania2008 (which will be held on 17-19 July, Alex, Egypt) call for participation deadline is drawing near. It is March 16, 2008.. So if you want to attend as a speaker, hurry up!!

If you rather be a regular attendee -like me ;)- you'll have to just wait & keep tuned to the event page (that's http://wikimania2008.wikimedia.org/wiki/Main_Page )..

I waited.. so much for the organizers to make an FB event but they didn't.. so I'll :P ( as if it's a must.. lol)

.. more.

Thursday, March 06, 2008

Save As PDF using C#

Welcome guys , this day we will display an esay way to convert files from any format that Microsoft Office open to PDF file format using simple C# code.

Frist of all you should to install 2007 Microsoft Office Add-in: Microsoft Save as PDF (very small about 934 KB) .

Click here to download it from Microsoft site

After you have finished your setup , you should to have new save as option like the picture .

saveasPDF


Secondly : add this two reference to your DotNet project as you see in this picture .

refrences

Then insert the required namespaces in the project ..

Like here :

using System;

using System.Data;

using System.Text;

using System.IO;

using Microsoft.Office.Interop.Word;

finally : here is the class called Doc2PDFAtServerClass , this class have only one static function word2PdfFcih which have two paramters .

this is a example :

object SourceFileName = “Fci-H.doc” ;

object newFileName = “Fci-H.pdf” ;

static public class Doc2PDFAtServerClass

{

static public void word2PdfFcih(object SourceFileName, object newFileName)

{

//Pid++;

Microsoft.Office.Interop.Word.ApplicationClass MSdoc = null;

//object Source = "d:\\Document" + Pid.ToString(System.Globalization.CultureInfo.CurrentCulture) + ".doc";

object Source = SourceFileName;

object readOnly = false;

object Unknown = System.Reflection.Missing.Value; //Type.Missing;

object missing = Type.Missing;

try

{

//Creating the instance of Word Application

if (MSdoc == null)

MSdoc = new Microsoft.Office.Interop.Word.ApplicationClass();

MSdoc.Visible = false;

MSdoc.Documents.Open(ref Source, ref Unknown,

ref readOnly, ref Unknown, ref Unknown,

ref Unknown, ref Unknown, ref Unknown,

ref Unknown, ref Unknown, ref Unknown,

ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown);

MSdoc.Application.Visible = false;

MSdoc.WindowState = Microsoft.Office.Interop.Word.WdWindowState.wdWindowStateMinimize;

object FileName = newFileName;

object FileFormat = WdSaveFormat.wdFormatPDF;

object LockComments = false;

object AddToRecentFiles = false;

object ReadOnlyRecommended = false;

object EmbedTrueTypeFonts = true;

object SaveNativePictureFormat = false;

object SaveFormsData = false;

object SaveAsAOCELetter = false;

//object Encoding = MsoEncoding.msoEncodingUSASCII;

object InsertLineBreaks = false;

object AllowSubstitutions = false;

object LineEnding = WdLineEndingType.wdCRLF;

object AddBiDiMarks = false;

/*

to get more details about SaveAs(...) function and it's parameter ,read this microsoft's link

http://msdn2.microsoft.com/en-us/library/aa662158(office.10).aspx

*/

MSdoc.ActiveDocument.SaveAs(ref FileName, ref FileFormat, ref LockComments,

ref missing, ref AddToRecentFiles, ref missing,

ref ReadOnlyRecommended, ref EmbedTrueTypeFonts,

ref SaveNativePictureFormat, ref SaveFormsData,

ref SaveAsAOCELetter, ref /*Encoding*/missing, ref InsertLineBreaks,

ref AllowSubstitutions, ref LineEnding, ref AddBiDiMarks);

}

catch (FileLoadException e)

{

Console.WriteLine(e.Message + "Error" );

}

catch (FileNotFoundException e)

{

Console.WriteLine(e.Message + "Error");

}

catch (FormatException e)

{

Console.WriteLine(e.Message + "Error");

}

finally

{

if (MSdoc != null)

{

MSdoc.Documents.Close(ref Unknown, ref Unknown, ref Unknown);

//WordDoc.Application.Quit(ref Unknown, ref Unknown, ref Unknown);

}

// for closing the application

// WordDoc.Quit(ref Unknown, ref Unknown, ref Unknown);

MSdoc.Quit(ref Unknown, ref Unknown, ref Unknown);

MSdoc = null;

}

}

}

Have fun ;) ..

.. more.

Setting Up ANT !!!

One of the most boring tasks is to set up ant to work on your computer, it is really a a very boring task that i usually spend a good amount of time doing and if i need to set it up again for any reason i discover that i do not remember and the spaghetti of environment variables begin :S. So, this post is to remind me rather than any body else what i need to do when setting up ANT :).

After downloading ANT, you need to specify some paths in the environment variables in order to work just by writing "ant" on the command line:

-In case you do not know where to find the environment variables :
right click on my computer -> advanced -> Environment variables.

-Make sure you have a JDK installed, and set the variable JAVA_HOME with the installation path of the JDk. e.g; c:\jdk1.6.0_02

- Make a variable named ANT_HOME with the path to installation directory to ant, e.g; C:\apache-ant-1.7.0

- MAKE SURE to add the path to the bin folders of both the jdk and ant to the "path" variable. The "path" variable must contain these two entries:
C:\jdk1.6.0_02\bin;C:\apache-ant-1.7.0\bin

Hopefully, you will get ANT working by now. If you do not know what ANT is, you can wait to see the coming post :).

.. more.

Wednesday, March 05, 2008

OOP Design Concepts - Interfaces

What is an interface in OOP?
During the process of designing an application using OOP Paradigm, the application will be designed as a set of classes indicating how objects will be created each with specific status and behavior, as well as defining the ways of interaction between those objects. By this way, almost every class indicates a type(an abstracted data type in a more specific manner).
For example, a class named car indicates an object of type car that has a set of status variables and a set of methods that indicates how other objects can interact with it. Consider that we have a car that have the normal four wheels and another type that uses one wheel in the middle of the car to move!!.
The common behavior between the two types of cars is that they can move, either on 4 wheels or 1 wheel it does not make a difference, all what we care about is that they can move, so, simply we can consider the two cars as "Movable". The word movable indicates the ability of the two objects to move which is an indication of the behavior of them without concerning other details like; the model of the car or even the way they can move. These are interfaces.
Interfaces indicate how certain types of objects have to behave. If we want to indicate clearly how a movable object must behave, we will create an interface with a method named " move" and make every movable object provide how this method will be implemented.
In our example; we will create something like what follows:

public interface iMovable
{
public void move();
}

public class normalCar implements iMovable
{
//actual implementation of the move method declared in iMovable
public void move()
{
//the code required to make a normal car move
}
}

public class weirdCar implements iMovable
{
public void move()
{
//the weird code to make a weird car move
}
}


So, why do we need interfaces?
OOP tries to resemble how objects are defined in the real life, and interfaces are a very logical way of grouping objects in terms of behavior. Suppose that we are making a game that has the normal and the weird car,however, a creative team member came with the idea that we need to make the extra super weird car with no wheels and with the ability to turn to a frog to hide from enemies and many many extra features. If we are not using interfaces, the game logic will need to handle the motion of each car as if they are of different type in spite that logically they share the core common behavior.
Interfaces also enhance abstraction which is a core principal of OOP, design patterns like the factory pattern make a perfect use of interfaces through abstracting objects to know which implementation of a certain object type is provided. Interfaces make it very flexible to change implementations of services specially in multilayer applications, for example; in an application, we have a data base layer that have an object named UserDb which is responsible to get the data of the user from the database, and we have another one named UserTxtFile which retrieves the information from a plain text file.
Each of the user objects can be used by a higher layer to retrieve the user data without any modification to the code, inspect the following code:

public interface iUserInfo
{
string getUserName(int userId);
string getUserAge(string username);
}

public class UserDb implements iUserInfo
{
string getUserName(int userId)
{
//code to retrieve user info from the database
}
}

public class UserTxtFile implements iUserInfo
{
string getUserName(int userId)
{
//code to retrieve user info from the plain text file
}
}

public class UserManager()
{
private iUserInfo userInfo;

public string retrieveUserData(string userName)
{
return userInfo.getUserAge(userName);
}
}


Take a close look at the manager class and you will find that it has a reference variable of type iUserInfo, so, if this reference is provided by a factory method or by any other means, the code of the manager class will be the same regardless what implementation is provided. This approach maximizes flexibilty if some implementations need to be altered during the process of software development, as higher level layers will not be affected at all.
Another benefit of interfaces shows up during the development of large projects by large teams, at which the interface acts as a specification for developers with the set of methods they need to implement in classes of a certain type.

What interfaces are NOT?
- Unless the interface specifies a common behavior, do not create one. A common mistake is to use interfaces just to make some constants visible to objects in different layers.
- Interfaces are not a work around to multiple inhertience.

I hope i could make my points clear enough, and about the super car that turns to a frog ; i think it is a good idea. think about it :) .

.. more.