Thursday, March 31, 2011

How to Print from 1 to 300000 without loop or Conditionals ?

In ILUG Kochi group , a question was posted by a member and I am giving my solution here


#include <stdio.h>


#include <stdlib.h>

#include <setjmp.h>



static jmp_buf buf;







int main( int argc , char **argv )

{

int i=0;





try {

setjmp(buf); 

printf("%d\n",i++);

longjmp(buf,i/(i%300001));

}

catch(...) {} 





}







Tuesday, March 29, 2011

Porting Skillset from one project to another ( a FOSS angle ! )

While one goes to work of  crafting a software , tools with excellent documentation is very much essential and it is a well acknowleged fact. Some proprietory tools really provide good documentation by spending millions of dollars for the purpose.

The biggest challenge facing an average developer is transportation of his skill from one project to another. Too often , the developer or tester in question is forced to learn couple of proprietory tools and a new lingo to be effective in the new environment.

If there is good adoption of OSS tools , the documentation will be public and there can be a shared language for the teams in a particular domain. I think , a lot of energy and money is spent to "re-train" the developers when they switch the projects.

Can u remain a techie for Life ?

Many a people prefer Computer Programming over other activity just for one reason ,viz you only need to interact with Human beings rarely. You are a GOD as far as writing Computer Programs are concerned.

If you start your career with a small company , what you see is just the continuation of activity which you are doing when you were studying.The poor programmer will continue to "enjoy" his stuff for a long time and one fine morning he finds himself in the midst of people who call them team leads , project manger , delivery manager , testers etc. This will be a shock for him and his struggle begins from then onwards.

Modern Software engineering is all about people and their attitudes . So , try to learn to adjust with fellow human beings or be prepared to stagnate.

The Power of Process

Being a person who started Software development when it was at it's infancy in India , I had aversion for process. Some Companies give undue emphasis on process and it made lot of people hate processes and the procedural aspects of Software Engineering.

If a company has got good financial "muscle" , a well defined process can give them business continuity more than any other variable. Slowly , I started appreciating the power of a good process. To be able to adjust to this world is another matter. Some do refuse to adjust. Back in the year 2001 itself , I understood that a well defined process helps management to take decisions based on facts ( rather than SWAG or Voodoo method )

Thursday, March 24, 2011

Funny reporting

I got up early today and switched on my friend's machine to see the outcome of India vs Australia match. The moment I logged In , I saw a heading "Sachin missed the hundred mark". When I slept yesterday , Sachin was not out at 45 and I thought he might taken India close to the Victory and have got out In his eighties or ninenties. This was not the case to be.

This "Sachin Mania" is not good for the team ( I have got a gut feeling that India will win the world cup just because It is the only thing which pushes Sachin to the second spot after the venerable God ! ) and might
affect the morale of the rest of the team.

Wait for the world cup to finish and let us hope Indian team ( or Sachin ) wins the stuff for the country. After all , It is sports and not the end of the world.


An Ant on the hair of a lady

Today , While sitting in the Bus , I happen to take note of an ant on the hair of a lady who was sitting two rows before me. The situation was really perilious and she is oblivious of her surroundings ( ear phone enabled music enthusiast ) and I observed the beast for close to ten minutes contemplating whether to inform her or not. I did try to ask the help of person who sits in the front row . Since , he was reading "Fooled By Randomness" , I thought he will be interested in communicating the stuff to the lady. He was unmoved and finally , I got up from my seat and told her about the stuff and she promptly removed the beast from her hair.

What you would have done ?

Wednesday, March 23, 2011

How some IT companies might be maintaining scalability ?

Some multi-nationals set up operations in India by doing some kind of ahead of time strategic analysis. They have to do capacity planning and it boils down to Infrastructure planning and Human resource staffing.

Regardless of the business model or vertical, some XXX amount of work needs to be done from a Business unit and they granularize the total quanta to a stage where total number of people who can do the work in a geographical location exceeds the projected demands. I would like to call it Unit Of Work Per Employee. (UOWPE)

TOTALWORK / UOWPE = # of people in the company

In big companies , UOWPE is less. This is by design to maintain Business Continuity .

Tuesday, March 22, 2011

City - a poem

A piece of land , spread across some area
Where ,people run here and there
In search for a future they desire
Future , it remains elusive
They run like rats
Some do win the race
After all , winner is also a rat !



Friday, March 18, 2011

Does Life have a purpose beyond pro-creation and suffering it's "aftermath" ?

There is a saying that only aim of life is to create even more life. By that process , the phenomena of life is perpetuating . At one point of time , survival amounted to physiological survival. That , In effect means protecting one self from animals , weather and other men.

Soon, man created instituitions and socities were formed around them. Then , on top of physiological survival , social survival became another aspect of survival game. Now, when we talk about survival , we are talking about social survival (implicitly ).

There is no canonical model for society. Society itself due to evolutionary pressures have got different strata ( sub societies which share a common juristriction ) within it.

At biological level , we have got obligation to pass our gene on to the next generation. That , essentially means we should pro-create and invest time for rearing them. Rearing a child (or children ) has socio-economic dimensions. We are supposed to provide the best (?) facility to realize their potential. The strata of society we are in could not provide the context for such an environment. Soon , we will try to move to the next upper strata to find that the rules of engagement have changed !. Thus , the Indvidual evolves .


Now , the million dollar question arrives

Who are we to decide how the result of  our pro-creative instincts should live ?


Auxilary questions include

a) Are we smart enough to detect the best environment for our kids ?
b) What If , our analysis went wrong and it was counter-productive ?
c)  Or without bothering , we should consider this as "parental" occupation hazard ?






Thursday, March 17, 2011

Life - Plans are part of the problem

We normally try to plan ahead to avert certain problems which we have anticipated. How much ever , we plan , what might come across can be a variation of problem which we have devised the solution for. In this scenario , the execution of original plan might turn out to become anti-plan.

Wednesday, March 16, 2011

I might soon morph into a "mall rat"

In Bangalore ,fooling around in a mall seems to be the only favorite pastime for young and old alike. The city is so crowded that you get some breathing space in parks ( not meant for me at this age !! ) and malls. I have slowly started liking the ambiance of malls. A thing which I despised in the past , is  helping me to energize myself.


Bangalore and Kochi - Pattern of book sales

Kent Beck can be rightly called the father of Test Driven Development. He has written a book which goes by the title "TDD by Examples" . I happen to see an Indian edition of the book in landmark book shop @ forum , Koramangala.

Kind of books which I saw @ landmark ( I mean the Indian edition ) , I have not found  in Kochi. There are more books on software engineering , Software testing , Unix programming in Bangalore compared to Kochi.  And regarding business books , barring Reliance Timeout , none of them stock books from Harvard Business School press,Kellog etc.

IMHO , In Kerala , You find exceptional computer programming talent compared to Bangalore , Chennai or Hyderabad. But,the collective wisdom of the crowd tilts things in favor of these cities.

I think , to understand the maturity of any Industry , try to see the bookshelves of the stores. It might give you an Idea of what is brewing there.




Monday, March 14, 2011

Mobile development - OEM angle

Even though Mobile device manufacturing and OEM software development can be called Embedded Systems , I used to view the stuff from a application software development point of view by virtue of having started active mobile development ( barring a project I happen to consult for Agilent Technologies using Windows CE )  using iPhone,iPad/Objective C/Cocoa framework (aka iOS ).

In the Application programming world , the talk of the town is Apple (iOS) vs Google (Android ) and MS try to create dent in their market with Windows 7 mobile ( Now Nokia/Microsoft deal has added fuel to that fire )

There is another Silent battle going on which I have not taken note off. For a OEM , using Android is a pain as Google "controls" most of the stuff. The OS customization is a involved process and there are deviations from ubiquitous unix driver model. So , learning curve is involved. In the case of iOS , apple's policy is clear and there is nothing much to talk about it.

These non real time OSs are used for media , traffic navigation and there is need for customizing the stuff for a particular family of device.



Sunday, March 13, 2011

Books - I'm going to miss them

I have got a good (huge ! - I know it is relative !) collection of books which I have acquired over a period of twenty years. The "bug" creeped into me in the year 1989 when I decided to become "enlightened". In those , times I used to raid old book stalls ( I could only afford that ! ) to purchase any book which amuses me.

At an average , I spend close to three thousand rupees a month to buy them. Since , I am in Bangalore and they are in Aluva ,  I will not be able to access them the way I was accessing them at my studies. I have built a dedicated eight hundred square feet area to house them.

some FAQs are

a) Why do u buy books , If you can google and find information  ?
b)  Is there any need to read so much books ?
c)  Even after reading this much , career wise you have not gained much (compared to "me"), right ?
d) Have you read them all ?
e) Is this a showpiece ?


I have got impressive answers for all of the above , but , the time is too narrow to deal here ! ( sounds Fermatish ?! ) . Fact of the matter is , I will miss them.




I have shifted my base to Bangalore

After resisting the temptation to move out of Kerala ( barring a period of nine months in Bangalore with Symphony Services ) for more than decade and a half , I have thrown in the towel. I am going to join UST global in it's Bangalore Office.

Today morning , I reached the city !. The last time I visited the city was in connection with my presentation @ Pycon India , 2010.

Friday, March 11, 2011

I'm talking about "Pattern Oriented Software development using C#/.NET"

The moment we hear patterns , we remember the venerable pattern catlog (consisting of 23 patterns grouped into creational , strcutural and behavioral ) published by Eric Gamma et al in the now famous book viz "Design Patterns - Elements of Reusable Object Oriented Software". They are also called Gang of Four Patterns.

But , to produce modern software one needs to be comfortable with

a) Architecture Patterns
b) Design Patterns
c) Patterns of Enterprise Application Architecture
d) Arlow/Nuestadt Archetype pattern
e) Enterprise Integration Patterns
e) DDD by Eric Evans

There are patterns for specific context like

JEE patterns
.NET Patterns
Security Patterns
Infrastructure Patterns

So , the word pattern has got different meaning for different crowd.

In my talk , I am planning to cover

a)  Fundamental OOP concepts ( to put things in perspective )
b)  SOLID principles ( by Robert C Martin aka Uncle Bob )
c)  What are Patterns ?
d)  Why Patterns ?
e)   History of Pattern Movement and the GOF book
f)   Design Patterns - It's taxonomy
g)  Coverage of some design patterns like Factory,Abstract Factory , Strategy , Template
     Command , Iterator , Interpreter etc
h)  Coverage of MVC Pattern
i)   Domain Driven Design
j)   Patterns of Enterprise Application Architecture
k)  Introduction to Arlow/Nuestadt Patterns
l)  Going forward.
m) Discussion about seven books
             GOF book , DDD book , POEAA (Martin Fowler ) , PPP (Robert C Martin  ) , Applying DDD  and patterns (Jimmy Nielson ) , Enterprise Patterns and MDA ( Arlow/Nuestadt ) , Enterprise Integration Patterns ( Martin Fowler Signature Series )

Date:- 12th March, 2011
Event Details @ http://k-mug.org/content/UGMeet120311.aspx

Thursday, March 10, 2011

DDD book by Eric Evans - Read it again... Slowly , It will make more sense

Domain Driven Design book written by Eric Evans is a classic to understand how to structure software with domain focus. The book starts with a anecdote and discusses about Ubiquitous langauge , Intention revealing Interfaces , Closure of Operations , Assertion , Domain patterns , Analysis patterns , Refactoring (targets are patterns...domain patterns ) etc.

He gives lot of information about how different models can co-exist in the same application and gives emphasis on the context of each model. He names it as a BOUNDED CONTEXT. The Domain model should bind to the Context in Question.

Recently , I had (re)invented (?) a Operations framework to structure the business logic of the application.

The Idea for the framework was from a school of thought called OPERATIONALISM. I happen to come across the term in a economic textbook. I think author was Paul Samuelson.

The rationale is

"Every human activity boils down to series of Operations. An Operation is uniquely Identified by a verb and there will be associated cargo of data as input. The cargo has got meaning only to the operator in question. "

class EXECUTION_CONTEXT
{
     string verb;
     string inputxmldoc;
     Hashtable addl_cargo;
}

interface IBusinessOperations
{
    BOOL PreExecute( EXECUTION_CONTEXT e );
    BOOL Execute(EXECUTION_CONTEXT e );
    BOOL PostExecute(EXECUTION_CONTEXT e );

}

class AddAccount : IBusinessOperations
{

BOOL PreExecute( EXECUTION_CONTEXT e ) {}

BOOL Execute(EXECUTION_CONTEXT e ) {}
BOOL PostExecute(EXECUTION_CONTEXT e ) {}
}

class AddJournal : IBusinessOperations

{

BOOL PreExecute( EXECUTION_CONTEXT e ) {}
BOOL Execute(EXECUTION_CONTEXT e ) {}
BOOL PostExecute(EXECUTION_CONTEXT e ) {}

}


By structuring the logic this way , I could create a pluggin framework which will call the appropriate handler to the verbs recieved at a WCF (Windows Communication Foundation ) endpoint.

The above stuff helped me to update data from iPad to the .net server. To populate iPAD UX controls , I required data from the server. I wrote a series of operations for that as well.

In the DDD book , he talks about Operations . He talks about the verb stuff and he uses the term SERVICE for Operations interface.

He tells that Operations can be broadly classified to Queries and Commands. It striked me between my ears.

Highly recommended

Tuesday, March 08, 2011

A spat with ex-councillor and husband of councillor

Currently , I have been involved in a movement to stall the setting up of a cement godown in the area where I live. The firm which is planning to setup the stuff has got deep political and bueracratic connection. They have "hired" some people in our midst to split the opinion.

Since most of the people who live in the area are "illiterate" by modern standards the said firm is waiting for the right opportunity to get the license and legitimize their illegal operation of using the plot as a area to store heavy iron.

The local councillor ( who is a lady which belongs to the congress party ) who got the seat vaccated by her husband (as our ward was reserved for women ) is forced to collide with the firm because they have got funding for her electoral campagin. The ex-councillor is running our ward by proxy practically speaking.

He plays a double game as if he is with the both parties and tries hard to mediate a truce ( which never can happen as it is equivalent to evict thirty families who belongs to a particular community ) between the firm and us.

When the councillor or her party did not give any support for us  , we approached BJP local unit ( they have come second in our ward for sixth consecutive time ) and they have started a poster campaign of their own.

The ex-councillor today happen to stop his bike where I and a friend of mine was chatting about an incident in Aluva ( muncipal secretary got arrested for taking bribe ). He began to say things like "if bjp is siding with you other parties will side with them !" and "why it is necessary to drag them to the issue " etc etc.

This irritated me and gave him reply on each of the point and substantiated my claim by giving facts. I also did say to him that councillor , ex-councillor and chairman are moot spectators to this human right violation and are closing their eyes.  He has been taking our people with hs "colinos" smile for the last ten years and began to murmur unconnected thing.This forced me to approach BJP local unit.


Now , I know that I have "inflicted" some pain (have I ? because he is a pachyderm )  he might look for an opportunity to strike back..god knows !...

Begging in disguise !

Tilak happens to chance upon a book on enterpruenership and as usual he began to brag about him going to become an enterpruener.

Tilak => "I think , we should stop working for some one and start our own conern !"

Prem => " You have got the capital for that ...?!"

Tilak => "If you have got enterprueneral instinct , capital will flow towards you ..!"

Prem =>"That works in movie and theory.....!"

Tilak =>"You need guts man ..to start on something ...!"

Prem =>"After all Business is nothing but , glorified begging ...and...I am not for it....!!!"

Monday, March 07, 2011

Enterprise Integration - a nice book I should have had when I started

It would not be wrong , If say that , I have built a career in Computer Programming/Software Engineering by working with re-engineering projects , software porting and application Integration.

In the early years , It was mostly interfacing C , Clipper and Assembler in writing business applications. CA-Clipper/Clipper Summer 87 had excellent facility to call C/Assembler functions ( EXTEND system ) and have Integrated C and Clipper in areas like VGA graphics , Local Language Font support , Data Compression , PC to PC file transfer protocols etc. to name a few.

Then , came Windows ( Win16/Win32s/Win32 ) and the focus shifted to producing DLLs in Borland C/C++  and  Visual C/C++. Those DLLs were called from Delphi and Visual Basic. I have participated in
VBX (Visual Basic Xtensions ) , OCX and Active X projects in integrating business logic and functionality.
Writing COM automation client was another option to integrate application.

Around that time , Windows became a network operating System ( My only previous exposure was SCO Unix and Novel Netware ) and Sockets/NamedPipes became the primary integration mechanism between applications. There were things like DDE (Dynamic Data Exchange ) to interact between two applications.
In Win32 , It was mostly splitting the applications to DLLs , COM DLLs , OCX and ATL DLLs. This enabled front ends written in VB ,Power Builder and Delphi to call the functionality encapsulated in those components.

Then came , COM + ( DCOM ) as a mechanism to integrate applications and excellent support for creating ATL based COM components enabled people to write applications in layered manner across the network. Microsoft came up with MTS , MSMQ (later merged into COM + ) and related technologies to help us integrate applications . ( It was called Windows DNA - Windows Distributed Network Architecture )

With the arrival of java , there are other tools which I got exposed to. The first was RMI/IIOP ( Remote Method Invocation ) and then , support for EJB .

Finally , It became Enterprise .NET stack and JEE stack. Then , SOAP over HTTP ( aka Web services ) became the norm and interfacing java and .net apps became a routine affair for me.

Recently , I worked with Apple iPad as the front end and .net enterprise stack (WCF ) at the backend. It was an Ocassionally connected application  (OCA ) and there were challenges with large file transfer , SOAP requests/repsonse, Synchronization and failsafe behavior.


Even though , I have mentioned lot of technologies, the Integration methodologies roughly fall into

a) File transfer
b) Shared database
b) Remote Procedure call/Remote Object call ( WCF , EJB stuff )
c) Asynchronous messaging ( JMS , MSMQ stuff )

The above information (regarding integration methodologies ) were usurped from the book,

Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions by Gregor Hohpe & Bobby Woolf.

The taxonomy and quality of narration (regarding the business context ) is simply superb and given a choice I would have revamped the integration logic of couple of applications I had worked in the past.

Sunday, March 06, 2011

Iterator Pattern in Java

Iterator is a GOF pattern which is defined in the book as follows

"Provid a way to access the elements of an aggregate object sequentially without exposing its underlying implementation"


Here is a simple implementation of Iterator pattern in java


import java.lang.*;


import java.util.*;







interface Command

{

public boolean Execute();



}



abstract class BaseCommand implements Command

{

public boolean Execute() {

return false;

}



}





class MoveCommand extends BaseCommand

{

public MoveCommand( int dx , int dy ) {} 

public boolean Execute() {

System.out.println("MOVE ... ");

return true;

}



}



class RotateCommand extends BaseCommand

{



public RotateCommand( double angle ) {} 

public boolean Execute() {

System.out.println("Rotate ");

return true;

}



}



class ScaleCommand extends BaseCommand

{



public ScaleCommand( double sx , double sy ) {} 

public boolean Execute() {

System.out.println("Scale ");

return true;

}



}



class CommandIterator implements Iterator

{

int position = 0;

private Command[] arr;



public CommandIterator( Command [] parr ) {

this.arr = parr; 

}



public boolean hasNext() {

return position < arr.length ; 

}



public Object next() { 

if ( position >= arr.length ) 

return null;

return arr[position++];

}



public void remove() { }



}





public class IteratorTest 

{



public static void main( String [] args )

{

Command [] as = new Command[5];

as[0] = new ScaleCommand(1.3,1.3 );

as[1] = new RotateCommand(45);

as[2] = new MoveCommand(10,10);

as[3] = new MoveCommand(-10,10);

as[4] = new ScaleCommand(1,1);



CommandIterator it = new CommandIterator(as);

for( ; it.hasNext() ; ) {

Command cmd = (Command)it.next();

cmd.Execute();

}



}



}

Watched Videos on AOP and HADOOP @ Software Engineering Radio

Today morning , I happen to check my mail to get the route map  to Thalayola Parambu for a wedding. I happen to get a mail regarding a post which I had done some time back.

I visited Software Engineering Radio site and as a bonus watched

Episode 160 : AOP ( Ram Nivas Laddad )
http://www.se-radio.net/2010/04/episode-160-aspectj-and-spring-aop-with-ramnivas-laddad/



Episode 157 : Hadoop
http://www.se-radio.net/2010/03/episode-157-hadoop-with-philip-zeyliger/

Friday, March 04, 2011

New Mobile platform !

Tilak is vary of his colleagues who mostly hail from Andhra Pradesh.

Tilak => "These people are making my life miserable"

Prem => "As much as you are forraying into Bangalore they are also doing the same"

Tilak => "But , these people team up to beat us !"

Prem => "What is wrong with it ?"

Tilak => "They are so assertive  that even Google is planning to come up with a mobile platform called Andhroid for these people ..!"

Groovy - I've started liking it !

In the last couple of years , I have heard lot of people rating Ruby On Rails ( ROR ) as a noble citizen of the enterprise framework world. I have seen tremendous excitement and never understood the reason behind it. Nor, I bothered to probe it deeper.

Intermittently  , I fiddle with groovy now a days and found that it is a language which can specify computation in a succinct way and seamless reflective capability of the language is amazing. This can open up a new world of cognitive space for a java/.net developer.

Groovy has got excellent support for Builder pattern and I am really impressed with it's capability. During my spare time , I have started flipping through the pages of "Groovy In Action" book.

The person who introduced me to the world of Groovy had talked about  (most of the ) C# 3.0 + features are available in Groovy . I brushed aside it back then. With C# 4.0 , MS had introduced ExpandoObject and I found support for that as well as indexer in Groovy.

I am yet to explore the DSL capability of Groovy !. Highly recommended.


Thursday, March 03, 2011

Coding GOF patterns in java

Currently , I am consulting for a company whose developers are developing an Integrated business suite using Groovy/Grails. Groovy/Grails framework supports lot of advanced features like closure , Meta Object Protocol , dynamic typing on Java Virtual Machine.

To broaden the horizon of developers over there , I am planning to demonstrate ( in java ) about

a ) Fundamentals of Object Oriented Programming
b ) Object Creation using new , Beans and Reflection API
c ) Robert C Martin's SOLID principles
         S - Single Responsibility Principle
         O - Open/Closed Principle
         L -  Liskov substituition principle
         I  -  Interface Segregation Principle
         D - Dependency Inversion Principle
 d)  Why Pattern Oriented Software development ?
 e )   Diving deep into GOF patterns
 f )    Arlow/Nuestadt Pattern
 g)    POEAA ( Patterns of Enterprise Application Architecture ) by Martin Fowler
 h)   DDD ( Domain Driven Design )
 I)   DSLs

As part of the above , I am writing implementations of some nineteen GOF patterns in java. For some patterns like interpreter , facade and composite , I am porting C# code to java. This process helped me
to understand why java is falling behind C# in programmer productivity. C# seems to be a better language to express computation than Java ( IMHO ). Only closest alternative is to program Java using Groovy and Java intermixed !.



            

Wednesday, March 02, 2011

Back after "HP technology @ work 2011"

I and a friend of mine did attend HP technology @ work 2011 held at Hotel Dreams , Kochi. It was infrastructure / CIO speak all around and was quite  informative.  We gained valuable insight into the concerns of a CIO in setting up a enterprise network in aligning IT with  business goals.

Got a nice bag , cock tail party and a dinner.

Tuesday, March 01, 2011

Maintaining Count !

Tilak was busy reading in news paper about a 66 year old man who has got thirty nine wives and ninety four children. The news clip goes as follows

"Aizawl, Feb 20 (PTI) Believe it or not, a man in Mizoram has 39 wives, 94 children and 33 grandchildren -- all living together under one roof in a picturesque village about 100 km from Baktawng in the north of the state.



The head of the family and leader of the "Chana" sect -- which allows polygamy -- is 66-year-old Ziona Chana who lives with his family in a 100-room, four-storyed house named ''Chhuan That Run'' or the House of the New Generation.



"Today I feel like God''s special child. He''s given me so many people to look after. I consider myself a lucky man to be the husband of 39 women and head of the world''s largest family," says Ziona."

When prem arrived ,Tilak showed the news clip and prem was indifferent


Tilak => Isn't it amazing ?
Prem => These kind of people will ruin our country !
Tilak => I am wondering how he has managed to maintain his count !!

Prem => I am sure about one thing. At least some of  his neighbhours seems to have maintain their count !!!!






Visited Reliance Timeout @ Oberon Mall after a long time !

I normally spend the money I get from presentations in buying new books. Today , I visited Oberon mall to buy some books and purchased three books

a) The art of Strategy - By Avinash Dixit and Barry NaleBuff (Rs. 595 )
b) What Is your MBA IQ ? by Devi Vallabhaneni (Rs. 399 )
c) Enterprise Integration Patterns by Gregor Hohpe and Bobby WOOLF . ( Rs. 725 )