This blog is subject the DISCLAIMER below.

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.

Monday, March 03, 2008

launching SQL 2008 in Egypt

As we mentioned before the global launch for SQL 2008 had been on 27 of Feb , Now, We have the pleasure to announce the launching SQL 2008 in Egypt will be in March 24 (Intercontinental City Stars Hotel) , but unfortunately the attendance is by Invitation Only :( .

You can see the agenda of the day and more information from here :
http://www.microsoft.com/middleeast/egypt/launch2008/register/default.aspx

.. more.

Wednesday, February 27, 2008

Finally EDC date released!!

Microsoft Egyptian Developers' Conference

Today, while checking my Facebook, I found Sherif El-Touny has announced the date of EDC (Egyptian Developers' Conference) finally it released :-) it'll be from 13th to 15th APRIL
I hope to see all there if I could attend, I'll keep you updated with any news...

.. more.

Saturday, February 23, 2008

ERP Solutions & CRM Application

- ERP Solutions & CRM Application :

Did you see these words "ERP & CRM" when you browse software companies' web sites !!!! , so what these words mean ???


- ERP Solutions :

ERP is short for enterprise resource planning , a business management system that integrates all facets of the business, including planning, manufacturing, sales, and markting . ERP Soultions are software applications that help business managers to control business activities such as inventory control, order tracking, customer service, finance and human resources


-CRM Applications :

Short for customer relationship management. CRM entails all aspects of interaction a company has with its customer, whether it be sales or service related .Because of revolution of information technologies , the interaction between companies and their customers is done through a web site application or through WAP phones .So that CRM application is a web application that can interact with customers to gain informations about these customers and through these information we can organise it for proper analysis and action. It is needed to keep that information up-to-date, make it accessible to employees, and provide the know-how for employees to convert that data into products better matched to customers' needs.

For examples about ERP solutions and CRM application products in real life, visit this web site :
-http://ajyal.com/en/index.html " ERP solutions "
-http://ajyal.com/en/solutions/non_commercials.html " CRM application "

.. more.

Friday, February 22, 2008

Microsoft Student Festival

The Modern Approach To Learning
Did you hear about Microsoft Student Festival??
The Microsoft Student Festival is the first event of its kind held on a university campus in the Middle East. It’s objective is to allow students the opportunity to interact directly with Microsoft and learn more about its products and programs. The event also presents opportunities to meet Microsoft partners, regional sponsors, and of course, fellow students.

ATTENDANCE IS BY INVITATION ONLY and you need to register here. hurrrrrrrrrrrry up and take your invitation from your MSP, we are looking forward seeing you there ",)

.. more.

Thursday, February 21, 2008

Debugging Tomcat web applications using JDeveloper

Hello All

I managed to enable JDeveloper to debug with tomcat and here are the steps to accomplish that.

As a prerequisite for this, you must have a tomcat server locally installed. I need to note also that this way you won’t be able to debug jsp files (Only classes). Actually there is a way around that but it’s so buggy and tiresome.

First you need to add those lines to the java options in tomcat configuration:

-Xdebug

-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

Second, go to the folder where tomcat is installed (for me it is “C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\Catalina\localhost”) and create a file called “project1.xml” for example, and paste this line in it.

project1\ViewController\public_html" path="/project1" reloadable="true" />

Where

docBase is the path to your public_html folder

reloadable=”true” allows tomcat to pickup any changes that you make to your jsps.

Path is the path that you can access your web application through.

Third, you need to create a new run configuration for tomcat (we need a remote debugging configuration):

* Check “Remote Debugging and Profiling”
* Go to Debugger -> Remote and change
o Protocol à Attach to JPDA
o Host à 127.0.0.1 as we are debugging through the locally installed tomcat server.
o Port à 8000 ( It should match the port specified in the tomcat configuration as in step 1)

Fourth, we need to change the Output Directory from “ViewController\classes” to “ViewController\public_html\WEB-INF\classes”

And to do this go to View Controller Project settings then to Project Content and change the Output Directory Textbox.

.. more.

Tuesday, February 19, 2008

DreamSpark

How would you like a free copy of Microsoft Visual Studio 2008? How about the entire Microsoft Expression Studio? Not enough...... how about Microsoft Windows Server 2003 and more?

For once, something that sounds too good to be true really is this good and really is true. Starting today (or soon in some areas), students worldwide will be able to download our professional development and design tools for free! It's called DreamSpark and it is upon us.

More on: http://channel8.msdn.com/Posts/2047/

.. more.

Monday, February 18, 2008

A common bar-code problem

A tiny detail that is usually missed when working with bar-codes (written in fonts like: "3 of 9 Extended", etc) is writing the bar-code text between brackets or asterisks:

myLabel.Text = "*"+myBarcode+"*";

or

myLabel.Text = "("+myBarcode+")";

Forgetting using one of the above ways makes the code unreadable by bar-code readers..

.. more.

C# : indexed pixel problem

Here I will mention the solve for a common problem happens when you try to create Graphic object from Bitmap images as in the next two lines..yes, it would fire an exception if your bitmap was indexed pixel .

Bitmap tmp = new Bitmap("Fci-h.jpg");
Graphics grPhoto = Graphics.FromImage(tmp);

Exception : "A Graphics object cannot be created from an image that has an indexed pixel format".

To pass this exception you will need to add some additional lines of code . Just create an image with the same size like the original image (Fci-h.jpg) then draw the original image onto the new Graphics object .

Here is an Example :

Bitmap bm = (Bitmap) System.Drawing.Image.FromFile("Fci-h.jpg",true);
Bitmap tmp=new Bitmap (bm.Width ,bm.Height );
Graphics grPhoto = Graphics.FromImage(tmp);
grPhoto.DrawImage(bm, new Rectangle(0, 0, tmp.Width , tmp.Height ), 0, 0, tmp.Width , tmp.Height , GraphicsUnit.Pixel);

.. more.

Ropes for Java

A Rope is an alternative to the traditional java String. A rope is a kind of heavy weight String that perform faster and more effcient in terms of modification. Basically, the rope is not effcient in normal string operations, but, it is powerfull when in appending its conents, also looping a rope is linear, which means a great performance in terms of time. A Rope is represented as a tree rather than an array of characters as the normal String.

For a deeper look: click here. or here.
To download the latest version of ropes: click here.

.. more.

Thursday, February 14, 2008

Stamping text file in PDF pages

I wrote C# function that Stamping the content of text file (text and hyper links) at the front of the select pages (selected by the user) from the PDF .

NOTE :
This C# function stamp the text with aligning the text at the center of the selected pages ,the function based on the latest library called ItextCharp ( iTextSharp 4.0.8 (2008-01-25) .
Download the library from here

iText

# (iTextSharp) is a port of the iText open source java library written entirely in C# for the .NET platform.
iText is a library that allows you to generate PDF files on the fly. It is implemented as an assembly.

Parameter Example :

string sourcefile --> "input.pdf"
string SaveFileName--> "output.pdf"
float Y_space --> 405
float lead--> 25
float FontSize --> 12
string TxtFileName--> "textostamp.txt"
string _Font --> "HELVETICA"
string pagesRange --> "3,6,8" or "3-6,9-15"


you must to import this namespaces :)
using System.IO;
using iTextSharp.text.pdf;
using iTextSharp.text;
==

/* StamperTxt is a class which stamps the content of text file (text and hyper links)

* at the front of the select pages (selected by the user)from the PDF .

* */

public StamperTxt(string sourcefile, string SaveFileName, float Y_space, float lead, float FontSize, string TxtFileName, string _Font , string pagesRange)

{

PdfReader pdfreader = new PdfReader(sourcefile);

float pagewidth = pdfreader.GetPageSize(1).Width;

int j = pdfreader.NumberOfPages;

bool[] flag ;

flag = new bool[j];

for (int i = 0; i <>

flag[i] = false;

if ((pagesRange.Trim() == "all" )&&(pagesRange.IndexOf("-") == -1 )&&(pagesRange.IndexOf(",") == -1 ) )

{

for (int ii = 0; ii <>

flag[ii] = true;

}

else if ((pagesRange.IndexOf("-") != -1))

{

string[] tempArr = pagesRange.Trim().Split(',');

foreach (string str in tempArr)

{

string[] tempArrhyphen = str.Trim().Split('-');

int startIndex = 0, endIndex = 0;

startIndex =int.Parse(tempArrhyphen[0].Trim());

endIndex = int.Parse(tempArrhyphen[1].Trim());

for (int s = startIndex; s <= endIndex; s++)

{

flag[s-1] = true;

}

}

}

else if ((pagesRange.IndexOf(',') > -1))

{

string[] tempArr = pagesRange.Trim().Split(',');

foreach (string str in tempArr)

{

int index = int.Parse(str);

flag[index-1] = true;

}

}

PdfGState pdfgstate = new PdfGState();

pdfgstate.FillOpacity = 1.0f;

Stream output_stream = new FileStream(SaveFileName, FileMode.OpenOrCreate);

PdfStamper pdfstamper = new PdfStamper(pdfreader, output_stream);

for (int k = 0; k <>

{

if (flag[k] != true)

continue;

PdfContentByte pdfcontentbyte = pdfstamper.GetOverContent(k+1);

float v_space = Y_space;

pdfcontentbyte.SaveState();

pdfcontentbyte.SetGState(pdfgstate);

BaseFont PF = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, false) ;

pdfcontentbyte. SetFontAndSize(PF , FontSize);

StreamReader SR;

string S;

SR = File.OpenText(TxtFileName);

ArrayList chunklist = new ArrayList();

S = SR.ReadLine();

while (S != null)

{

Chunk chk = new Chunk(S + "\r\n", FontFactory.GetFont(_Font, FontSize, Font.NORMAL));

if (S.IndexOf("http:/") > -1)

{

chk = new Chunk(S + "\r\n", FontFactory.GetFont(_Font, FontSize, Font.UNDERLINE));

chk.SetAnchor(S);

}

chunklist.Add(chk);

S = SR.ReadLine();

}

//Console.WriteLine(S);

SR.Close();

Phrase PH = new Phrase();

PH.Font = FontFactory.GetFont(_Font, FontSize, Font.NORMAL);

PH.AddRange(chunklist);

PH.Leading = lead;

PdfPTable table = new PdfPTable(1);

table.DefaultCell.Border = Rectangle.NO_BORDER;

table.DefaultCell.SetLeading(lead, 0);

table.TotalWidth = pagewidth;

table.HorizontalAlignment = Rectangle.ALIGN_MIDDLE;

table.DefaultCell.HorizontalAlignment = Rectangle.ALIGN_MIDDLE;

table.HorizontalAlignment = Rectangle.ALIGN_CENTER;

table.DefaultCell.HorizontalAlignment = Rectangle.ALIGN_CENTER;

table.AddCell(PH);

table.WriteSelectedRows(0, -1,0, v_space, pdfcontentbyte);

}

byte[] arr = pdfstamper.Writer.XmpMetadata;

pdfstamper.Close();

pdfreader.Close();

Console.WriteLine(SaveFileName + "Was Created in Success...");

}////end Function

.. more.

Tuesday, February 12, 2008

The release of large chain in Microsoft

As mentioned in MSDN magazine ,27 of February will be worldwide launch of Windows Server 2008, Visual Studio 2008, and SQL Server 2008 .

Microsoft Windows server 2008 : the most advanced Windows Server operating system yet, designed to power the next-generation of networks, applications, and Web services. With Windows Server 2008 you can develop, deliver, and manage rich user experiences and applications, provide a secure network infrastructure, and increase technological efficiency and value within your organization.

Microsoft Visual Studio 2008 : delivers on Microsoft's vision of enabling developers and development teams to rapidly create connected applications with compelling user experiences for Windows Vista, the 2007 Microsoft Office system, mobile devices and the Web. With the release of Visual Studio 2008 Beta 2, Microsoft is taking a leap forward on its promise to enable developers to harness this next wave of innovation.

Microsoft SQL Server 2008 :provides a trusted, productive, and intelligent data platform that enables you to run your most demanding mission critical applications, reduce time and cost of development and management of applications, and deliver actionable insight to your entire organization.

Downloads :
http://www.microsoft.com/heroeshappenhere/learn-more/downloads/default.mspx

more information : http://www.microsoft.com/heroeshappenhere/default.mspx

.. more.

Sunday, February 10, 2008

How to create a multi-lingual web site Step By Step

As usual there are two ways to make a multi-lingual web site:

· The easy , beautiful and half functional way.

· The hard , ugly but full functional way.

We will go first through the common steps for the both ways

First create your ordinary web site with your VS

In the design view add one label and one button and leave them with their default values

From your solution explorer right click on your web site and click add new item and choose Resource File and rename it with you page name and extension (Default.aspx)

A Massage will pop for you asking for creating a Global Resources folder click no

Add a new folder with the name APP_LocalResources and put your Resource file on it

In the Label and the Button add new attribute meta:resourcekey="ResourceName"

Add a new string value in the resource file with the same resource key name and add .Text like ResourceName.Text and give it the Default language value like English

Copy the resource file and rename the new one to the secondary language name like Default.aspx.as-EG.resx

Give the ResourceName for the button another values in the Arabic resource file like عربي

Here come the easy way

Set the Culture and UICulture to Auto from designer or from aspx file like Culture="Auto" UICulture="Auto"

And now just run you application , The Button and the label now should have the default language values from the resource file

Change the default language for you explorer (most explorers will be from Tools->Internet Options->Language(Button)

If the Arabic language is not already there add it and move it up

Now refresh you page and the label and button should change their text to عربي

That’s easy as you can see :d but what is the user don’t know about how to change the browsers language, then we should use the bit harder way and use a button to change the Culture and the UICulture values from the code.


*You need now to change the Culture information on the button Click event, But the problem here is that the culture information will be reset on the postback, so you can use whatever way to keep its value but here I will use cookies .

Now make a new class with name common and put it in the App_Code folder

Make a bool attribute with the name ISArabic like

public static bool IsArabic

{
get

{
if (Thread.CurrentThread.CurrentUICulture.Name == "ar-EG")

return true;
else
return false;
}
}

Now on the button Click we will create a new cookie(if it doesn’t already exist) and give it the culture value just as fallows

HttpCookie myCookie = (HttpCookie)Request.Cookies["Localization"];

if (myCookie == null)

myCookie = new HttpCookie("Localization");

Then we will set the cookie value acording to the current choosen culture

if (Common.IsArabic)

myCookie.Values["Language"] = "en-US";

else

myCookie.Values["Language"] = "ar-EG";

then we set the cookie and add it and Then we redirect to the same page

myCookie.Expires = DateTime.Now.AddYears(1);

Response.Cookies.Add(myCookie);

Response.Redirect(Request.Url.AbsoluteUri);

Now add a new Item and choose Global Application Class

Add a new event called Application_BeginRequest and put the code which checks for the current culture on it just like that


void Application_BeginRequest(Object sender, EventArgs e)

{

HttpCookie myCookie = (HttpCookie)Request.Cookies["Localization"];

if (myCookie != null)

{

//Read culture from cookie
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(myCookie.Values["Language"]); System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(myCookie.Values["Language"]);

}

else

{

//Create new default cookie

myCookie = new HttpCookie("Localization");

myCookie.Values.Add("Language", "en-US");

myCookie.Expires = DateTime.Now.AddYears(1);

Response.Cookies.Add(myCookie);

//Set the thread default culture

System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");

System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");

}
}

Don't forget to remove the Auto values for the Culture And UICulture

Now everything should work just fine

You can now use the resource file and change strings, pictures and icons just according to the chosen language

source files could be found here

.. more.

Fedora 9 alpha release

Fedora 9 Alpha have been released a minutes ago here is the link of the page and for downloads

http://fedoraproject.org/get-prerelease

.. more.

Thursday, February 07, 2008

.network.org 2nd gathering

Get ready for the second .network group gathering..

Date: Saturday, February 9, 2008
12:00pm - 4:00pm

Location: CIC (the Canadian International College) campus.

Busses (to the gathering) will be available in front of "Nady EL-Sekka" from 11:00-11:30

Event Agenda:
12:00 - 01:30 Khaled Hnidk, Link Development - WCF – Messaging & Channel Model
01:30 - 02:00 Coffee Break
02:00 - 03:30 Mohammed Meshrif, Microsoft - SQL Server Maintainability
03:30 - 04:00 Lunch


Check the facebook group: http://www.facebook.com/group.php?gid=2409268236
& the Event page: http://www.facebook.com/event.php?eid=7974276601

& join the Yahoo!Group: http://groups.yahoo.com/group/dotnetworkorg/

.. more.