Wednesday 25 January 2012

Looking at Dependecy Inversion Principle (DIP) and JAIN SLEE typed events...

JAIN SLEE follows Event-Driven Programming Model, this means the glue between coorperating components (SBBs) is the Events, with an exception of parent-child relationships in the case of composite services (those services composed of a number of SBBs - with one as a root). This also means that the dependencies between components or the relationship between them is that one produces event while the other(s) consume(s) these events. It is therefore a good place to discuss the Dependency Inversion Principle (DIP), the Open Close Principle (OCP) as well as the Interface-Segregation-Principle (ISP).

The definition of an Event in JAIN SLEE is located in the event-jar.xml descriptor file and is as follows:

   <event-definition>
        <event-type-name>co.za.ishmael.lab.messaging.events.DELIVERY_REPORT</event-type-name>
        <event-type-vendor>co.za.ishmael.lab</event-type-vendor>
        <event-type-version>1</event-type-version>
        <event-class-name>
                    co.za.ishmael.lab.messaging.api.MessageDeliveryReportEvent
        </event-class-name>
    </event-definition>


To "subscribe" to such an event, the SBB that wants to receive the event would add the following in its sbb-jar.xml descriptor file:

<event event-direction="Receive" initial-event="False">
            <event-name>MessageDeliveryReportEvent</event-name>
            <event-type-ref>
                <event-type-name>
                     co.za.ishmael.lab.messaging.events.DELIVERY_REPORT
                </event-type-name>
                <event-type-vendor>co.za.ishmael.lab</event-type-vendor>
                <event-type-version>1</event-type-version>
            </event-type-ref>

            <initial-event-select variable="ActivityContext"/>
</event>


This discussion focuses on the <event-class-name> because this points to the actual class (abstract or concrete) or an interface. I am using the following use-case to guide the DIP discussion on this post.

An imaginary Messaging-Service SBB received request events to send messages out, and upon successful submission of the messages, it sends back to the requestor the delivery report. So we have two events here, the "Request-to-Send-Message" event (we call it SendMessageRequestEvent) which carries with it the message to be sent, the message indicates who the sender is (from) and the intended recipient (to) as well as the string representing the message body. The "Message-Delivery-Report" event (let's call it MessageDeliveryReportEvent) on the other hand carries the original request ("Request-to-Send-Message") to which this is the response, and the status of the delivery (say, OK, ERROR, etc).

Comforming to the DIP:
Dependecy should only be to Interfaces or Abstract Classes, not concrete objects. In terms of JAIN SLEE  events this would require that the <event-class-name> should point to Abstract classes or Interface, and these Interfaces (if applicable) should in turn depend yet on other Abstract Classes or Interfaces.

Coming back to the example: This means the "Request-to-Send-Message" and "Message-Delivery-Report" events should be interfaces. The "Message" should also be an Interface. Of course, someone somewhere will have to create concrete implementations of these interfaces ( this is where the AbstractFactory design pattern comes into play...let's not discuss this here though).

The SBB that receives the request event to send messages now depends on the Interface Message, and the Interface SendMessageRequestEvent.

public Interface SendMessageRequestEvent{
     public Message getMessage(); 
     ...
}

    /**
     * This event-handler method is invoked when receiving a SendMessageRequestEvent event
     */
    public void onSendMessageRequestEvent(SendMessageRequestEvent event, ActivityContextInterface aci, EventContext context) {       
       //get the message (Message is some Interface representing a message)
       Message msg = event.getMessage();
       someSbbRAInterface.sendMessage(msg.getFrom(),msg.getTo(),msg.getMessageBody());
    }

Now, because the Message is an Interface, we can extend this by having specific types of messages, say Email, SMS and IM, it should still be possible to fire the same SendMessageRequestEvent  event, bearing the Message which may be Email/SMS/IM . This is the Open Close Principle (OCP) - without modifying the Message Inteface source code, but only extending it into more specific implementations of a Message. The only difference in the Message types/implementations might be in terms of what constitutes a valid recipient/sender addresses, for example, but they all have the From, To and the message-content/body data elements.

Furthermore, if the implementation fo SMS-Message changes, this does not affect how the event handler for SendMessageRequestEvent functions, it can still treat it as a "Message". So by depending on Message Interface and not Email/SMS/IM, the SBB in question conforms to the DIP.

Also, if a new "Request-to-Send-Message"is defined, which has some additional properties such as TimeToLive or validity-period, then a new event can be defined, pointing to this extended "Request-to-Send-Message"interface. Those SBBs that are interested in receiving such an event will add it in their sbb-jar.xml descriptor files. This leans towards the Interface-Segregation-Principle (ISP).

Example:
public Interface ExtendedSendMessageRequestEvent extends SendMessageRequestEvent{
     public long getValidityPeriodInMillis(); 
     ...
}

In some interested SBB:

public void onExtSendMessageRequestEvent(ExtendedSendMessageRequestEvent event, ActivityContextInterface aci, EventContext context) {       
       //get the message (Message is some Interface representing a message)
       Message msg = event.getMessage();
       long ttl = event.getValidityPeriodInMillis();
       //check if the request is still valid and send the message if true..
       if( (ttl - System.getTimeMillis()) >0){
          someSbbRAInterface.sendMessage(msg.getFrom(),msg.getTo(),msg.getMessageBody());
        }
       else{
          // you might want to fire some "request-expired-event" here
        }
    } 

These seemingly simple techniques come in very handy when developing very complex systems typical of converged communications systems with a number of collaborative components. In my Masters Degree research project I am looking at Access-Agnostic Delivery Pattern - again, Abstraction is key!

Tuesday 24 January 2012

Open Closed Principles - Applicable to JAIN SLEE SBBs?

One of the most important principles in Software Engineering is arguably the Open Closed Principle (OCP). Simply put, OCP stated that modules should be written in a manner that makes it possible to extend or change their behavior without having to modify their source code. In this sense, such modules are "open for extension" but "closed for modification".

This principle requires that the details of the workings of the modules should be hidden from potential "extension builders". The techniques for achieving OCP are necessarily based on Abstraction.

Robert C. Martin (2000) lists:
Dynamic Polymorphism - in this case the "function" or "behavior" is made to depend on an interface and not on a concrete object - this means the function will need no modification when a new "Interface implementation" is added, thus extending how the module behaves.

In JAIN SLEE SBBs, the SBBs are abstract classes, implementing the javax.slee.Sbb (which defines mainly Life-cycle methods such as:

    public void sbbCreate() throws javax.slee.CreateException {...}
    public void sbbPostCreate() throws javax.slee.CreateException {...}


So by having something like this: public abstract class IshmaelExampleSbb implements javax.slee.Sbb
I am extending how the "Sbb" behaves (to the person invoking methods on the javax.slee.Sbb Interface) by adding IshmaelExample-specific behavior - which is hidden from the user of javax.slee.Sbb Interface.

Now between SBBs (say IshmaelExampleSbb and IshmaelAnotherExampleSbb), JAIN SLEE Spec allows for a "Local Object" interface through which the developer can define some functions which these other SBBs can use to invoke certain behavior of the implementing SBB. Such an interface is define through the descriptor file (sbb-jar.xml) thus:

 <sbb-local-interface>
          <sbb-local-interface-name>

                 co.za.ishmael.labs.XmppServiceBuildingBlockLO
          </sbb-local-interface-name>
 </sbb-local-interface>


Again, following the OCP, by changing what happens  in the implementing SBB (which defines the interface) - I will be extending, from the viewpoint of the SBB that uses the said interface, how the function exposed by SBB behaves. For example -

public interface XmppServiceBuildingBlockLO {
       public void incrementXmppMessagesSent(long value);    
       public long getXmppMessagesSent();
}

The implementing SBB would invoke the above method thus (I am omitting JAIN SLEE specific details of attaining the Local Object):

_xmppServiceBuildingBlockLO.incrementXmppMessagesSent(300);



Assume that the above statement results in the value 300 added to the total number of XMPP Messages ("stanzas"). Now, say someone decides that it the value reached a certain threshold, after incrementing, the operation should be aborted. This changed how the incrementXmppMessagesSent(long value) behaves, but requires no code changes on the part of the module that invokes the method.
Another technique mentioned is the Static Polymorphism - technically, this is achieved through the use of Templates or Generics:

public class SomeGenericStuff<T extends SomeCommonGenericStuff>
{
   
    /**
     * T is the formal parameter of SomeGenericStuff 
         and stands for all "extensions" of  SomeCommonGenericStuff
     */
    private T genType;
    String defaultStuffFromBase;  
    public SomeGenericStuff(T concreteObject){
         this.genType = concreteObject;
          //assuming this is defined in the SomeCommonGenericStuff. I can do this... 
          this.defaulStuffFromBase = concreteObject.getStuff();
          ...
    }

In fact the above example speaks to to the next principle that Robert C. Martin discusses - The Liskov Substitution Principle (LSP). It states that the subclasses (that extend others) must be substitutable for their base classes (which they extend). So, from the above, I should be able to treat T as though it were SomeCommonGenericStuff.

Don't be caught in the midst of the The Circle/Ellipse Dilemma dilemma though.....

Have fun coding...

Ishmael





Tuesday 17 January 2012

Monday 16 January 2012

Quantum Africa 2 The 2nd Conference in the Quantum Africa Series will take place from 3 to 7 September 2012.

The Quantum Africa Conference Series: 

[Excerpt from source]

The Centre for Quantum Technology of the University of KwaZulu-Natal has organised a very successful conference in 2006 on Theoretical and Experimental Foundations of Recent Quan- tum Technologies. The proceedings of this conference were published in a special issue of The European Physical Journal [Ph. Blanchard, E. Bruning, F. Petruccione (Eds.), Emerging Quan- tum Technologies: Selected Theoretical and Experimental Aspects, EPJ ST, Vol. 159, June 2008]. The local and international positive resonance to this conference motivated the organi- zation of a new series of conferences: Quantum Africa. The new series of conferences is planned to take place consecutively in several African countries. The first conference in the series, Quantum Africa 2010, was hosted in Durban by the Centre for Quantum Technology with a conference on Recent Progress in Theoretical and Experimental Foundations of Quan- tum Technology.

...

It was decided to host Quantum Africa II again in South Africa.... 

[Source] http://quantum.ukzn.ac.za/events/quantum-africa-2




"Getting muddier": JAIN SLEE AS (service) and Android Activity+Service (client)

In this lab experiment, I am writting a JAIN SLEE AS (Mobicents) based service that receives incidents-reports from multiple sources (crowd-sourcing) and overlays these on the map based on the location of the reported incident as explicitly stated or deduced from the user's submissions. The incident submission is done using the Ushahidi Platform (ushahidi.com).

The idea is now to seamlessly make the collected intelligence (incidents/locations/etc) available to the client applications such as "travel route planner" that can use the intelligence to support user's decision making. Android will be used to build the client-side services that subscribes and receives the information from the JAIN SLEE service.

This a cloudy idea....but will get soime mock-up soon!

Follow....






Thursday 12 January 2012

The 2012 World Congress in Computer Science, Computer Engineering, and Applied Computing

                    CALL  FOR  PAPERS
                                and
                     Call For Conference Tracks

             Paper Submission Deadline: March 12, 2012


                           WORLDCOMP'12
            The 2012 World Congress in Computer Science,
            Computer Engineering, and Applied Computing
                      July 16-19, 2012, USA

             http://www.world-academy-of-science.org/
          Location: See the above web site for venue/city

You are invited to submit a full paper for consideration. All accepted
papers will be published in the respective conference proceedings and
indexed in Inspec / IET / The Institute for Engineering and Technology;
DBLP / Computer Science Bibliography; CNRS, INIST, PASCAL; and others.
Accepted papers will be published in printed conference books/proceedings
(they will also be available online). Like prior years, extended versions
of selected papers (about 42%) will appear in journals and edited research
books after the conference (publishers include: Springer, BMC, Elsevier,
and others).


IMPORTANT DATES:

March 12, 2012:    Submission of full papers (about 7 pages)
April 12, 2012:    Notification of acceptance (+/- two days)
April 26, 2012:    Final papers + Copyright/Consent + Registration
July 16-19, 2012:  WORLDCOMP 2012 and all its affiliated conferences



WORLDCOMP'12 is composed of a number of tracks (joint-conferences,
tutorials, workshops, and panel discussions); all will be held
simultaneously, same location and dates: July 16-19, 2012. For the
complete list of joint conferences, see below.


LIST OF CONFERENCES :

o BIOCOMP'12 - 13th Int'l. Conference on Bioinformatics & Computational Biology

o CDES'12 - 12th Int'l Conference on Computer Design

o CGVR'12 - 16th Int'l Conference on Computer Graphics and Virtual Reality

o CSC'12 - 9th Int'l Conference on Scientific Computing

o DMIN'12 - 8th Int'l Conference on Data Mining

o EEE'12 - 11th Int'l Conference on e-Learning, e-Business, Enterprise
  Information Systems, and e-Government

o ERSA'12 - 12th Int'l Conference on Engineering of Reconfigurable Systems
  and Algorithms

o ESA'12 - 10th Int'l Conference on Embedded Systems and Applications

o FCS'12 - 8th Int'l Conference on Foundations of Computer Science

o FECS'12 - 8th Int'l Conference on Frontiers in Education: Computer
  Science and Computer Engineering

o GCA'12 - 8th Int'l Conference on Grid Computing and Applications

o GEM'12 - 9th Int'l Conference on Genetic and Evolutionary Methods

o ICAI'12 - 14th Int'l Conference on Artificial Intelligence

o ICOMP'12 - 13th Int'l Conference on Internet Computing

o ICWN'12 - 11th Int'l Conference on Wireless Networks

o IKE'12 - 11th Int'l Conference on Information and Knowledge Engineering

o IPCV'12 - 16th Int'l Conference on Image Processing, Computer Vision,
  & Pattern Recognition

o MSV'12 - 9th Int'l Conference on Modeling, Simulation and Visualization
  Methods

o PDPTA'12 - 18th Int'l Conference on Parallel and Distributed Processing
  Techniques and Applications

o SAM'12 - 11th Int'l Conference on Security and Management

o SERP'12 - 11th Int'l Conference on Software Engineering Research and
  Practice

o SWWS'12 - 11th Int'l Conference on Semantic Web and Web Services

All conferences listed above will be held simultaneously; ie, same location
and dates. A link to each of the conferences can be found at:
http://www.world-academy-of-science.org



CONTACT:

Any inquiries should be sent to: editor@world-comp.org

Tuesday 3 January 2012

Africa Android Challenge ACC 2012 Announced!

The Africa Android Challenge ACC 2012 has been announced:  http://androidchallenge.org/

I will be submitting an Adroid application "for social good" and will use this post to communicate my Android lab progress...

Monday 2 January 2012

A paper on my work published in the Lecture Notes in Electrical Engineering

Excited: My first contribution to the Lecture Notes in Electrical Engineering - Springer:
IT Convergence and Services: Lecture Notes in Electrical Engineering, 2011, Volume 107, Part 1, 55-68, DOI: 10.1007/978-94-007-2598-0_6 (http://www.springerlink.com/content/rh7l5245884l7245/)

 
Very nice....

Launched Pretoria Google Technology User Group (GTUG)

We have officially launched Pretoria's Google Technology User Group (GTUG). We are officially the 3rd Google developer community in South Africa after JHB and CTN. Well done and thank you to those that attended the innaugural meeting...
I am the manager for the Google Group for this GTUG,

The Work and Life of Ishmael Makitla....

A welcome note...I will use this blog to communicate my ideas, and posting recent activities which will mainly be academic (I work on the scientific research council), technical ( I am in the R&D, Computer Science, Engineering discipline), intellectual as well as philosophical (I have some liking and inclination to this...)..

.
I hope all the followers find this refreshing and enlightenin,