June 12, 2009

Good Design Thoughts


1. Encapsulate what varies --> identify the sections that vary and separate them from what stays the same
2. Favour composition over inheritance --> use "has-a" it is better than "is-a"
3. program to interface not implementations
4. Strive for loosely coupled designs between objects that interact (think mediator/observer)
5. Classes should be open for extension but closed for modification (think decorator pattern wrap around to extend)
6. Depend on abstracts not on concrete classes (an example would be factory method)
7. only talk to your friends (avoid having large number of classes coupled together)
8. dont call us, we will call you (template method - let superclass re-direct to subclasses)
9. A class should have only 1 reason to change

Inheritance vs Aggregation vs Composition


Inheritance - "Is A" Strongest Relationship

We depend on the functionalities of a Super Class

Aggregation - "Has A / Is Part Of" - Weaker Relationship

As shown in the example Aggregation occurs when the part of outlives the whole. e.g the listener instance could be alive even after WebServer instance is garbage collected


Aggregation Example ("has a"):



Composition - "Uses A" - Stronger Relationship

In a composition relationship the listener instance lifespan lasts till the WebServer instance is garbage collected.


Composition Example ("uses a"):







WSDL Styles Samples

==============================================
RPC LITERAL
==============================================








==============================================
RPC ENCODED
==============================================









==============================================
DOCUMENT LITERAL
==============================================












June 5, 2009

WSDL Styles

There are 5 types of WSDL styles.
  • RPC/Literal
  • RPC/Encoded
  • Document/Literal
  • Document/Encoded
  • Document Literal Wrapped Mode
Irrespective of the style differences, it can be applied to any technology.




WSDL Styles

Advantage

Disadvantage

RPC/Encoded

The WSDL is simple and straightforward

The operation name appears in the message, so the receiver has an easy time dispatching this message to the implementation of the operation.

The type encoding info (such as xsi:type="xsd:int") is usually just overhead which degrades throughput performance.

Message cannot be easily validated as very few lines contain things defined in a schema; the rest of the soap:body contents comes from WSDL definition

RPC/encoded is not WS-I compliant.

RPC/Literal

The WSDL is still simple and straightforward

The operation name still appears in the message.

The type encoding info is eliminated.

RPC/literal is WS-I compliant.

Message cannot be easily validated as very few lines contain things defined in a schema; the rest of the soap:body contents comes from WSDL definition

Document/Encoded

NIL

Nobody follows this style. It is not WS-I compliant

Dcoument/Literal

There is no type encoding info.

Message can be validated with any XML validator. Everything within the soap:body is defined in a schema.

Document/literal is WS-I compliant,

The WSDL is getting a bit more complicated.It is not easily understood by humans

The operation name in the
SOAP message is lost. Without the name, dispatching can be difficult, and sometimes impossible.

WS-I only allows one child of the soap:body in a
SOAP message.

Document/Literal Wrapped Mode

There is no type encoding info.

Everything that appears in the soap:body is defined by the schema,
Message can be validated with any XML validator.

Once again, you have the method name in the
SOAP message.

Document/literal is WS-I compliant, and the wrapped pattern meets the WS-I restriction that the
SOAP message's soap:body has only one child.

The WSDL is even more complicated.

Reference: http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/

April 14, 2009

What is Multi Factor Authentication (MFA)

Multifactor authentication (MFA) is a security system in which more than one form of authentication is implemented to verify the legitimacy of a transaction. In contrast, single factor authentication (SFA) involves only a user ID and password.

In two-factor authentication, the user provides dual means of identification, one of which is typically a physical token, such as a card, and the other of which is typically something memorized, such as a security code.

Additional authentication methods that can be used in MFA include biometric verification such as fingerscanning, iris recognition, facial recognition and voice ID. In addition to these methods, smart cards and other electronic devices can be used along with the traditional user ID and password.

April 4, 2009

Handling Different timezones in distributed environment

This was a captivating discussion on how timezones in distributed environment should be handled. There are a couple of good strategies recommended.

Scenario:
Having db server in different time zone and process server / engine, which is going to run lively like auctions/bidding in different time zone.

Recommended Solution

Store dates in GMT format and format them as required at the various endpoints.
  • User prefered timezone - used whenever date displayed to user, entered by user and validated.
  • User machine timezone - could be used to determine user preferred timezone and local logging in case of rich client
  • Server timezone - used for local logging
  • Database timezone - should be irrelevant.
  • Common timezone (GMT normally but it does not really matter) - used for dates stored in database, interserver communication, centralized logging, etc)

September 17, 2008

Unix Processes

Below are some of the common unix commands that can be used to list the processes and cpu usage.

ps -ef |less
  • list all running process (-e)
  • full details (-f)
  • page by page (| less)
top
  • list top 15 cpu intensive processes
  • -o option sorts the information by cpu, time, res
prstat -avm
  • reports active process statistics
  • all process (-a)
  • -m report microstate process information