Wednesday, February 21, 2001

A simple top level design for an instant messenger (Jabber Instant Messenger Client)

The Jabber Messenger is composed of 2 parts the server and the client. The server is ready. This analysis would entitles the client structure.

The client is based on the Java Platform to be as portable as possible. In order to be modular and reusable the OOP structure is the best at all. In this small analysis I would talk about the basic structure of the messenger.

Abstract Classes:
This set of classes would help to keep the portability of the Package and the complete abstraction and encapsulation of the program parts.
Messenger Class
This is the main class that encapsulates the whole program. It is the most abstract Class that do nothing but initiates other Classes. However, this class is important to assure the reusability of the package.
  • Class Messenger: Top Level Module
    1. Registry keys (Call Register Class)
    2. General Messenger Attributes (Set General Attributes, Titles, Logos, Fonts, Templates, Languages)
    3. General Check in before start (Check Modules integrity, libraries availabilities, OS, Browser Type, Encoding, Connection)
    4. Call real messenger Classes (Connection to Messenger server, Set Presence, Get Buddies states, Get Mail Messages)
    5. Move the action to Draw Classes to display the status.
    6. Move the Action to the interactive Class to complete the user actions. 
    7.  Clean Up after Closing
  • Abstract Menu Class: This class is an abstraction of the Usual Windows Menu Classes. This class is necessary to assure the ability to modify the whole system and keep its integrity
  • Abstract tool Bar Class: This is similar to the previous class.
  • Online buddies Class : Abstract Class also
  • Complete list of Buddies Class : Abstract also
  • Mail Messages List Class : Abstract also
  • Ad Rotator Class : Abstract
  • Sets of Buddies and Sets of available Contacts.
  • Status Bar Abstract Class
  • Task bar Abstract Class
  • Abstract Connection Class
  • Abstract Interaction Classes
  • Abstract Request and Response Classes
Every abstract Class has its own equivalent display abstract class also to assure the harmony at the display side also. When an abstract class is instantiated its equivalent display is called to complete the task at the abstract level before going into concrete display.

Real Classes:
Every abstract class calls real time modules to complete the task. For example, the Messenger Top level Class initiates other Top level abstract classes (listed above) However when the call goes to the Top level Connection Class, it should call a real connection module such as Connect Class to get the real connection done.
·         Connection Class:
1.     Connect to the Server by sockets or COM library (JabberCOM).
2.     Take care of the XML request and replies
3.     Call the Presence Class
4.     Call the Online buddies Class
5.     Call the Mail Fetching Modules
·         Person Class:  This class encapsulates all the attributes of the Person using the messenger
1.     Personal Info
2.     Server Settings (Offline, Buddy List, Contacts, Buddy Settings.)
3.     Preferences
4.     Profile
5.     Interests
6.     Geographic and Categorized info
7.     Mail Settings
8.     Mail Domains
·          Contact Class : Similar to Person Class however not all attributes are available to the Person Class ( Public and Protected only)
1.     Public Profile info
2.     Presence info ( Apparent)
3.     Domain
4.     Geographic info and Category settings
·         Buddy Class : Inheritant from Contact Class with the additions of ability to interat online
·         Conversation Class : This class is some what top level also . It takes care of the conversation  between online buddies following the IM conditions.
1.     Takes care of the List of online Buddies I this conv.
2.     Save the Connection handler
3.     Saves the initiator privileges
4.     Saves the History of the Conversation
5.     Set the Conversation Preferences.
·         Private Messaging Class : Inheritant from the previous Class but for 2 contacts only. All the previous conditions apply.
·         Interact Class : Top level Class encapsulates all interactions between contacts : Send a Message , invite , send a mail , Call – later on , send a alert …. From this class we would inherit al the other sub classes
1.     Message Class
2.     Call Class
3.     Alert Class
4.     Mail Class
5.     Invite Class
·         Contact List Class : Get the contacts info from the server  and display them according to the rules of the User preferences , Server conditions  and other rules
·         Mail Message Class : Get the messages headers from mail servers.
·          Request Class : This Class takes gets requests from all above classes , formats them saves the  handle , cares of XML composing and sends them to the Connection class that sends them to the IM server.
·         Response Class : Gets the reply from the IM server , parse the XML tags , fetch its handles and return it to the Requesting Class.
·         Task Bar Classes . This is a set of classes that implement the functionality of the alerting system (Display , ring , status , Preference menu).
·         Category Class : Sets the rules to divide the Contacts lists and display public profiles.
·         File Transmission Class ( FTP functionality)
·         Options Class : Top level Class that makes use of all classes public interfaces to set or get the objects attributes.
·         Help Class : General Help about all functions in this IM.

After agreement on this structure , we should develop the real structure of all those classes. Definitions , attributes , methods , privacy , inheritance, interaction , implementation.

For example

Class Person

int id;
String Password;


String name;
String Email;
String MailDomain;
String interests[];
String Preferences[];
String Sex;
Int age;
String Location;
BOOL Status;

String Handle;
String Category;

// Public Interfaces
int Getid();
void Setid(int newId);
int getAge();
voidSetAge(int newage);
void setHandle(string new handle);
void setCategory(string Cat);
BOOL checkpassword (string passwd_hash);
void SetStatus(BOOL available = TRUE);
void drawIcon();
void displaynick();

class Contact : public Person { … } ;
class Buddy : public Contact {..};

and so on.