/**
*
* PI approximation using Monte Carlo Simulation. Draw a square of
* unit area on the ground, then inscribe a circle within it. Now, scatter some
* small objects (for example, grains of rice or sand) throughout the square. If
* the objects are scattered uniformly, then the proportion of objects within
* the circle vs objects within the square should be approximately PI/4, which
* is the ratio of the circle's area to the square's area. Thus, if we count the
* number of objects in the circle, multiply by four, and divide by the total
* number of objects in the square (including those in the circle), we get an
* approximation to PI. (http://en.wikipedia.org/wiki/Monte_Carlo_method)
*
*/
public class PiEstimationWithMonteCarlo {
public double estimatePI(long numberSample) {
long numberInCircle = 0;
double pi = 0.0;
for (int i = 0; i < numberSample; i++) {
double x = generateRandomNumber();
double y = generateRandomNumber();
if (insideCircle(x, y))
numberInCircle++;
}
pi = (numberInCircle * 4) / ((double) numberSample);
return pi;
}
private boolean insideCircle(double x, double y) {
double distance = x * x + y * y;
if (distance > 1) {
// out of circle
return false;
}
return true;
}
private double generateRandomNumber() {
// between -1 and 1
return Math.random() * 2 - 1;
}
public static void main(String args[]) {
PiEstimationWithMonteCarlo piEstimator = new PiEstimationWithMonteCarlo();
double pi = piEstimator.estimatePI(5000000);
System.out.println("PI=" + pi);
}
}
Friday, October 17, 2008
PI approximation with Monte Carlo Simulation
Tuesday, October 14, 2008
Bets and the City: Sally Nicoll's Spread Betting Diary
With these are in my mind, i bought a spread betting and a stock market books to get some beginner information about this sector. Let me be clear first, i don't like gambling, i never heard or seen anybody gains from gambling, apart from casino or gambling saloon owners. Besides, i saw from some of people around me how gambling dramatically effects people's life.
Spread betting book i purchased is Bets and the City: Sally Nicoll's Spread Betting Diary. It has good review rate on Amazon and i think it is a good book to get some starting information on learning phrase of a spread better or gambler.
Nothing can explain this book more than "Bridget Jones meets Wall Street", i think. As a middle age, single lady with tendency to gambling, Sally decides to play on spread betting after reading an article on a magazine. She is also a full-time writer, struggling to finish her first novel. While she learns and gamble rather than trade on spread betting, she writes her spread betting experience or dairies on a spread betting company's website.
She puts together a genuine dairy. In her blog/dairy, she writes all her mistakes, losses, gains and lessons with a hilarious way with her daily life. Like many beginner, she is not much successful, in many trades she loses, but each time she strikes back with new methodologies. And she explains in a clean way her mistakes, as much as she can.
When she published her spread betting dairy as book, after a year, she was still a learner and not millionaire yet. She does not reveal her final account figures in the end of the book, but i think, she lost big chunk of her initial money. But she still claims that spread betting (especially binary betting) is a trade rather than a gambling, which i doubt very much, especially in this financial crisis (even in normal conditions, in the medium and long term). Maybe Sally should try also arbitrage sport betting which a friend of mine claims that he earned decent amount with his pocket money when he was in university. When i heard these, i can not help myself thinking motto of BBC3's The Real Hustle TV program: "These bets are very tempting to take part in but you can guess which way the bet always goes - the hustler's way!"
Wednesday, October 01, 2008
Sample Address Book
Presentation layer
- GWT
- EXT GXT
- Spring
- Hibernate
- HSQLDB (or MySQL)
Source code as eclipse project is available here . Please note, in order to run project in eclipse, a maven 2 plugin must be installed. I suggest m2eclipse (http://m2eclipse.codehaus.org/).
Requirements for the address books are as follows:
- A simple address book with three separate pages.
- The first page should allow the user to input up to 50 names and phone numbers at a time. The user can input between one and fifty name/numbers at a time.Each name must be unique and have only one phone number.Both the name and the phone number must not be blank.The names and phone numbers should be stored in memory. Phone numbers should be validated to contain only numbers, with an optional + prefix and possibly one pair of brackets with at least one number in them. The phone number must start either with a + or a 0 - if it starts with a +, it cannot be followed by a 0.
- The second page should list all stored numbers and names, sorted alphabetically.
- The third page should allow a user to search the address book by phone number (exact number, not substrings) and also by full name or part of a name (case insensitive). It should display all matching names and related phone numbers for the search criteria.
Saturday, September 06, 2008
Spring in Finance eXchange
Patterns of Enterprise Application Architecture by Martin Fowler
Enterprise Applications
Followings are the important aspects of an Enterprise Applications:
- Persistent Data
- Huge Volume of Data
- Concurrent Access to Data and Resources
- Multiple User Interfaces
- Integration with other Enterprise Applications
- Same data with various syntax and semantics format
- Complex Business Logic/Illogic
In the light of these, we can say that, for example, following applications are not of enterprise applications: web browser, word/image /video processor, games, OS, compilers, digital TV software... And followings can be given as examples to enterprise applications: " ... payroll, patient records, shipping tracking, cost analysis, credit scoring, insurance, supply chain, accounting, customer service, and foreign exchange tradin."
Performance of an Enterprise Application is one of the vital factor in its success. Following has to be kept in mind during design in terms of performance:
- Response Time: Amount of time it takes to process an request
- Responsiveness: How quick the system acknowledge back that a request is received. Generall, responsiveness is more shorter than response time.
- Latency: Minimum time to get a response from a remote system for a given existing or non existing task or request. Remote calls tends to increase latency therefore they should kept minimum.
- Throughput: The amount of work/task done in a given time.
- Load: How much system is under stress due to concurrent requests on a time point.
- Load Sensetivity: Under a specific load or stress quickness of response time
- Efficiency: Performance (response or throughput) per by resource
- Capacity: Maximum effective load or throughput of a sytem
- Scability: How performance is affected if resources are added or removed. Especially, hardware resources must be kept in mind when considering scability.
In terms of performance, the ultimate target in enterprise applications is to maximize the throughput or minimizing the repsonse time. Obviously, there is a trade-off between throughput and response time, therefore, ratio between throughput and response time has to be decided based on the constraints and requirements of application domain.
Chapter 1- Layering
Layering is one of the fundemantal pattern in enterprise applications. Layering is representing an application with loose coupled and highly coherent components, each of which sits on top of a lower components. Each layer only aware of the lower layer and it provides an interface to communicate with upper layers. Layering provides:
- Abstraction: Each layer is responsible of a set of task and does not has to know detail implementation of other layers
- Substitute: Without effecting much other layers, a layer's implementation can be changed.
- Minimize dependencies
- Standardization: By providing interface each layer make some sort of de-facto standardization, contract for other layers.
- Reusability: Layer can be used with other high level layers.
On the other hand, extra layering would degrade performance since in each layer data or inputs has to be transferred into the layer specific format.
The Three Principal Layers
There are three principle layers:
- Presentation: Displaying or providing information to user. Generally sits on client side
- Domain: Business logic which generally sits on server side.
- Data Source : Communication with database, messaging system, transaction again generally on server side.
Chapter 2. Organizing Domain Logic
Three separated pattern to organize domain logic:
- Transaction Script: Based on simple procedural approach
- Domain Model: Based on Object Oriented modelling
- Table Module: Hybrid of transaction and domain model
A common approach is to put a Service Layer on top of above patterns in domain logic. A service layer provides clear API and placeholds for transaction control and security.
Chapter 3. Mapping to Relational Databases
This chapter elaborates mapping patterns and issues between domain layer and datasource layer such as architectural, behavioral, structural, decorative, connections and schemas. Fortunately, many of these concerns and patterns are implemented and addressed with latest OMR frameworks (such as hibernate) unless if you dont want to create your own OMR layer or framework.
Chapter 4. Web Presentation
Most important aspect in Web presentation is separation of business logic from web presentation by using patterns similar to MVC (Model, View, Input Controller). In case of a web application, MVC works as follows:
- A request comes to controller which extract required information from the request.
- Controller forwards it to business logic for an appropriate model object
- The model object fetch persistent data via data access objects and aggregate/format data for response object
- Returns to controller to decide which view will be used to display the response.
- Controller passes the response data to the view
- View is prepared and return back to client
Separating model from presentation is also a good practice in terms of testing. Each section, especially business model, can be tested independently without dealing with presentation issues.
View Patterns
- Transform View: Similar to XSLT, it deploys a transformation schema which applied to inputs.
- Template View: With structured page which has embed markers indicating where dynamic content to go. Server page technologies such as ASP, PHP, JSP implement this pattern. While this pattern provides a flexible and powerful coding, unfortunately, it also leads to a messy presentation code.
In addition to these patterns, view is generated either with a single step(stage) or two step view. In single step view generation, there is a one view module for each user interface, display and presentation decisions are taken only in this module. But in two step view, each view module responsible of a specific view and then this view is passed to second stage where global, common view is created. This is a vital advantage of two step view cos of it provides highly coherent view modules.
Input Controller Patterns
Input controller handles HTTP request and analyse it and then decide what to do with the request. There are two patterns for input controller :
- Page Controller: For every page there is a input controller which create models and process it and then create a view object and returns it.
- Front Controller: A centralized single object intercepts all requests and upon analyse them, it creates separate handlers to process each request.
Chapter 5. Concurrency
Concurrency Issues
- Lost Updates
- Inconsistent read
- DeadLocks/LiveLocks
Execution Contexts
- Request
- Session
- Process
- Thread
- Transaction
Isolation and Immutability
Isolation and immutability are among two solutions for concurrency problems. In isolation, shared resource is isolated for only an active agents such as process in operation systems. Other approach is to make shared resource is immutable. If no active agent tries to change the shared resource, then there wont be lost update or inconsistent read problem.
Optimistic and Pessimistic Concurrency Control
If we can not enable a isolated or immutable shared resource, then we have to carry out either an optimistic or pessimistic concurrency control.
In optimistic concurrency control, shared resource is allowed by two or more active agent and then a conflicts are detected. If there is a conflict, it is asked user to make decision (to merge, or cancel) similar to source control system such as CVS or SVN.
In pessimistic concurrency control, once an active agents starts to work on a shared resource, agent locks it, and other agents can not access it until the active agent unlock the shared resource. Unlike optimistic approach, while this approach maximise the concurrency, it suffers from low availability as a shared resource is accessed by only one agents at a time.
Severity of conflict and frequency of changes are the two major factor deciding which approach to use. If change frequency is high and severity of conflict is low then optimistic approach can be chosen. But if conflict is major factor then pessimistic approach is the answer. But these two approach comes along with additional problems such as deadlocks and livelocks.
Transaction
Transaction is one of the primary technique for concurrency control. A transacation is a sequence of work with consistent states and well defined start and end points. All works in transacation are carried out completely nor neither of them if one fails (rollback). Transaction can be defined with following four properties (ACID)
- Atomicity: Transaction as a whole is an atomic process. Namely, if a step in the transaction fails, then all other steps will be rolled back. Transaction finishes successfuly with an commit statement.
- Consistency: During all step of transaction, system state must be consistent and noncorrupt.
- Isolation: Results of each internal steps in a transaction is not visible to other transaction until it finishes with a commit statement.
- Durability: Commit statement must do result of transaction persistent.
Databases, message queues, ATM, printers are the sample transactional resources. A transaction should be short as much as possible. If a transaction takes more than a request, then it is called long transaction. And if a transaction' s lifeycle is bound to only a request's, then it is called request transaction, in other words, it starts and finishes with requests. Another variation is late transaction which works for only updates. It does not prevent inconsistent reads.
Transaction Isolation Levels
Isolation levels are defined in terms of three factor:
- Dirty Read: You are permitted to read uncommitted or dirty data. Data integrity is compromised, foreign keys violated and unique keys ingored.
- Non-Repeatable Read: It means a row can be updated at two different time, T1 and T2 and each time, you would get a different updated data.
- Phantom Read: If you read a row at time T1 and then later T2, data will be same on the row but more related row data is added to table.
ISO 92 standard defines four transaction levels (from low to high):
- Read Uncommitted
- Read Committed
- Repeatable Read
- Serializable
Isolation Level | Dirty Read | Unrepeatable Read | Phantom |
Read Uncommitted | YES | YES | YES |
Read Committed | NO | YES | YES |
Repeatable Read | NO | NO | YES |
Serializable | NO | NO | NO |
Chapter 6. Session State
A session in a distributed environment system can either be:
- Statelessness: System does not retain state between requests. When a request invoke a method, the state of the objects used by the method are not known. As default, HTTP protocol is stateless.
- Stateful: System stores or keep track of states or information between requests.
Stateful system requires more resource as each stateful object has to to store all its states. On the other hand, a stateless object can be other requests too. But in real life problems, we need to store states. Therefore, best approach would be to store states on a stateless server.
Session States
Session state are the states that they are bound to session and isolated from other concurrent sessions. Lifecycle of a session state is limited with session's, so if you want to persist states further than business transaction, they should be persisted on other medium such as on databases.
Session states in business transaction has to obey fundemantal rules of transaction (ACID) when business transaction finished. For example. during business transaction, session states maybe be in invalid or inconsistent, but before commit, they have to be consistent with the rest of the data. But more important concern is the isolation between session states. Operations in business transaction must not cause an inconsistent data cos of multiple concurrent read and updates. Session states must be kept isolated from other sessions.
For performance reason, some data can be stored in sessions as part of a cache mechanism between requests. But this data is not a session state.
Methods to Store Session State
- Client Session State: Storing data on client side. Most common methods: encoding data on URL, cookies or hidden form variables in html. Often these session data has to converted to right format in server side. If the amount of data is large and frequent, that approach suffers bandwith problem. It also exposes security and data integrity issues, unless data encryption is applied.
- Server Session States: For example stroring data on server's memory or more for further persistence, serialized object can be stored on filesystem or database table where session id would be primary key and serialized object would be value. In case of session migration, transfering session to another server, session states have to stored in a shared resource or memory. That approach is good when session states are continouosly proccessed.
- Database Session States: It is also server side but object's states are mapped to columns in a table for a longer persistence. Special attention has to be paid to secure isolation of session data in databases. In terms of performance, this approach is appropriate when session data is idle most of the time, for example in a public retail system.
Session data has to be cleared after some timeout or if request is cancelled. In case of client session state approach, this is not big concern as much others. A timeout has to be put place in server and database session states.
These three approaches can be used all together. But generally Server and Client session states are mostly used in practice. As pointed out above, if data is small and not complex, client session states is a good candidate. If you need failover, clustering and isolation between session is not problem, then Database session states can be used.
Sunday, August 03, 2008
Credit Crunch and "The Revolutionary Idea of Karl Marx" by Alex Callinicos
http://www.istendency.net/pdf/revideas.pdf
This book gave me an absolutely different perspective on original idea of Karl Marx. As he pointed out in his latest years ("All I know is that I am not a Marxist") many of of Marx's ideas are misunderstood, twisted or not implemented in the correct way. In this biography Callinicos explains the revolutionary idea and life of Karl Marx in a plain way. Even more, in a way, the book gives an insight to the fundamental reasons of latest financial global crisis as Trotsky also pointed out:
Although i think some of Karl Marx's ideas are irrelevant now, it is still a great book to read to understand modern politics, economy and class based social life.
Monday, June 30, 2008
The Career Programmer: Guerilla Tactics for an Imperfect World By Christopher Duncan
Recently I come cross a brilliant, funny, practical e-book "The Career Programmer: Guerilla Tactics for an Imperfect World" by Christopher Duncan. The title of the book actually explains lots. The author narritives his real world work experiences with a witty, funny, daily life language. I think this book should be a must reading for software engineering students.
Sunday, June 22, 2008
Churchill A study on Greatness by Geoffrey Best
My research on Internet led me to a relatively recent published book: "Churchill A study on Greatness" by Geoffrey Best whom teaches history at Sussex University. The book is compiled out of enormous literature research. In this book, Geoffrey Best aims to cover overall respects of Winston without much penetrating into details.
Although Geoffrey Best puts an incredible work to justify how great was Winston Churchill in its historical context, unfortunately, given the stories and evidence in the book, my impression and thought about Winston is completely different and, to surprise myself, it is, even worse,a disappointment. To credit to the author, he points out in the book, given the evidences and stories, readers should make their mind on Winston Churchill themselves. Unlike the author and many people, given my working class, non-white, social-democrat background, i am failed to see why Churchill is a great man in terms of international and national politics, war leader, personality, literature, family. Let me elaborate my thoughts on these subjects.
Let's start with a summary of his peculiar personality. In his all life, even though Churchill did all his best to evade any type of classification, people knew him and some historian describe Churchill as egoist, gambler, loves luxury lifestyle, rude to people working under him, difficult to work and get along together, Victorian Liberal Imperialist, opportunist, man of war (warmonger) and peace, enemy of working class people, believer of white-superiority of Anglo-Saxoinism and Tory radical, sympathetic to Zionism, imperialist, good political speaker and writer. Sure, i think some of these are over-exaggerated.
Winston Churchill is known well as politician and military background. After high school,he attended Royal Military Academy for two years and he commissioned as Second Lieutenant. As service man, he deployed to various part of British Empire, Cuba, India, South Africa, Sudan and Malakand. Even though he disliked traditional education system in his school times, he self educated himself during the service. In addition, he also wrote articles as war correspondence to several London based newspapers. He was a brave soldier and participated in several risky campaign.
Winston Churchill, first of all, was a politician. After spending five years in the army, in 1900, he started his political career in the conservative party where his father was also a hard-core MP. But he did not stayed there for a long time. In his second election, against his families and father's will and tradition, he transferred to the Liberal Party where he assumed doors and posts will be opened more quicker. He was right. Soon, he undertook important positions in the party and the governments between in 1905 and 1916 till disastrous defeat in the battle of Gallipoli against Turks in which he was Admiral. He never recovered from that bad publicity caused deu to his role in this battle.
As politician, he was big supporter of free trade and in many circumstances he comes cross as an opportunist. Especially in the beginning of his career in the Liberal Party, in election campaigns, even though he comes from aristocracy, he gave speeches that House of Lords should not be superior than House of Common upon he sensed the unhappiness among the working class electorates against aristocracy. In 1924, he rejoined the conservatives and until 1929's he undertook the position of Chancellor of the Exchequer in the conservative government. Some economics believe that, his decision to return to the gold standard at the pre-war parity in 1925, would lead to a world depression. In industrial conflicts and strikes, in many occasion, he put his preference on business elite and he made a reputation as enemy of working class people.
Upon 1929 general election lose, Churchill stayed away from politics for couple of years. This isolation is due to his personal relations with party management, his stand against India policy and his connections with dubious peoples. When he backed to Parliament in first half of 30s, he vigorously established an anti-Indian, Nazi and Communism campaign. But none of his opinions is taken into consideration by majority of people cos of his warmonger, imperialist attitude. With WW II, in 1940 he backed to main political arena again as Prime minister due to his military background.
Overall, both in Liberal and Conservative parties until 1940, he was not an extraordinary politician and not put his name under long term significant works. He made reputation as egoist, opportunist, rude to people working under him, difficult to get along together, Victorian Liberal Imperialist, warmonger, enemy of working class people, anti Nazi and Communist, opposite to Indian independence, supporter of white-superiority of Anglo-Saxinism and sympathetic to Zionism. Even more, in all his political life, it seems, because of his love to luxury lifestyle, he never hesitated to get financial help from his rich friends.
During WW II, as prime minister and leader of national coalition government, he led his country against Nazi Germany. And he owes all his popularity to this role. For his countrymen, he is the saviour of not only UK but also civilization against Nazi. I think his role in WW II is overrated. I think he was only the defender of his country. UK could not won the war by herself, and it took long time, in spite of mass colonies and resources. Fate of the war only has changed after Soviets and America joined to the war in Allies side. Besides all of these, there are doubts on his leadership skills.
Without doubt, Winston Churchill was a good speaker and boosting morale of public in war times. But I wonder if someone else would be able lead better the army and country in WW II? Because people working under him often say that he was full of ideas. For an issue, he was coming up more than 10 different ideas. Unfortunately, so often, only one of these ideas was plausible and his staff wasted quite lots of time to argue about impractical side of his other ideas. You can guess how it would be difficult to work with someone who especially thinks: "All i wanted was compliance with my wishes after reasonable discussion". Who knows maybe with a better leader, the war would have been won more faster against Nazis. I think, the public should have shared the similar frustration with his management, so after WW II, in the first election in 1945, Labour party defeated Churchill with an unprecedented seat majority in the Parliament. Besides these, short after Nazi Germany was defeated, in international meetings, Britain could not defend her interest well against Soviet Union and America. Some diplomats complaint that Winston Churchill attended meetings without much preparation, even worse, sometimes without reading the briefings.
Someone would argue that, given the historical context and resources, Winston Churchill achieved incredible results. But i can not help to think that, people can create miracles in real tough circumstances. 20th century has being witnessed many great national leaders in many wars in which superior countries attacked small, tiny countries but dramatically been defeated. I think, if opportunities were given to other people, Britain would had achieved better with a more skillful person. But without any doubt, unlike the battle of Gallipoli in WW I, Winston Churchill did not let his country down in WW II with help of Soviet and America.
Towards to end of WW II and afterwards, in government and opposition seats, he introduced the main seeds of European Union movement. After WW I, not many people in Europe was thinking there would be another war in Europe soon. But WW II proved that that assumption was so optimistic. In order to prevent such a third war in Europe and against Soviet occupation, Winston Churchill developed and introduced European Union movement. He worked and campaigned on this idea especially when he was on the opposition between 1946-1951. But when he came to power again in 1951, he put his preference on America once again and focuses on the "special relationship" with America. But on the other hand, he always iterated that UK will be always with Europe to against Soviet. To credit to him, whatever his motive was, Winston Churchill was one of the prior in European Union movement.
After WW II, having defeated Nazism, Winston Churchill turned his all attention to the old enemy, Communism. Expansion of Soviets to East Europe after WW2 caused concern among western European countries and Churchill used this atmosphere to promote his anti-Communism in UK and USA. His tone of language against Soviet got more stronger with time and he established his new political career on anti-Communism. He was even accused of being a provocateur, warmonger by some Labours. He was the principal architect of Iron Curtain betwen Soviet and West. It seems to me, in order to come power again, Churchill and some conservatives promoted a political tension in between Soviet block and Western countries which lasted until the end of the century. Once more, this tactic of seizing power and keeping people under control by creating a common enemy is used against Muslim by neocons after communism collapsed.
His stands on non-white European colonies and countries were imperialist and he was big believer and supporter of white-superiority of Anglo-Saxionism. Without much change, in his all political life, he opposed of independence of India. His following remark on Gandhi in 1930 explains his conservative, aristocratic, imperialist, politic background:
"A seditious Middle Temple lawyer now posing as a fakir of a type well-known in the East,striding half naked-up the steps of the Vice-regal place... to parley with the representative of the King-Emperor."
Winston Churchill had tendency that non-white people can not run their countries themselves. For example, with irony, he claimed that Indian people would be better under the British rule because he thinks that non-white people are lack of self management. Irony is that, in his white aristocratic, imperialist world, in spite of limited academic, military and political achievement and inter personal skills, a white aristocrat can become an MP and even more a Prime Minister, but a non-white person such as Gandhi, who is a lawyer and graduated from London, loved and respected by millions in India is not capable of self management!
Luckily India has not suffered much from his opposition. But Middle East suffered dramatically cos of his and his peers's policies, prejudice, ignorance and sympathy to Zionism. After first WW I,he was in charge of determining new borders in Middle East. New borders are drawn without taking into consideration of local people's opinion and many current problems in Middle East (Palestine, Jewish, Kurdish, Arabs) are attributed to role of his role. In these talks, he did not even want to meet with Arab delegates.
Another interesting characteristic of Winston Churchill was that he earned his livelihood from his pen when he was not in the Parliament. He published several books on military, WW I and II and English speaking world. He also wrote many articles for newspapers. At the moment i am reading, his "My Early Life" book, later i would be able to comment about his writing style. He won the Nobel Prize in Literature 1953. He hired several, Oxford graduated writer to help him in his latest books after WW II. There is also not much known artistic side of Winston Churchill. In his free times, he painted and vivid colours were dominant in his paintings.
In family side, although he was close to his children and biggest admirer of his wife, his children did not catch up any of his success or popularity. His son, Randolph, followed his fathers step in terms of career, personality and lifestyle and with failure. Some of his daughters made unhappy marriages. Most interesting part of his life, surprisingly, his never lasting love to his wife. He and his wife, were biggest supporter of each other all the time.
In conclusion, I do understand admiration of Kasparov to Churchill because Winston was the first person in Western warned and even more provoked people against Communism. He was the main ideologist in the West created so-called Communist Monster. But, i think, Kasparov misses a crucial thing. Due to his character, Churchill never lack of enemies or suspicion of stranger/foreigner. In order to keep his status, he and neo-cons always created an enemy. His stand, vision on Communism is more prejudice similar to his attitude against India, Middle East, Palestine and desire and hunger to the power.
Based on this book, i think, Winston Churchill is really overrated in its historical context. I do understand this pheromone from the British, conservative point of view. Every nation or political movement has tendency to satisfy their ego anyhow with national heroes. But from an objective point of view, I think British Empire should/would have done better without Winston and there are certainly far far better statesman in 20th century in all around the world.
Friday, June 20, 2008
Losing My Virginity: The Autobiography by Richard Branson
Even though, Branson is one of the well known celebrety entrepreneur in Bratain, it is so rare to see him on public events (even on enrepreurial related TV prograns such as Dragons Den). It seems he enjoys his privacy and prefer to stay away from public attention which make people more interested in his life. His autobiography "Losing My Virginity: The Autobiography" is a good reference for those who interested in him and history of Virgin.
In his autobiography, his extra ordinary, colorful life is fluently told in a relatively long way (now it is about 600 pages, and he updates it regularly every year). Although, last two chapters (2006 and 2007) kinda come across as snapshots from his busy calendar, this book suprisingly is worthwhile to read.
Richard Branson is born into a post war England in 1950. He is the oldest children of Ted and Eve Branson both of them actively involved in WW II. Richard with his two sisters had a peaceful childhood in Surrey. He describes his family as that would have killed for each other. That special bond between him and his family, especially with parents can be sensed through the pages whole book.
He remembers his childhood full of challenges which were set up by his parents and relatives to make him self-sufficent and creative. These challenges were generally sportive and business oriented rather than academic. This was not a coincidence. Since Richard has dyslexia, his academic record was not good, however how much he tries hard in schools. In these times, when dyslexia was not known, and pupils who fail at Math are branded as stupid, sportive activies were the only way to survive in school. So, Richard focused on sport and made a good reputation as football player in school team. But after an accident in field, doctor banned him participating any sportive activities which led to a miserable school life. Upon the accident, he spent his most of the time in library, far away from eyes, but girls.
One of most apprepciated characterisitct of Richard, i think, his modesty and personality. From the first pages of the book, it came cross to my mind that maybe he owes his personality to a degree to his dyslexia which made him more sensetive, conscious, caring to other people. My this superficial thought is got stronger when i read Sally Gardner's interview on a magazine. Likewise Richards Branson, Sally Gardner is a dyslexia and she makes livelihood writing children books. She does not also recall great memories from her schooltimes due to her dyslexia. She explains affect of dyslexia on personality by : "After such a long period of time seen as a misfit you always feel an outsider. It is something that never leaves you. I will always be a round ball in a square hole. "
Since neither in academic nor sport(after the accident) he was successful, he directed his all effort to small scaled business plan in his childhood. In high school, about in the second half 60's, when students rebelling against established system in all around the world, he came up with the idea of a student magazine called Student. With a childhood friend, he set up the magazine. While his friend was editor of the magizine, he took all financial and organizational responsibilities. He and his friends made Student one of the biggest magazine for student in 60's. While content contributors of Student were generally leftist, he tried to keep himself in neutral, as a business man.
He learnt quite lots of deal about marketing and business and made extensive business network out of Student. As far as i see from the book that Richard Branson tries to apply all these lessons to all his business deals till now. Some of these lessons are that a succesful business is a team work and must enjoyable, the satisfaction of staff comes first and taking risk is essential to grown the business.
Rather than discussing about his success in business, i would like point out something else which i could not help myself noticing through the pages. As i mentioned above, Branson is very keen to his family, parents, sisters, children and wife. I dont want to speculate on his personal life, but with respect, i am a bit suprised that he did not mentioned so much about his second wife, Joan, mother of his two children and love of his life. Through lines, she comes cross as just a good, modest mother and full time house wife. But i am sure she is more than just these, as you guess, partners have big impact on someone's success. For example, Clementine, wife Winston Churchill, was the biggest supporter of his husband in many matters in peace and war time.
I think it would be very revealing to read biography of Joan&Richard Branson from one of their children (for example Holly Branson who recently graduated from University College in London with MD) for a objective and insider aspect to the life of Richard Branson.
Monday, June 09, 2008
Software Tests in GWT
Since software development in GWT is based on Java, many conventional and well-practiced test techniques related to Java can be utilised for applications developed using GWT. Following test techniques are supported by GWT:
· Unit testing (JUnit by extending GWTTestCase)
· Performance testing (Benchmarking, by extending Benchmark)
· Robot testing ( Selenium, UI test)
· Continuous Testing (Cruise Control)
Unit Test (JUnit)
Since GWT unit tests extends standard JUnit (version 3, not JUnit4), conventional JUnit test approaches (such as use of Assert assertion methods) can be used for GWT unit test cases. Each GWT JUnit test extends GWTTestCase and implements getModuleName() method which defines the interest of GWT module.
GWT JUnit supports asynchronous tests by introducing two methods, finishTest and delayTestFinish. delayTestFinish makes sure that test does not terminates immediately but wait for a period of time to handle asynchronous callbacks. As soon as a result obtained from asynchronous callback, finishTest should be invoked to finish test successfully, otherwise delayTestFinish will cause a timeout exception to fail test. In addition those, chain pattern can be implemented for invoking several asynchronous serially to simulate UI cases.
JUnit tests can be run either in hosted (default) or web mode (-Dgwt.args="-web" ,with various browsers). During hosted mode, cross browser compatibility is not checked. For this purpose, tests must be run against different browser in web mode. Corresponding to application size, compilation time can be longer (1-5 min) in hosted compared to web mode.
Please note that, in GWT 1.5 MS2 and RC1, the base test class which implements getModuleName() method must have the same package name as the package name of the module entry class. For example, for module com.booo.Boo.gwt.xml, the package name of the base test class should be com.booo.client
Performance (benchmarking)
With GWT 1.4, a benchmarking scheme is introduced to test performance of client side code. For profiling and reporting, in GWT, a benchmarking test class must extend Benchmark which is subclass of GWTTestCase. In addition to standard JUnit facilities, Benchmark provides automatic iterative test case invoking for given range or Iterator. Please refer to [1] and [2] for further information.
The biggest disadvantage of Benchmarking in GWT, unfortunately, it does not yet support asynchronous calls and access to server side code. This severely limits its use for testing performance of a whole application. Instead, it is better used to benchmark stand alone client side code.
Robot (Selenium)
Selenium is a de facto standard for robot UI testing. Selenium performs automatic UI trigger based tests against a given valid URL. Selenium utilises generally HTML elements' ids to carry out operations such as clicking buttons, editing input text or selecting an item from a list box.
These operations can be performed manually by a user on Firefox with the Selenium IDE which records all of these operations sequentially and then converts them to a Selenium JUnit class (extending SeleneseTestCase). These test cases can be aggregated in continuous tests similar to standard JUnit tests. Selenium supports continuous tests out-of-box with selenese Ant tasks [3].
Since any changes on the UI directly affect these tests, UI developers have to be careful in terms of naming or identifying HTML elements. If Selenium testing is chosen for robot UI testing a systematic schema has to be agreed and developed between QA and the UI developer. In addition to that, UI developer must use appropriate UI widgets and libraries which support identifying HTML elements for Selenium test.
GWT and continuous testing (CC)
Since GWT takes full advAntage of Java, it is possible to use a continuous testing schema for above tests. For example, Google uses GWT with CruiseControl for continuous testing. Eric Ayers from Google has described how they use CC and GWT in this link:
http://groups.google.com/group/Google-Web-Toolkit/msg/006793285e736d23
But for future reference, I am quoting it here again:
“…
The best advice I can give you for setting up a project build is to look at one of the projects on code.google.com:
- - gwt-google-apis
- - gwt-api-interop
- - google-web-toolkit-incubator
All of these are projects that use GWT as a library and we build from cruisecontrol at the top level and 'ant' build files to actual compile everything. The ant build files are included in the subversion repository, but the Cruise \control files are not. For Cruisecontrol, setup your project as follows:
Create a directory with the download of GWT you want to build against. This directory you need to set as the ant property 'gwt.home' You may also need a directory with the 'tools' directory from the GWT subversion respository (but I'm not certain you need this). This directory you need to set as the ant property 'gwt.tools'
Now, look at the common.ant.xml file in one of the projects I mentioned. It has rules for building and testing GWT projects. You will probably need a copy of the direcory 'build-tools' in order to use all of the rules. You can copy this from the GWT repository or use an Subversion 'external' refernece to pull it in if your project uses subversion.
Our cruise control configuration file does the following:
- - Refreshes the project code from SVN,
- - Pulls the latest version of the GWT ''tools' directory
- - builds the ant targets 'build' and 'test'
- - runs an artifactspublisher to pull down the 'dist' directory as well as the unit test reports.
...“
I have followed his instruction and managed create an ant script for CC. As he mentioned above, even though, these sample build files based on GWT_tools, you can create simpler build files by ignoring tools.
Conclusion
Since development in GWT is based on Java, many testing techniques common to the Java domain can be applied to GWT. GWT supports many standard testing techniques such as unit testing (JUnit), performance (Benchmark) and UI triggered robot tests (Selenium).
Generally, it is recommended to use GWT JUnit for non-UI based test such as logic and functionality test which may or may not require client and server asynchronous communication.
At the time of writing this report, GWT Benchmark does not support asynchronous call and access to server side code, therefore benchmarking in GWT is not useful for performance tests of complete application but only for isolated client side logic and functionality.
For UI trigged testing, Selenium can be used but since Selenium tests are tightly-coupled to HTML elements a systematic agreement has to be developed between UI and test developers against UI code changes and type of widget will be used.
All of these tests can be aggregated in Cruise Control for continuous testing.
For detailed information regarding benchmarking and JUnit tests in GWT, please refer [2].
References
- “Google Web Toolkit Applications” by Ryan Dewsbury. Page (170-180) for JUnit and benchmarking.
Saturday, May 24, 2008
I don't mean to be rude, but ... by Simon Cowell (?)
I like this program because it was real life story of interesting people who want to be next pop star, idol, celebrity. I could not believe in my ears when some deluded contester open their mouth and start signing. I am aware of that some people just go there to make mockery of audition (and there are also some kind of people as Renaldo Lapuz who sang "We're brother forever", which i will come later). But i always wonder where these deluded people come from? Venus, Mars? They must have been signing all time in bathroom or they have no friends/family members to tell them the truth. But i admire their courage and love to see disbelieve/shock in their face and eyes when they heard harsh truth from Simon Cowell in the rudest way. Do these deluded people need or deserve such a rude/harsh feedback in front of million on TV? Simon Cowell thinks they must awake from their dreams that they can not sign and Simon does his best and rudeness to wake them and sometimes humiliates them. But where does Simon get this power? How come he can be that much rude and he gets that much rating? I wondered if Simon in real life is also rude and when i saw his autobiography (I don't mean to be rude, but ... ) in a bookstore, i could not help myself to buy it.
As his TV program, his autobiography is also very entertaining, surprisingly. I was not expecting that much i will enjoy the book (although, i must admit i skipped some pages when he starts repetitively talking some American Idol episodes ). He took his autobiography(!) serious and hired the best ever biography author, i think, because it is well structured and story is well told. In book, as all autobiography, the book covers his childhood, his rebel years as teenager, career steps from post office to top of company, and Pop Idol epidemic. Towards the end of the book, he also talks about how to be a star for wannabes, if anybody interested.
Simon Cowell born in 1959 into a middle-upper class, Conservative family in London, UK. His father owns a property and estates related business. He grows up among many actors and actress , thanks to his father's connections and the neighbourhood they live where was close to film studios at this times. And sometimes he joins his oldest brother who works in a near film studios as a runner. He remembers his first rudeness as early as four years-old against his mother on a Christmas Day.
Even though, Simon's dad provided many opportunity for a good education such as sending him to a private school, Simon was not a brilliant student at school and did not believe that studying Math or English will make him a millionaire. He was more into fun and music in his childhood and teenager ages, even though he does not have any musical skills. At age of 16, he decided that school and studying wont provide him enough money (£millions), so he left school.
After leaving school, his father arranged many job interviews for him but he just made mockery of every interview, as he thought, none of these jobs would make him rich enough. He wanted to be rich and from his observations he thought that actors make lots of money and enjoy life. With help of one of his close relative, he starts working as runner in a film set with so little money. But cos of his arrogance, film producer fired him.
In the way of being rich, he decided to give a go to music industry in which he thought he would have a good career. Again, with help of his father's connection, he secured a position in one of the biggest record company, as a postman. To credit him, he knew that in order to get the top of the company with his less background and skill, he had to start from bottom and work hard. So, he worked in the company's basement as postman with big hope and ambitions. When he was working there, he knocked all doors, he tried his best to jump a better position related to music in the company. But as he noted, he made a big mistake. He started from really so bottom that people even did not care him as a postman. After 1.5 years hard work, he finally gave up and see the harsh reality of the life. First time in his life, he thought he wont be a millionaire.
Having failed in music industry, he decided to follow his brothers and father career path and started to work in a estate agent. He was not happy there, and his father knew that. His father again used his connection and secured him a better place in the record company where he is used as postman previously. He says that people there was not nice to him at beginning cos of how he got the job and also a bit of his high ambition and arrogance. In that position, he learned many things and then stepped up his career path and made millions. How he did millions is not much interesting, to be frank. Same old stories! He says the formula behind his success is hard work and be able to see changes in market and adapt. Sure these are important factors, but he forgets to acknowledge the another important one. Luck! I think he was quite lucky in some important moments in his career.
Another interesting point i learnt from the book is that, actually Simon does not have that much great vision, unlike he always claims in the judge panel. For example, before Spice Girls break to pop music world, they talked to Simon first, but he did not signed them. He also hesitated to sign West Life initially and declined to be a judge in first series of Pop Idol. (and in some part of the book, he thinks, marriage of Paul McCartney and Heather Mills is out of real love! As history shown, in the next edition of book, maybe he will update his anticipation on this matter!)
In last two-three chapters of the book, he gives advices to wannabes how to be a pop idol! In a nutshell, the greatest advice he gives is that unless if someone does not have right contacts (such as his father :)) or real talent, whatever he/she do will be waste of time. Even though, after hard work and some luck, if someone achieves to be a pop star, celebrity for a while in some way, he suggests that one of the best way of keeping the pop crown is to be on tabloid papers all the time by putting his/her private life in public domain such as dating other celebrities or doing crazy unorthodox things! Such a great advice! Now i understand the behaviour of Amy Winehouse!
You, reader of my blog, may think that i don't give enough credit Simon Cowell but that's my impression from the book. I think, Simon Cowell is an ambitious businessman and trying to make lots but lots money. That's all. He is not there for love of music but money!
As Simon points out in his book, the success behind XFactor and American Idol epidemic is showing, selling people that American Dreams can be true. Someone from nowhere among ordinary millions can change his/her life completely if he/she wins the program. I think, it is not just a entertainment program but it also sells and feeds many false dreams.
97.5 million in America watched the final of American Idol and i am sure it is popular in other part of English-speaking world too. So, I wonder what is the real affect of this program on society?More specifically, for example, how would rudeness of Simon Cowell affect on individual? Does Simon Cowell is a good sample to society with his rudeness and arrogance? What would happen if people start to behave as him? Just in sake of being honest, if people would break each others heart? You may think i am exaggerating lot! Altogether, we will see and face the consequences.
Although some of pop idols are really so talented, I am not sure if they would ever last a long period of time. The way these pop idols are marketed makes them also so easy and fast to be consumed and make Simon and record companies richer!
Finally, If you like American Idol/XFactor/Pop Idol then i think you will like this book too. It is entertaining as much as its TV programs.
PS: Last night i watched American Idol 2008 final and it was great apart from Renaldo Lapuz who sang "We're brother forever". I loved that song from the moment i heard it and listened it many times on YouTube. But in this program, they ruined, consumed, wasted it. Such a pity! Renaldo Lapuz should not let that happened.Tuesday, May 13, 2008
How life imitates chess by Garry Kasparov
In his autobiography, Kasparov narrates the story behind his success in chess. He shed a light on many questions about his personal life and chess, such as how many moves ahead he can see, how he prepares for matches and how he took title of World Chess Champion from Anatoly Karpov in 1987 after 3 years struggle and 120 matches ? He relates his experience with politics, business and personal improvement. In some sections of the book, i felt that this combination, especially personal improvement, is a bit cheap shot! Nevertheless, it has lots of advice and real life experience for personal development. He quotes lots from many successful people (Churchill is his personal hero).
But interesting point about this book, for me, was Kasparov's political's ideas, democracy struggle in Russia. I do support his democratic against Putin's undemocratic regime. After he retired professional chess in 2005, he actively involves in politics in opposition parties against Kremlin for a democratic change in Russia. For such a change, he and like-minded people (liberals, communist, human right activist) set up a nationwide rainbow organization (United Civil Front, UCF). UCF organizes activist against 2008 elections since 2004 for a democratic change. He points out that, this mixing of opposition groups in UCF gave fruitful results such as that these opposition groups better understand each others. Leftist, who are still under impression of Soviet era, have recognized the importance of freedom and democracy from liberals and liberals acknowledged social aspect of democracy from leftist.
I think Kasparov deserves all credit for his active role in UCF and he asks support from western countries, powers, companies to pressure on Kremlin for democratic change. Add this point, i dont agree with Kremlin. I think, he should not let external factors and powers involve in Russia's internal affairs. I am doubtful that interests of external powers are always same as the interest of people of Russia. Middle East is a simple example of who benefits and suffers cos of external powers! Careful consideration must be done when seeking external support, i think.
I strongly advice this books to those who loves chess or wants to read the story of a success.
Monday, May 05, 2008
Quotes and Notes
"As soon as man dares to think, the priest’s empire is destroyed";Holbach
"All I know is that I am not a Marxist";Karl Marx
"Capitalism does live by crises and booms just as human being lives by inhaling and exhaling... Crises and booms were inherent in capitalism from birth; they will accompany it to its grave.";Trotsky
“To want to wait, until everyone is sufficiently enlightened, as people usually propose, means to give the matter up completely; for an entire people will never be equally enlightened, at least as long as inequality and the struggle of private interests in society continue to exist.”;Wilhelm Weitling
"Communism [meaning the idea of Cabet] and Proudhonism stand by a river bank arguing whether the field on the other side is maize or wheat; let’s cross and see." Blanqui
“Marx was the genius who continued and consummated the three main ideological currents of the 19th century, as represented by the three most advanced countries of mankind: classical German philosophy, classical English political economy, and French socialism combined with French revolutionary doctrines in general.” Lenin
"After all, a man's life must be nailed to a cross either of Thought ot Action. Without work there is no play."; Winston Churchill
"I adopted quite early in life a system of believing whatever i wanted to believe, while at the same time leaving reason to pursue unfettered wahetever paths she was capable of treading.";Winston Churchill
"A seditious Middle Temple lawyer now posing as a fakir of a type well-known in the East,striding half naked-up the steps of the Vice-regal place... to parley with the representative of the King-Emperor." Winston Churchill described M.K Gandhi after first talk with British Empire and with M.K. Gandhi in 1930.
"Don't tell me about the press. I know exactly who reads the papers: The Daily Mirror is read by people who think they run the country, The Guardian is read by people who think they ought to run the country, The Times is read by people who actually do run the country, The Daily Mail is read by the wives of the people who run the country, The Financial Times is read by people who own the country, The Morning Star is read by people who think the country ought to be run by another country and the Daily Telegraph is read by people who think it is.Sun readers don't care who runs the country, as long as she's got big tits.";Jim Hacker,Yes, Minister
"War is too serious a business to be entrusted to soldiers";Georges Clemenceau
"Who needs your help most? It is those that have the least, that suffer the most.It is they that are rarely heard.";Nelson Mandela
"Know the truth and the truth will set you free.";Donald Makhubele
"if you wish to experience peace, provide peace for another. If you wish to know that you are safe, caouse others to know that they are safe. If you wish to better understand seemingly incomprehensible things, help another to better understand.if you wish to heal your sadness or anger, seek to heal the sadness or anger of another.";Dalai Lama
"i may be a businessman, in that i set up and run companies for profit, but, when i try to plan ahead and dream up new products and new companies, i'm an idealist."; Richard Branson
"The rock (music) business is a prime example of the most ruthless kind of capitalism!";Richard Branson.
"There are only 10 types of people in the world: Those who understand binary, and those who don't";
"If you want to succeed, double your failure rate";Thomas Watson
"I haven't failed, I've just found ten thousand ways that didn't work";Thomas Edison
"Nowadays people know the price of everything and the value of nothing";Oscar Wilde
"The hardest thing in the world to understand is the income tax";Albert Einsteun
"Computers are useless,they can only give you answers";Pablo Picasso
"Having an extra hour in the day would be welcomed by most everyone, but not the man in jail.";How life imitates chess;Garry Kasparov
Friday, May 02, 2008
From my old corners
For a personal project, i compiled detailed information on London undergrounds (address, post code, zone, lines, short description). It was very useful very for me and if you need it, click following link:
London Underground List - XML- TXT- XSL