Sunday, March 30, 2008

Java Profiling

Java Application Profiling using TPTP
- By Valentina Popescu, IBM - July 2006

Profiling an Application
In the current environment of short development cycles for delivering a product, developers tend to focus more on the functional aspects of application execution, mostly via testing, debugging, and code fixing. However, many problems do not easily surface until the application is running in production mode, 24 hours a day, 7 days a week and gets pushed to limits during some unexpected peak periods.

The kinds of performance problems encountered in production cannot be discovered during a debugging session. Before deployed and run in production mode, it is important to use a Profiling tool to analyze application execution and identify performance problems, such as execution bottlenecks, object leaks, and system resource limitations.
This article provides an introduction to the TPTP Profiling tool. It demonstrates how to use the TPTP Profiling tool to profile a Java application in order to identify performance hot spots, and fix and validate performance problems.

TPTP Profiling Tool
The Eclipse Test & Performance Tools Platform (TPTP) Project offers a profiling tool for identifying and isolating performance problems such as performance bottlenecks, object leaks and system resource limits. The tool targets applications of all levels of complexity, from simple standalone Java applications to Eclipse plug-ins or complex enterprise applications running on multiple machines and on different platforms.
This article was written using the TPTP 4.2.0 which require Eclipse 3.2.0.

TPTP Selected as the best free Performance tool for 2006

-----------------------------------
TPTP API Recorder and Test Generation Tutorial

asr: using these tools below auction firm can save hundreds of developer hours by saving exceeptions to a common base ( LDAP /DB ) from the log files.

Stand-alone Generic Log Adapter v4.3 User's Guide
Overview of the Generic Log Adapter
The Generic Log Adapter allows you to process application log files and transform their contents into the Common Base Event format
. The Common Base Event specification prescribes a common format for logging, management, problem determination, and autonomic computing. It provides a consistent format that facilitates intercommunication between tools that support these goals. Common Base Event objects allow you to develop a common prescriptive event in a consistent format so that tools can be developed to support these goals.

In order to take advantage of tools such as the Log and Trace Analyzer that support Common Base Event objects, your application log files need to conform to the Common Base Event format. To produce application log records that conform, you can do one of the following:

- Change the application that generates the log file to create Common Base Event records directly.
- Write a transform that converts application log files to Common Base Event records.
The first approach is impractical unless the application is currently being developed. This approach does not solve the problem of integrating existing application logs with the Common Base Event format.

The second approach is more practical. However, it leaves you with the tedious task of writing the transform. Typically, this is accomplished by either writing some custom code in either a third-generation programming language or a script that can be used by established scripting tools such as Perl. Once the transform is created, you must test the transform and integrate the transform solution into the tools that use Common Base Event objects.

Friday, March 28, 2008

Java bycode debuggers

AOP@Work: AOP myths and realities - Beyond hype and misunderstandings - 14 Feb 2006

asr: If we just need to log all method execution trace of business flow along with parmeter values passed for each method , it can be done with Spring frame work with simple xml declarions, pls. check , If this is the only purpose do not need the complex ASM etc..

http://asm.objectweb.org/ - ASM java byte code debugger used by autciton gaint.

ASM package seems specially designed to create method flow of Java server code. It helps programmer to quickly find bug in a complex flow of software.
Next setp is to create method flow diff of 2 different software relaease running on 2 different servers .

- using spring AOP : It is worth to try to create dynamic proxy's for all methods of all classes with loggigng of method entry with all parameter data printed so that a prorgrammer can see what is wrong in a flow. mostly you get different set of data causing null pointer exceptions

Thursday, March 27, 2008

Crude oil Strips

-------------------------------------------
http://www.europac.net/ - Because there is a Bull Market some where
- Author : Crash Proof

http://bigpicture.typepad.com/comments/2006/10/dow_gold.html
-----------------------------------------
The complete investor TCI - news letter
- Author Setphen Leeb is PhD : author of 'The coming Economic Collapse', 'the oil factor' ( written 2004 ) , defying markets ( written 1999 , prediction of dot-com tech bust )
- advises sell and be in cash when oil increse by 80% from previous year , be in stock market when oil falls -20% from previous year

good site for oil future contracts
-----------------------------------------------

Crude oil contracts for spot (immediate) delivery, and up to six months out, respond much faster to Chaostan shocks than more distant contracts. For example, during the Kuwait War when spot oil peaked around $40, contracts for delivery a year or more away remained around $21. This is because refiners and end users bid up nearer-term contracts to secure scarce supplies for current needs, while staying hopeful that lower prices would return later on.

The added volatility in closer contracts causes options on these contracts to profit faster than those on the slower moving, distant contracts. But the distant options have more staying power. Strips fill both needs.


To construct a strip, you buy a series of call options on crude oil future contracts every six months in the future. Right now [at the publishing of this report] you can buy the following $35 per barrel strike price option strip for less than $2000: December 2001, June 2002, and December 2002
.

The options allow you to participate in the changing value of the underlying futures contract for 1,000 barrels of West Texas Intermediate crude oil. The right is good until the expiration of the December 2002 option in mid-december 2002, so the strategy has plenty of time to work.


Dynamic Price Play. Usually instant profits from higher prices, without the frustrating lag times of weeks or months typical of oil stocks.
Flexibility. The luxury of taking partial profits on the way up (something I recommend for all speculations) without abandoning your longer-term bullish position.
Fixed-Risk Leverage. A highly leveraged position in a potentially explosive bull market with a limited risk of less than $2,000 -- and one you can buy and sell with the same ease of any exchange-listed stock or other option contract.


A return to Kuwait War highs at $40 per barrel would make each strip worth $5,000. A run-up in today's inflation-adjusted dollars, based on the prior Iranian Revolution high, would come to roughly $85 per barrel, making the recommended strip worth at least $50,000 at option expiration.

Compare this to a big-company oil stock like Exxon Mobil (XOM). From December 1998 to October 2000, crude oil rose roughly 236%, while XOM gained $20 per share, or 36%. This was not bad, but it was not even close to the gain in crude oil, or the even bigger gain in EWR strips, as of late 2000.

At today's prices you can buy four crude oil strips (12 options total) for the price of 100 shares of XOM ($80/share). Should crude spike to $85 per barrel, these four strips, costing you around $8,000, would be worth at least $200,000, and possibly much more if the move occurs within the next six to twelve months.

Yet, there is a tradeoff. Should crude fail to rise between now and December 2002, strip holders would take partial losses or the options would expire worthless. XOM holders would still own the stock.

What about Natural Gas and Unleaded Gasoline options? Periodically a good speculation (I may recommend them later), they currently do not come close to the spectacular potential found in crude oil strips.

We never know for certain what the future holds, but we do know that when a new Chaostan crisis explodes, crude oil options could double or triple in value in just hours or days. So if you like to speculate -- don't delay taking action.


You cannot trade crude oil options through your stockbroker because they are listed on the New York Mercantile Exchange. Therefore, you need a licensed commodity broker to buy them.

My recommended broker is Sue Rutsen at Fox, Inc. Sue and her team have been serving EWR subscriber option trading needs since 1995. They know the strip strategy inside and out. Call Sue at (800) 345-7026 or (312) 341-7494, and refer to this Special Report at chaostan.com.

If you are new to options and are a current subscriber to Early Warning Report, tell Sue and she'll send you the IPS Short Course In Futures and Options, a $14.95 bookstore value, absolutely free.

Tuesday, March 25, 2008

U.S. home prices continued to plunge in January

U.S. home prices continued to plunge in January
By Michael M. Grynbaum -- Published: March 25, 2008


NEW YORK: Home prices across the United States continued to plunge at record rates in January, a private survey released Tuesday showed, and economists said the slump was probably worse than at the height of the last housing recession in the early 1990s.

The fresh evidence of deterioration in the U.S. housing market came as a measure of consumer confidence reached a five-year low, buffeted by gyrations in financial markets and fears the United States may be sliding into a recession.

The value of single-family homes plummeted 10.7 percent in January compared with a year earlier, as measured by the Standard & Poor's/Case-Shiller index, a leading gauge of 20 major metropolitan regions.

The decline was the steepest year-over-year since the index began eight years ago, and reflected a wide-spread deceleration in values.

"No matter how you look at these data, it is obvious that the current state of the single-family housing market remains grim," Robert Shiller, chief economist at MacroMarkets and co-developer of the index, said in a statement.


Another housing index published Tuesday by the U.S. Office of Federal Housing Enterprise Oversight, showed home prices continuing to fall, but less sharply across the United States. The decline nationwide was about 1.1 percent from December to January, and 3 percent from a year earlier.

"The weakness is not contained to the bubble areas," Michelle Meyer, an economist at investment bank Lehman Brothers in New York, told Reuters. "It has spread to the rest of the nation."

As housing prices tumble, some economists see a silver lining: The decline may help to lure buyers back into the beleaguered market, where sellers are struggling under a wave of foreclosures and a tight credit market that has made it more difficult for many Americans to take out mortgages.

Inventories have ballooned as purchases have dried up, as buyers hold out for prices to fall even further.

Yet the slide in home values has been compounded by a general sense of gloom about the economy.

Confidence among consumers unexpectedly fell this month, dragged lower both by eroding asset values and concern that business and employment conditions will worsen before they improve. A quarter of those surveyed in an index created by the Conference Board, a private research group, said they believed businesses conditions would worsen in the next six months, and nearly a third said the economy would have fewer jobs.

The index slumped more sharply than expected, to 64.5 from 76.4 in February. A value of 100 represents the level of confidence in 1985.

The positive sales figure led some analysts to suggest that the housing market is approaching its bottom. But many economists predict that prices will fall for several more months before sales pick up in earnest.

"It's a necessary thing," said Joshua Shapiro, the chief U.S. economist at MFR, a New York economic research firm. "It's like the mess going down in financial markets. You gotta get through it. The sooner you get through it you can look for better times."

All 20 regions included in the Case-Shiller survey Tuesday recorded price declines, with Sun Belt cities like Las Vegas; Phoenix, Arizona; and Los Angeles suffering the worst losses in January. Prices in Miami and Las Vegas have fallen nearly 20 percent in the 12 months ending in January.

In the New York metropolitan area, home values fell just 0.9 percent in January, and 5.8 percent compared with a year earlier. But the drop-off appeared to be gaining speed: values were down nearly 10 percent on a three-month annualized basis.

Sunday, March 23, 2008

Software Development system for high productivity

Prsentation code:
- Aptana : use this nextGen for all Ajax developemnt and debugging
- for css: ready to use code fom 'css design patterns' book
- you have MyEclipse for JSP , JSF development

Server code:
- Spring framework with Webflow , Jdbctempales, aspects for (logging and debug mode code to log 'method level flow traverse code' )
- use Spring in action book code samples , and good articles on javaworld.com javalobby.com , serverside.com
- you have pulse for automatic Eclipse download and config of plug-ins.
- you have MyEclipse with all these plug-ins no hassle install and run , you have pulse for profile and use it at home/office .

Testing :
- testNG see TestNG crator book , TDD approach , use watij ( web application testing in Java ) to comibine with TestNG to create all functinoal test cases. Automate it to run for each bugfix/change

Thursday, March 20, 2008

software testing issues and solutions

-----------
WatiJ vs. HttpUnit vs. Selenium
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=68&t=001476
- post said use HtmlUnit instead of HttpInput as first is latest project
-----------------------------------------
High level software testing automation components
1. Test data beds
2. capture html pages at server end point before returning to browser
3. capture what user entered ( data or clicks )
4. save .htm files in step 2 and step 3 to server so that 'tester/bug fix developer' can see 'total flow ' as set of html screens saved on a server. just click on links like pag1 , page2 it shows each page in the flow . It should be that simple .
5. server logging of all method flow along with ( values passed ) is also saved .
6. all web pages will have hidden field like <input type="hidden" name="flowStatus" value ="fromflow:REIInput;toflow=ERR_REQIRED_FIRSTNAME;desination=RegSuccess">. WatiJ java code will process this hidden filed after every web GET/POST and compare with expecgted codes and mark the test case as either faiure or success. In WatiJ we write this code
read whole data input into java object
document.firstName = inputObj.getFristName(); // then assingn to watiJ values ..
document.lastName = inputObj.getLastName() ;
document.firstName = hash1.get("firstName"); // use hash instead of above class no burden of creating class .. read data into hashmap
String input_error = read error conditon from the data inptut file . // ERR_REQIRED_FIRSTNAME
flowstat = new FlowStatus(flowstatStr); // read from hidden filed
// FlowStatus class will parse differnet part of the flowStatus string
if ( flowstat.errorEquals(input_error) { test case success}
else { test case failure }


1. Test data beds: this can be in simple form of text file ( may be like FIT , FITNESS test data study )
- each field level exhastive tests are performed with auto generated 'field domain' xml defintions given in the post just below this post .
- the following is simple functional test. The actual strings 'firstName' 'phoneNum' are taken from field definitions file , these should match exact names to what HTTP POST/GET expects . WatiJ scirpt will use this file/names to auto enter the these test values in browser test
errorType | firstName | LastName | phoneNum | Address1 | Address2
ERR_REQIRED_FIRSTNAME |
ERR_REQUIRED_lastName | joe |
ERR_REQUIRED_phoneNum | Joe | hopper
ERR_REQUIRED_address1 | joe | hopper | 4083349890

you see above , the error condition ( that returns in web pages ) is coded in the test case itself .
---------------------------------------------------
When you ask a software engineer 'on Avarge how long does it take to fix a production bug in your software application ?' .
you get many answers, it depends on bug complexity , experience of programmer etc.. Here is the key , even though many of above are true we should have a avarge number . For most of the buisness applications my guess is it is like 1/2 to 1 day depnding on how complex/ easy is the aplication.
Developers spend most of the time in pinponting what exactly caused the bug, often is is hard to re-produce ( bug logged by QA engineer with some screen shots ).
Here is a set of Next genration development tools and practices to cut down software deveopoment time (same goes for bug fixing) by 50% over the current practices .

post 2: how to pinpoint what code change caused this bug
1. The idea is to log each method a use case is traversed in the code and log all those methods.
2. when you see a bug compare the 'code travese' between current version and bug-free base version (prior version).

how to log 'code traverse' methods: on a browser front end provide a key combinagton like CTRL+ALT+L a java script popus a text box enter 'tracking key' like 'UserRegigartionConfirm' a hidden filed is populated with this value and is added to each form submit on the page.
On the server 'key' value is captured and used by aspects to log 'entey' of each method. Use Aspects of Spring to log each method name entry .
3.You repetat same for the bug-free version on a different pool
4. At the end a toll do the Differene of these 2 runs and log only methods that have a difference in code.
5. Using a UI tool go over each method and see what is the diff of the methods , you can easily figure out which method caused this change.

Free File Comparison Utilities - Win Merge
-------------------------------------------
Post 1:
1. All cases business use cases are not captured in one place along with all error codes/conditions
2. incremental data progression is required

let us take REI page with fileds first name, last name , city, state, zip, phoneNumber

we define domains similar to domain names in Database desgin tools ( ERWin ..)


define domains:

nameThing
10
30
[a-z][A-Z][0-9]_-



phone
7
10
[0-9]


now we define fields with requied overridding default values of domain.

nameThing



nameThing


now the test suite will genereate test cases for these automatically like this below. Notice all cases below by default they are negaive test


*(
$(
1$(
$1(
$1a(
a$*(
a
ab
ab345678 // only 8
ab34567890ab34567890ab3456789011 // more than 30
ab3456789 // just 9 , success case for this field , there should NOT be ERRFirstName in output
getTestSuite.get("FirstName") // to read from a DB or flat flie of valid values


Functional testing: for Business applications
- as TestNG creator pointed out in his blog below functional testing is must. so for REI page he is functional test cases

REI-highrisk-user
by annonymous email
Supply Date here ..



REI-highrisk-user
by userid with _5620
Supply Date here ..



REI-lowrisk-user
by non-annonymous email
Supply Date here ..



REI-lowrisk-user
by userid normal
Supply Date here ..

software testing frameworks tools

http://www.openqa.org/ - this site has many frameworks mentinoned . Selenium , Watir is main

This Wiki link has all testing frame works in the world
http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#Java
Cactus show no new development after 2007 , JunitEE is next seems

-----------------
TestNG documentation

TestNG 5.6 and Junit 4.4 : which framework you will choose for unit testing? -- Published February 29, 2008 Java
http://lijinjoseji.wordpress.com/2008/02/29/testng-56-and-junit-44-which-framework-you-will-choose-for-unit-testing/
- asr note: this blog author LiJin is in India ( see about Linkedin profile , he can be good consultant in India for Spring , TestNG related issues )

Next Generation Java Testing: TestNG and Advanced Concepts - amazon book reviews - TestNG creator ( and author of this book )is Google engineer
- on his blog he says this: Keep in mind that functional tests are the only tests that really matter to your users. Unit tests are just a convenience for you, the developer. A luxury. If you have time to write unit tests, great: they will save you time down the road when you need to track bugs. But if you don't, make sure that your functional tests cover what your users expect from your product.
- asr note: this supports my point focus more on functional test covering every case and have data to support it. In case of REI page after REI submit you can have WatiJ get emailaddress from web page and query DB to get 'confirmation code' and feed it to go to next page .

They even go into Spring's test mechanisms, and do a good job with it.
------------------------------

Watij - Web Application Testing in Java
Watij (pronounced wattage) stands for Web Application Testing in Java. Watij is a pure Java API created to allow for the automation of web applications. Based on the simplicity of Watir and enhanced by the power of Java, Watij automates functional testing of web applications through a real browser. Currently Watij supports automating Internet Explorer on Windows only. Future plans are in place to support others like Mozilla .

Watij is a Java API that provides control and automation of Internet Explorer in order to test web applications. It was created out of the need to have a reliable, easy to use, and robust web application testing tool using Java as the scripting language. But why Java?

With Java at your fingertips you have access to a tremendous amount of existing libraries and tools. This means in your test scripts you are not restricted to testing only web applications. For example with Java you can write a test that calls a web service to do some processing and in the same test bring up your web application using Watij and validate that everything is correct. And if your web application is developed in Java, Watij integrates nicely into your already existing environment.

With Watij you can imitate real user interaction with your web application. Simple user actions like navigating, clicking links, filling out forms, and validating content are a breeze with Watij. Watij also makes it easy to handle more complex actions like file downloading and uploading, popup windows and dialogs, and screen captures.

Finding HTML elements on a page can be a cumbersome task using the traditional DOM. To make this easier Watij includes a powerful element finding capability that allows your scripts to find, access, and control any HTML element on the page. It even supports XPath expressions that are lightning fast.

Watij is a standalone Java API that purposely doesn’t force you into using a proprietary testing framework or IDE. Two of the most popular Java testing frameworks are JUnit and TestNG, and Watij integrates seamlessly with either one. Watij is just like any other Java library, so it’s very is easy to import into your favorite Java IDE like Eclipse or IntelliJ. And even though its main use is in testing web applications, because it is a standalone Java API Watij is not limited to the testing paradigm.

See Watij new relesae with Eclipse support
_______________________________________________________________

Selenium used at auction gaint

Selenium is a test tool for web applications. Selenium tests run directly in a browser, just as real users do. And they run in Internet Explorer, Mozilla and Firefox on Windows, Linux, and Macintosh. No other test tool covers such a wide array of platforms.
http://technology.amis.nl/blog/?p=1077
http://www.openqa.org/selenium-ide/
http://www.openqa.org/selenium-ide/

Wednesday, March 19, 2008

Demonstrating Spring's Finesse

Spring IDE
using Spring IDE

______________
asr notes: what are the real real advantages spring as development platform ( my own view )
1. JDBCTemplates -- great to get sql result in one line
2. aspects for 'log messages' and security checks
3. INput FORM data validation declaratively , ability to define masks like for phone numbers etc.
4. ability to use caching ( JCS, hybernate ) built in interfaces provided
5. Good webflow module works with JSF , struts etc..
_______________________________

discard all below old stuff

Note: this is written in 2005 very old spring , probably get new Spring 2.0 application code
JpetStore -- app this author talks about
- download from here
- app demo

Author's note: In this excerpt from Chapter 8 of our book, Better, Faster, Lighter Java, we look at an example of an enterprise web application using the Spring framework. While Hibernate provided a single service, the Spring framework provides an efficient way to build and assemble Java applications, with abstractions for many services. Although it supports many services, Spring stays focused and clean with excellent layering and encapsulation. Like EJB, the centerpiece for Spring is a container, and like EJB, the Spring framework provides access to core J2EE services. But that's about as far as any similarities go. ( no more similarities with EJB ).

Pet Store: A Counter-Example
The J2EE Pet Store application is an infamous programming example gone bad. It taught thousands of J2EE developers to build poorly designed, poor-performing code. It was also the center of a benchmarking controversy

Data sources

A Java class that manages connections, usually in a pool.
DAO layers

If your applications use a database, you probably want to isolate the database access to one layer, the DAO. You can access this layer through the application context.
Persistence managers

Every persistence framework has an object or factory that the application uses to access its features. With Hibernate, it's the session and the session factory. With JDO, it's the persistence manager factory and persistence manager.
Transaction policies

You can explicitly declare the methods that you want to participate in transactions and the transaction manager that you want to use to enforce that strategy.
Transaction managers

There are many different transaction management strategies within J2EE. For single database applications, Spring lets you use the database's transaction management. For multiple databases or transaction sources, Spring allows JTA instead. You can keep the transaction manager in the application context.
Validation logic

The Spring framework uses a validation framework similar to Struts. Spring lets you configure validation logic like any other business component.
Views and controllers

The Spring framework lets you specify the controllers for a view and helps you configure the navigation path through them.

The jPetStore application uses the Spring application context for a data source, the DAO layer, and a transaction strategy. You define what goes into a context within an XML document that lists a series of beans

Asia Investment in Wall Street firms

Citic was to buy $1 billion worth of 40-year preferred securities convertible into about 6% of Bear Stearns equity. The conversion price of Citic's investment into Bear Stearns was around $120, based on the last five days traded prices at the time. Bear Stearns had traded down from a January 2007 high of $171 leading some market commentators to observe that Citic had got itself a bargain. The arrangement was somewhat reciprocal as Bear Stearns would eventually invest $1 billion in Citic's equity, based on Citic's traded share price.

Bear Stearns' share price lost ground all of last week as investors � correctly � feared the worst and closed at $30 on Friday. Then JPMorgan bailed out the beleaguered investment bank over the weekend at a price of $236 million, which translates to a valuation of around $2 per share. Bear Stearns' shares lost 84% on the news, finishing at $4.81 on Monday but gained some ground on Tuesday to trade up to $7 before closing around $6.

Citic said yesterday it will not be going ahead with the investment, which was still awaiting approvals. But while this ended up being just a close call for Citic, other investors who bailed out subprime-affected banks have not fared as well.

Just a few weeks after the Citic-Bear Stearns tie-up, Citi said the Abu Dhabi Investment Authority would invest $7.5 billion to buy up to 4.9% of the bank. Citi issued equity units to ADIA that are convertible into common shares at a price between $31.83 and $37.24 per share. Until conversion in tranches in 2010 and 2011, the securities carry a coupon of 11%, payable quarterly. Citi's shares closed at $30.70 the day the markets learned of the ADIA investment.

Then UBS announced that the Government of Singapore Investment Corporation (GIC) and an undisclosed strategic investor in the Middle East would jointly invest SFr13 billion ($13.2 billion) to take a 10.5% stake in the Swiss bank
. The investors bought notes convertible in two years, bearing a coupon of 9%. The shares traded at SFr57.2 on December 7. The conversion price is an average of the December 7 price and the volume-weighted average price of the three trading days prior to the extraordinary general meeting at which the issuer would seek approval, subject to a floor of SFr51.48 and a ceiling of SFr62.92.

UBS currently trades at SFr26.02.

On December 19 China once again stepped up to the plate with China Investment Corporation agreeing to a $5 billion infusion to acquire a stake of up to 9.9% in Morgan Stanley. The US investment bank issued equity units, bearing a coupon of 9% per annum payable quarterly, convertible into Morgan Stanley shares in August 2010. The conversion price was based on traded prices the week of December 17, with a floor set at a premium of 20% to the reference price. The reference price was $48.07-$57.68 per share.

Morgan Stanley traded yesterday around $41.

Merrill Lynch's gift to shareholders came on Christmas Eve when it announced Temasek and Davis Selected Advisors would subscribe to $6.2 billion of stock at a price of $48 per share. Merrill Lynch traded at $56 the morning of the announcement, so Temasek and Davis seemed to have got a good deal buying at a 14% discount to the traded price (though the investors bought straight equity so got no fixed coupon).


January brought both Citi and Merrill Lynch back on the road for another round of capital infusion.


Citi announced it would issue $12.5 billion of convertible securities to a consortium led by Singapore's GIC. The securities have a coupon of 7% per annum, payable quarterly, and convert at $31.62. Citi traded down to $26.90 the same day.

Merrill issued another $6.6 billion of convertible preferred stock that carry a 9% dividend and are convertible in 33 months based on the then traded price, with a floor of $52.40 and a ceiling of $61.31. Korean Investment Corporation, Kuwait Investment Authority, Mizuho Corporate Bank and others bought the stock. Merrill traded around $54.29 that day.

ADIA benefited from the further capital dilution Citi subsequently announced and the conversion price for the securities it holds is now set at $31.83.

Citi currently trades at around $20, while Merrill Lynch was quoted at $44 yesterday.

Specialists say all these investments have been made by the Asian and Middle Eastern investors with a medium- to long-term perspective and share price movements just three to six months later are not the correct way to view them. Indeed, better than expected first quarter results from Goldman Sachs and Lehman Brothers yesterday coupled with expectations of an interest rate cut in the US caused sentiment on financials to rebound and most bank shares gained, albeit marginally, corroborating how nervousness is driving trading rather than fundamentals.

Further, the investors are in many cases the largest single shareholder in the banks post-investment � a position they would not easily have been able to achieve through open market purchases. Another point specialists make is there is no way of knowing when markets have bottomed, thus buying at bargain basement prices is nigh impossible.

And a bad deal for one side is a good deal for the other. Bear Stearns has been hammered on the stockmarket but JPMorgan is widely perceived as having got a good deal and its share price gained 10% on Monday after the deal was announced to close at $40.31 and continued to gain on Tuesday to trade around $42.50 midday.

After Citic and Bear Stearns announced their cross-shareholding deal, it seemed that every other bail-out investor managed to secure a better deal than the Chinese saviour, with fixed coupons and in some cases discounts to prevailing share prices. But Citic is now no doubt having the last laugh as its $1 billion is still intact.

And even if all the points that specialists make with respect to the investments already committed are correct, the questions that remain to be answered are: which financial institution will be next to go belly up? And when it does, will investors from Asia and the Middle East be prepared to dole out cash again given how their first round of investments are trading?

TDD - Test Driven Development

Test Driven: TDD and Acceptance TDD for Java Developers
- new book written in Nov 2007 , many other books are old

Maven 2 - build and project collaboration tool

"Spring in Action" - Author mentioned in book ( using it )

Introduction to Apache Maven 2 - Tutorial

Modern software projects are no longer solely monolithic creations of single local project teams. With the increased availability of robust, enterprise-grade open source components, today's software projects require dynamic collaboration among project teams and often depend on a mix of globally created and maintained components. Now in its second generation, the Apache Maven build system -- unlike legacy build tools created before the Internet-enabled era of global software development -- was designed from the ground up to take on these modern challenges. This tutorial gets you started with Maven 2.


Learning Maven 2 need not be difficult, once you understand its motivation and the challenges that it aims to overcome. As a build tool, Maven 2 is usable productively even by rank beginners developing projects in an isolated silo. Start using Maven 2 in your own development project or join one of the many open source development communities, and soon you too will be influencing the course toward which Maven 2 will evolve.

Working with the Maven 2 Plug-in for Eclipse 3.2 -- Nice UI tool

Tuesday, March 18, 2008

AOP / Dependency Injection (DI).

http://static.springframework.org/spring/docs/2.0.x/reference/aop.html
Implement crosscutting concerns using Spring 2.0 AOP Spring 2.0 offers excellent user-friendly AOP capabilities
By Ganesh Ghag, JavaWorld.com, 01/05/07

Most developers will acknowledge how implementing crosscutting concerns such as logging, auditing, security and transactionality can adversely affect business logic implementation. Such concerns "seem" to increase the complexity of existing business logic, at times making it difficult if not impossible to clearly distinguish business logic from the crosscutting concern implementation.

I had been hearing about aspect-oriented programming (AOP) being a solution for implementing crosscutting concerns. But having read through early AOP tools documentation, I was dissuaded from using AOP in my projects' recommendations, primarily because of a concern that average developers might not "get" AOP concepts, and the overall ability to debug applications, and maintain them, might be restricted to those few who understood AOP.

Recently released Spring 2.0 provides excellent, easy-to-use AOP capabilities. Spring AOP is now remarkably easy to use for the average Java developer with traditional object-oriented programming skills. This story shows how Spring 2.0 AOP can be effectively used to implement crosscutting concerns in a typical software project. We will consider the following crosscutting concerns for implementation:

Security
Logging
Transactionality

Let us start with an example code snippet:

Before we begin, let's review a few basic definitions used in aspect-oriented programming and their implementation in Spring AOP.

AOP basics
Aspect: A modularized implementation of a software concern that cuts across various objects in a software implementation. Logging is a good example of an aspect. In Spring AOP, aspects are nothing more than regular Spring beans, which themselves are plain-old Java objects (POJO) registered suitably with the Spring Inversion of Control container. The core advantage in using Spring AOP is its ability to realize the aspect as a plain Java class.
Join point: A point during program execution, such as a method executing or an exception being handled. In Spring AOP, a join point exclusively pertains to method execution only, which could be viewed as a limitation of Spring AOP. However, in reality, it is enough to handle most common cases of implementing crosscutting concerns.
Advice: Information about "when" an aspect is to be executed with respect to the join point. Examples of types of advice are "around," "before," and "after." They specify when the aspect's code will execute with respect to a particular join point.
Pointcut: A declarative condition that identifies the join points for consideration during an execution run. Pointcut is specified as an expression. Spring AOP uses the AspectJ pointcut expression syntax. An example pointcut expression is: execution(* com.myorg.springaop.examples.MyService*.*(..)). Asterisks in the expression refer to wildcards, as is conventional.

The above AOP code can be easily compiled with the Java 5.0 compiler. There is no need for a separate AOP compiler. Spring uses Java 5.0 dynamic proxies to implement Spring AOP. Needless to say, the weaving of Spring AOP aspects into the application code occurs at runtime, because of the use of dynamic proxies.


Logging as an AspectLogging has a lot of characteristics that make it a prime candidate for implementation as an aspect. The following are two of the notable characteristics:
Logging code is often duplicated across an application, leading to a lot of redundant code across multiple components in the application. Even if the logging logic is abstracted to a separate module so that different components have a single method call, that single method call is duplicated in multiple places. - asr: It seems you do not have to call logging in Spring AOP one declaration of what all classes need logging seems takes care

Logging logic does not provide any business functionality; it's not related to the domain of a business application.

________________________________________________________________________________
Learn AspectJ to better understand aspect-oriented programming -- 03/01/02
AspectJ language overview
To support AOP, AspectJ adds to the Java language concepts:


Joinpoints: Points in a program's execution. For example, joinpoints could define calls to specific methods in a class
Pointcuts: Program constructs to designate joinpoints and collect specific context at those points
Advices: Code that runs upon meeting certain conditions. For example, an advice could log a message before executing a joinpoint

Aspect Hello world
Add Japanese manners to HelloWorld
Now that you've seen the around() advice and collecting context, let's use it to add manners, Japanese style, by adding a "-san" suffix to each person's name to show respect. We simply add another aspect: JapaneseMannersAspect. This aspect advises the call to HelloWorld.sayToPerson(String, String) and proceeds with a modified person argument by adding "-san":

// JapaneseMannersAspect.java
public aspect JapaneseMannersAspect {
pointcut callSayMessageToPerson(String person)
: call(* HelloWorld.sayToPerson(String, String))
&& args(*, person);
void around(String person)
: callSayMessageToPerson(person) {
proceed(person + "-san");
}
}



__________________________________________________________________________________
A Beginer guide to Dependency Injection (DI). - dated July 2005


Scope
This article presents a high level overview of Dependency Injection (DI). It aims to present the overall concept of Dependency Injection to the junior developer within the context of how it could be used in a variety of DI containers.


Dependency Injection (DI) or Inversion of Control (IOC) ? A lot of current literature often refers to the same design pattern as either Dependency Injection or Inversion of Control. I prefer Dependency Injection from my belief that it is a more specific name. I can imagine many scenarios where one would find evidence of Inversion of Control, though the resultant pattern is unlikely to be focusing on resolving dependencies (e.g. moving from a console application to a Windows Event Loop) . However should you prefer IOC, you can pretty much read the remainder of the article by replacing DI with IOC. Within IOC there are various types (creatively called as type 1, type 2, type 3). The differences within these types are not particularly relevant to the scope of this article and thus not entered into.

Dependency Injection in a Software Context
Software components (Clients), are often a part of a set of collaborating components which depend upon other components (Services) to successfully complete their intended purpose. In many scenarios, they need to know “which” components to communicate with, “where” to locate them, and “how” to communicate with them. When the way such services can be accessed is changed, such changes can potentially require the source of lot of clients to be changed.

Monday, March 17, 2008

How the Bear Stearns deal got done

Without the Fed's $30 billion, JPMorgan Chase couldn't have bought Bear Stearns without writing down its own mortgage holdings.
By Roddy Boyd, writer


NEW YORK (Fortune) -- The Fed's agreement to buy up to $30 billion in troubled Bear Stearns mortgage bonds may have saved JPMorgan Chase from a big writedown, according to senior executives involved in the transaction.

JPMorgan (JPM, Fortune 500) executives initially decided to pass on a purchase of Bear Stearns this past weekend, Bear execs said, largely because of the risks tied to Bear's mortgage portfolios. They changed their minds after the Fed agreed to pony up $30 billion in so-called nonrecourse loans - agreements that transfer the risk of Bear's bad mortgage bets to U.S. taxpayers. The Fed's decision paved the way for the Sunday evening deal that put Bear in JPMorgan's hands for $2 a share, a 93% discount to Friday's closing price.

But the value of Bear's balance sheet wasn't the only worry at JPMorgan. Bear execs say JPMorgan was also worried that without help from the Fed, buying mortgages from Bear (BSC, Fortune 500) could force JPMorgan to write down the value of its own mortgage holdings.

That fear stemmed in part from the sharp decline in the value of mortgage debt this year, along with the different calendars the firms report on. At the end of February, Bear had $16 billion in commercial mortgage-backed securities, $15 billion in prime and Alt-A mortgage bonds and $2 billion in various subprime bonds, JPMorgan said. The value of those securities has been in sharp decline, along with U.S. house prices. Indeed, values in the mortgage securities market have plunged just over the past month, as investors in lenders such as Thornburg Mortgage (TMA) - which is dealing with unmet margin calls triggered by plunging prices - will surely tell you.

Bear Stearns collapse

10 biggest Losers
JPMorgan Surges After Capturing Bear Stearns for $240 Million

March 17 , 2008(Bloomberg) -- JPMorgan Chase & Co. surged in New York trading after striking a deal backed by the Federal Reserve to buy Bear Stearns Cos. for $2 a share, 90 percent less than the 85-year old firm's market value last week.

Citic Scraps Deal

Cayne ranked as Wall Street's richest CEO, with $1.3 billion of assets, according to Forbes magazine's 2007 billionaire survey. His stake in the firm approached $1 billion last year when the shares reached their peak price of $170. Under terms of the JPMorgan takeover, his holdings are now worth about $12 million.

Joseph Lewis, Bear Stearns's second-largest shareholder, has spent more than $1 billion on the firm's stock since September, paying as much as $150 a share. Lewis, a 71-year-old billionaire, wasn't planning to reduce his stake, a person close to him said March 11. He's now entitled to $22 million of JPMorgan shares.

Beijing-based Citic Securities Co. canceled a proposed $1 billion investment in Bear Stearns, said Kong Dan, chairman of Citic Group, the company's parent, in an interview today. Citic had agreed in October to buy a stake in Bear Stearns when the company's stock was trading at more than $117.

45-Story Building

``To see a situation involving a bailout lead to shareholders getting pretty much wiped out is a pretty significant event for the market,'' said Ben Wallace, who helps manage $800 million, including stock in JPMorgan, for Grimes & Co. in Westborough, Massachusetts. ``It's going to raise concerns'' about the value of financial stocks, he said.

The Fed's attempt to rescue Bear Stearns last week with a cash infusion failed to avert a crisis of confidence among the company's customers and shareholders, who drove the stock down a record 47 percent on March 14, when the emergency funding was announced.

Bear Stearns's profit exceeded $2 billion in 2006, yet the price JPMorgan is paying is about one quarter the value of the securities firm's headquarters building in midtown Manhattan. The 1.2 million-square-foot, 45-story structure built in 2001 is worth about $1.2 billion, based on the average $1,000 per- square-foot that comparable office space in the city is currently fetching.

Counterparty Risk

JPMorgan Chief Financial Officer Mike Cavanagh said on a conference call after the sale was announced that the bank was comfortable with the values Bear Stearns had assigned to the mortgage-related assets on its books. Asked to explain why JPMorgan was paying about $2 a share for a company with a book value -- assets minus liabilities -- of $84 a share, Cavanagh said the price reflected the risk the firm was taking.

It ``gives us the flexibility and margin of error that's appropriate given the speed at which the transaction came together,'' he said. JPMorgan said it was confident Bear Stearns shareholders would approve the sale.

``If you're buying equity for free and the liabilities are pretty well capped, it sounds like it's good for JPMorgan shareholders,'' Wallace said. ``The thing that everybody's been worried about has been the counterparty risk, and if this gives people more confidence, that will be good for the markets.''

`A Lot of Value'

Minutes after the deal was announced, the Fed cut the so- called discount rate by a quarter of a percentage point to 3.25 percent. The Fed also will lend to the 20 firms that buy Treasury securities directly from it.

Bear Stearns's prime brokerage unit, which provides loans and processes trades for hedge funds, generated $1.2 billion in revenue last year. That business is probably the only piece left of the company with value after the mortgage market collapsed last year, analysts said.

The prime brokerage was the third-largest behind Goldman Sachs Group Inc. and Morgan Stanley as of April 2007, according to Sanford C. Bernstein & Co. About a sixth of the firm's income came from packaging and trading mortgage bonds, a market that has been almost completely frozen since July during the biggest housing slump in a quarter century.

``As bad as things are at Bear Stearns, this is still a franchise with a lot of value, particularly the prime brokerage business, which is what JPMorgan is after,'' said William Fitzpatrick, who helps oversee $1.6 billion at Racine, Wisconsin-based Optique Capital Management, including JPMorgan shares. ``That's the crown jewel, and that would fit into JPMorgan's business extremely well.''

Saturday, March 15, 2008

Spring Web Flow for better workflow management in JSF

Spring Web Flow for better workflow management in JSF
An alternative to the JavaServer Faces CustomNavigationHandler

By Ravi Shankar Nair, JavaWorld.com, 01/10/08

JavaServer Faces is a powerful framework for component-based Web UI development, but its CustomNavigationHandler introduces more complexity into rules-based navigation than you need. In this article, Ravi Shankar Nair shows you how to integrate a little flow -- Spring Web Flow, that is -- into an existing JSF application, bringing truly customizable and reusable navigation to your evolving JSF applications.

-- show also good flow model of JSF


------
Spring webflow - 2005 aritcle
http://www.theserverside.com/tt/articles/article.tss?l=SpringWebFlow

Hybernate

Hibernate is a powerful, high performance object/relational persistence and query service. Hibernate lets you develop persistent classes following object-oriented idiom - including association, inheritance, polymorphism, composition, and collections. Hibernate allows you to express queries in its own portable SQL extension (HQL), as well as in native SQL, or with an object-oriented Criteria and Example API.

Unlike many other persistence solutions, Hibernate does not hide the power of SQL from you and guarantees that your investment in relational technology and knowledge is as valid as always. The LGPL open source license allows the use of Hibernate and NHibernate in open source and commercial projects.
________________________________
Hibernate: Return on Investment (ROI) --September 19th, 2006 http://www.jacoozi.com/blog/?p=16
Performance
Hibernate supports various caching managers. It is a fast performer, has a dual-layer cache architecture, and may be used in a cluster. It’s pure Java design also allows it to be used in any J2EE application server





This tutorial provide step by step instructions on using Hibernate 3.0. Hibernate is popular open source object relational mapping tool for Java platform. It provides powerful, ultra-high performance object/relational persistence and query service for Java. Hibernate lets you develop persistent classes following common Java idiom - including association, inheritance, polymorphism, composition and the Java collections framework. The Hibernate Query Language, designed as a "minimal" object-oriented extension to SQL, provides an elegant bridge between the object and relational worlds. Hibernate also allows you to express queries using native SQL or Java-based Criteria and Example queries. Hibernate is now the most popular object/relational mapping solution for Java

http://www.hibernate.org/hib_docs/reference/en/html/tutorial.html
http://www.roseindia.net/hibernate/index.shtml

Friday, March 14, 2008

Spring Framework

Question:
I remember watching a presentation from Rod Johnson about two years ago ... this one looks very (too) similar. I think that the Java world owes a lot to Spring, they brought a lot of common sense back when things where going crazy with EJB 1/2.

However, EJB 3 took a lot of those lessons from Spring (dependency injection, simplicity, etc). Is Spring a victim of its own success? Will it keep growing as EJB 3 gets more open source app servers?

Answer:

Spring is an integration framework. While EJB3 is not.
Transaction demarcation in Spring is done much better.
With Spring you can work same way with JDO,Toplink,Hibernate,Plain JDBC. With EJB3 you provides only very restricted subset of Hibernate featues (e.g. no Criteria API at all).
Spring provides AOP out of the box. EJB3 guys usually don't even know what it means.
Spring provides ACEGI for Security while EJB3 has only JAAS.
Have a look at Spring remoting and compare it to EJB3.
And the last Spring provides IoC while EJB3 only uses IoC.

Now tell is Spring a victim or a winner ;-)
_________________________________
Inroduction to SpringFramework - dated May 2006Yet another framework?You may be thinking "not another framework." Why should you read this article, or download the Spring Framework (if you haven't already), when there are so many J2EE frameworks, or when you could build your own framework? The sustained high level of interest in the community is one indication that Spring must offer something valuable; there are also numerous technical reasons.

I believe that Spring is unique, for several reasons:

It addresses important areas that many other popular frameworks don't. Spring focuses around providing a way to manage your business objects.
Spring is both comprehensive and modular. Spring has a layered architecture, meaning that you can choose to use just about any part of it in isolation, yet its architecture is internally consistent. So you get maximum value from your learning curve. You might choose to use Spring only to simplify use of JDBC, for example, or you might choose to use Spring to manage all your business objects. And it's easy to introduce Spring incrementally into existing projects.
Spring is designed from the ground up to help you write code that's easy to test. Spring is an ideal framework for test driven projects.
Spring is an increasingly important integration technology, its role recognized by several large vendors.

______________________________________________

The Spring Framework - Reference Documentation

Using the JDBC Core classes to control basic JDBC processing and error handling
11.2.1. JdbcTemplateThe JdbcTemplate class is the central class in the JDBC core package. It simplifies the use of JDBC since it handles the creation and release of resources. This helps to avoid common errors such as forgetting to always close the connection. It executes the core JDBC workflow like statement creation and execution, leaving application code to provide SQL and extract results. This class executes SQL queries, update statements or stored procedure calls, imitating iteration over ResultSets and extraction of returned parameter values. It also catches JDBC exceptions and translates them to the generic, more informative, exception hierarchy defined in the org.springframework.dao package.

11.2.1.1. Examples
Find below some examples of using the JdbcTemplate class. (These examples are not an exhaustive list of all of the functionality exposed by the JdbcTemplate; see the attendant Javadocs for that).

11.2.1.1.1. Querying (SELECT)
A simple query for getting the number of rows in a relation.
int rowCount = this.jdbcTemplate.queryForInt("select count(0) from t_accrual");
A simple query using a bind variable.
int countOfActorsNamedJoe
= this.jdbcTemplate.queryForInt("select count(0) from t_actors where first_name = ?", new Object[]{"Joe"});


11.4. Modeling JDBC operations as Java objects
private class CustomerMappingQuery extends MappingSqlQuery {

public CustomerMappingQuery(DataSource ds) {
super(ds, "SELECT id, name FROM customer WHERE id = ?");
super.declareParameter(new SqlParameter("id", Types.INTEGER));
compile();
}

public Object mapRow(ResultSet rs, int rowNumber) throws SQLException {
Customer cust = new Customer();
cust.setId((Integer) rs.getObject("id"));
cust.setName(rs.getString("name"));
return cust;
}
}

public Customer getCustomer(Integer id) {
CustomerMappingQuery custQry = new CustomerMappingQuery(dataSource);
Object[] parms = new Object[1];
parms[0] = id;
List customers = custQry.execute(parms);
if (customers.size() > 0) {
return (Customer) customers.get(0);
}
else {
return null;
}
}

Chapter 12. Object Relational Mapping (ORM) data access
The Spring Framework provides integration with Hibernate, JDO, Oracle TopLink, iBATIS SQL Maps and JPA: in terms of resource management, DAO implementation support, and transaction strategies. For example for Hibernate, there is first-class support with lots of IoC convenience features, addressing many typical Hibernate integration issues

______________________________________________________________________________
Spring 2.0: What's New and Why it Matters - Posted by Rod Johnson on Jan 15, 2007

Most important, it has developed a large and loyal user base, which understands its key values and has contributed feedback that has helped it to advance rapidly. Spring's mission always been clear:

- To provide a non-invasive programming model. As far as possible, application code should be decoupled from the framework.
- To provide a superior solution to in-house infrastructure, so that developers can focus on delivering business value rather than solving generic problems.
- To make developing enterprise applications as simple as possible, but enhancing, rather than sacrificing, power

As work on Spring 2.0 progressed through 10 months of development, we also needed to take into account several trends that became evident in Spring usage in 2005-2006:

An increasing number of prominent third party software products are using Spring internally, and need the optimum in configurability and flexibility from the container. Examples here are many. To choose just a few:
The upcoming BEA WebLogic Server 10, which uses Spring and the Pitchfork Project to perform injection and interception.
BEA WebLogic Real Time (WLRT)-a high-end product from BEA targeted at applications such as front office trading, requiring low latency.
Numerous widely used open source products such as Mule, ServiceMix and the Apache JetSpeed portal container.
Enterprise vendors integrating their products with Spring such as GigaSpaces, Terracotta and Tangosol. Vendors in the grid space, in particular, are increasingly embracing Spring as the programming model of choice.
Oracle's SCA implementation and various other Oracle products.

________________________________________________
spring frame work
A Primer on Spring's Data Access Object (DAO) Framework - by Dhrubojyoti Kayal - 11/29/2006

The business components in J2EE applications typically use the JDBC API to access and change persistent data in relational databases. This often leads to the mixing of persistence code with business logic—a bad idea. The Data Access Object (DAO) design pattern addresses this problem by separating the persistence logic into data access classes.

This article is a primer on DAO design pattern, highlighting its merits and demerits. It then introduces the Spring 2.0 JDBC/DAO framework and demonstrates how it elegantly addresses the drawbacks in traditional DAO design.

Spring books
Spring in Action - 2 nd edition seems good book with Spring 2.0






___________________________________________________

Thursday, March 13, 2008

Who gets rich off $3 gas - who doesn't


The guy running the service station makes just a few cents, while crude oil producers take the biggest chunk. -- March 13, 2008

Just a few cents of every gallon goes to the gas station when you fill up - most goes to those that produce the oil.
pay_pump4.jpg

NEW YORK (CNNMoney.com) -- Motorists may fume when forking over $3 a gallon at the local service station, but as it turns out, your local filling spot makes chump change from a gallon of gas.

So exactly who is getting rich?

Oil traders: While often blamed for pushing up prices, traders don't necessarily benefit from the high price of crude or gasoline; they profit from how much the price changes. Traders can get rich - as long as they bet correctly on whether prices will rise or fall.

For example, an investment bank that makes a bet that the price of oil will rise makes money when oil prices go from $95 to $100 a barrel - or $100 to $95 if it bet the price will fall - not on the difference between production cost and trading price.

"If you wanna keep your job, you gotta be more right than wrong," said John Kilduff, an energy analyst at the trading firm MF Global in New York, explaining how traders make their money.

Gas stations: A surprisingly small amount goes to the guy who runs the station.

Most service stations are independently owned and operated and take in between 7 and 10 cents for every gallon they sell, according to the U.S. Energy Information Administration.

That 7 to 10 cents going to the gas station isn't even profit. Out of that, station owners still have to pay leases, workers, and other expenses - leaving them with a profit of just a few cents. For the service stations, most profit comes from selling coffee, cigarettes, food and other amenities.

These calculations are based off of EIA's most recent numbers, when gas was $3.04 a gallon. Gasoline hit another record nationwide average of $3.27 a gallon Thursday.

Taxes: The government takes about 40 cents right off the top, with about 18 cents going to the feds. State taxes vary widely, but the national average is about 22 cents a gallon. Most of this money is used to build and maintain roads.

Transportation:
Getting the gas from refineries to service stations via trucks or pipelines - and the cost of storing it in large tanks - eats up another 23 to 26 cents per gallon.

Refining: About 24 cents a gallon goes to refining companies like Valero (VLO, Fortune 500), Sunoco (SUN, Fortune 500) or Frontier (FTO, Fortune 500) that specialize in turning crude oil into gas. Some companies like ExxonMobil (XOM, Fortune 500), Chevron (CVX, Fortune 500) and ConocoPhillips (COP, Fortune 500) also have refining operations.

Profits for refiners have been squeezed lately because the price they pay for oil has risen so much faster than the price they can sell the gas for. This helps explain why Big Oil companies -like Exxon, which actually buys more crude oil than it produces - haven't seen their profits rise as much as the price of oil.

Crude oil: This is the most expensive part of a gallon of gas. Of every gallon of gas $2.07 from every gallon of gas goes to producers of crude like Chevron (CVX, Fortune 500), BP (BP), and smaller outfits like Anadarko (APC, Fortune 500) and Marathon (MRO, Fortune 500), or national oil companies controlled by countries like Saudi Arabia, Mexico or Venezuela.

Crude currently trades around $110 a barrel, but breaking down the money in that barrel of oil is tough. Exploration and production costs, royalty payments - all a big part of $110 a barrel oil - vary widely country by country and project by project.

"It's difficult to generalize; there's a whole spectrum of costs," said Ron Planting, an economist with the American Petroleum Institute, an industry trade group.

They can range from $1 a barrel to produce crude in Saudi Arabia to over $70 a barrel to find, develop and pump oil in the deep water Gulf of Mexico or off the coast of Algeria, said Ann-Louise Hittle, an oil analyst with the energy consultants Wood Mackenzie.

EIA estimates it costs U.S. oil companies an average of about $24 a barrel to find, develop and produce oil worldwide, but that doesn't include costs like transportation, administration, or income taxes - which can be substantial. While Exxon made $40 billion in 2007, a 60% increase from 2004, it paid $100 billion in taxes and royalties.


Nonetheless, $40 billion - or any of the record profits seen by most oil companies over the last few years - is certainly a lot of money, and it has put Big Oil in lawmaker's cross hairs.

Rep. Edward Markey, D-Mass., has called the chief executives of the five biggest oil companies to testify on the industry's record profits on April 1st. Markey's office swears it's no April fool's joke.

Gold prices hit $1,000 milestone

Precious metal hits key level on fears about economy and further weakness in the dollar. -- March 13, 2008
After weeks hovering just below $1,000, gold passed the key psychological mark Thursday.

NEW YORK (CNNMoney.com) -- Gold prices touched the $1,000 milestone for the first time Thursday as the dollar plunged amid nagging fears about the health of the U.S. economy.

After weeks of flirting with the key psychological mark, COMEX gold for April climbed to $1,000 an ounce in morning floor trading. Prices later pared their gains and were most recently up $16.60 to $997.10 an ounce.

Sending prices higher were another drop in the dollar, looming Federal Reserve interest rate cuts, and rising inflation.

"Supply and demand is not really the driver of gold prices," said UBS metal strategist Robin Bhar. "This is about global financial stresses."


Falling dollar. The dollar hit a 12-year low against the yen and retreated to yet another record low versus the euro Thursday. As the price of gold appreciates compared to the dollar, investors pour money into the commodity in hopes that their gold will maintain some value.

"Perhaps some investors have reached a point where there is nothing better than a hard, physical asset like gold," Bhar said.

Interest rate cuts. Many economists expect the Fed to cut interest rates by one-half of a percentage point when the U.S. central bank meets next Tuesday. As interest rates continue to dip, and funds tied to interest rates like money market accounts lose their yield, investors look to an asset that will provide a stronger return on their investments.

"Gold is a non-interest yielding commodity, so lower interest makes gold a more attractive commodity," said Bhar.

Rising inflation. When the central bank slashes rates, inflation rises as the dollar loses its value. As the Fed has cut rates to 3%, prices have risen at an annual rate of 2.5%, according to a U.S. Labor Department reading.

Traditionally, investors put money into government bonds and TIPS to ward off inflation. But recently bonds have provided historically low yields, and many have now transferred their funds into gold.

"It may be that we've reached a point that not even those instruments are adequate insurance against inflation," said Bhar.

But historically, gold has failed to keep pace with inflation. When the economy ends its current downturn, gold prices should eventually fall, as they did 28 years ago. After hitting the $847 mark in January 1980, gold futures fell 70% to $253 in August 1999.

Still a long way to go. Even so, gold may continue to soar. The shiny commodity has long been considered a safe haven for investors worried about the economy.

"The current environment is such that the doom and gloom scenario plays right into investors' hands," said Bhar, who believes that gold prices will continue to rise as long as investors are worried about an economic recession.

"Though forecasts point to no recession, hedge fund clients are quite fearful right now."

And 1980 is proof that gold prices could continue to go up. Though gold has never been traded at a higher price, the $847 level in 1980 would be worth $2,170 in today's money, more than double the current price of gold.

Tuesday, March 11, 2008

PHP PHP IDE , Eclipse PDT

-------------

Reading and Writing Spreadsheets with PHP -- March 31, 2008

Breaking The Language Barrier

When it comes to playing nice with data in different formats, PHP's pedigree is hard to beat. Not only does the language make it a breeze to deal with SQL resultsets and XML files, but it comes with extensions to deal with formats as diverse as Ogg/Vorbis audio files, ZIP archives and EXIF headers. So it should come as no surprise that PHP can also read and write Microsoft Excel spreadsheets, albeit with a little help from PEAR.

In this article, I'll introduce you to two packages that make it surprisingly easy to hook your PHP scripts up to a Microsoft Excel spreadsheet and extract the data contained therein. I'll also show you how to dynamically create a new spreadsheet from scratch, complete with formulae and formatting, and import data from a spreadsheet into a database. So come on it, and let's get started!
----------

PHPExcel - OpenXML - Create Excel2007 documents in PHP - Spreadsheet engine
Project providing a set of classes for the PHP programming language, which allow you to write to and read from different file formats, like Excel 2007, PDF, HTML, ... This project is built around Microsoft's OpenXML standard and PHP.

reviews
# Output your spreadsheet object to different file formats

* Excel 2007 (spreadsheetML)
* BIFF8 (Excel 97 and higher)
* PHPExcel Serialized Spreadsheet
* CSV (Comma Separated Values)
* HTML
* PDF

# Read different file formats into your spreadsheet object

* Excel 2007 (spreadsheetML)
* BIFF5 (Excel 5.0 / Excel 95), BIFF8 (Excel 97 and higher)
* PHPExcel Serialized Spreadsheet
* Excel 2003 XML format
* Symbolic Link (SYLK)
* CSV (Comma Separated Values)
________________________
PHP : where best suites the requirements as programming language
1) to report log information in IT departmetns: Just read from DB or text files and display info with less than 10 lines of code, no huge try catch exception blocks as java , any school graduate can learn and do it.
- this may be reason why google is using to report all it server logs ( see notes below )
2) code development productivity may be at leaset 3 times to that of java
3) huge community generated notes and examples see this url below
http://us.php.net/manual/en/function.mysql-list-tables.php
4) using PDT free IDE , it must be very easy to debug visually , kids can enjoy it too
5) May be good language to introduce programming to kids in 5/6 th grade summber time. no complexity they can learn varibles and simple loops etc..




________________________________
About PDT
The PDT project provides a PHP Development Tools framework for the Eclipse platform. This project encompasses all development components necessary to develop PHP and facilitate extensibility. It leverages the existing Web Tools Project in providing developers with PHP capabilities.
- PDT is about 1 year old started APR 2007


Eclipse Announces New Tools for PHP Developers - press release
- PDT 1.0 release - the first Eclipse project targeting PHP
- “PDT has evolved to a mature and high-quality Eclipse toolset for PHP developers,” says Peter MacIntyre, principal at Paladin Business Solutions in Charlottetown, PE in Canada. “Its strength as a framework for creating PHP systems and applications is certainly evident, and it is exciting to think of the commercial products that can now be delivered leveraging the PDT framework.



PDT 1.0 Release Review
- Aug. 20, 2007
- 17 Committers (14 from Zend and 3 from IBM), so Zend is mainly driving it .
- 40,000 downloads a month

Comparison with PDT
While Zend Studio for Eclipse is built on top of Eclipse and PDT there are significant differences. PDT is designed as a basic PHP editor and a framework for building IDE. Zend Studio for Eclipse is designed as a full featured multi-language PHP IDE based on Zend’s strong experience with Zend Studio to create the most powerful PHP IDE available. This table will give you a quick comparison.
- Basic free PDT version should do for many developments

- PDT you tube
- user comment
____________________________________________________


Where is Python used at GOOGLE - blog dated 2006.02.01 Wed
http://panela.blog-city.com/python_at_google_greg_stein__sdforum.htm

* The Google build system is written in python. All of Google's corporate code is checked into a repository and the dependency and building of this code is managed by python. Greg mentioned that to create code.google.com took about 100 lines of python code. But since it has so many dependencies, the build system generated a 3 megabyte makefile for it!
* Packaging. Google has an internal packaging format like RPM. These packages are created using python.
* Binary Data Pusher. This is the area where Alex Martelli is working, on optimizing pushing bits between thousands of servers
* Production servers. All monitoring, restarting and data collection functionality is done with python
* Reporting. Logs are analyzed and reports are generated using Python.
* A few services including code.google.com and google groups. Most other front ends are in C++ (google.com) and Java (gmail). All web services are built on top of a highly optimizing http server wrapped with SWIG.

Wednesday, March 5, 2008

12 Learnings From My First Turn As Startup CEO

Referred by Rajesh
In December 2003 I decided to take the plunge and quit my corporate job to start a new company from scratch. Believe it or not, it was an easy decision. I had an idea and a certainty that there was a valuable company to be built around it. That company was Jobster, where I served as CEO until January 2008 when I helped recruit my successor, transitioned to vice-chairman of the board of directors, and turned my attention to starting a new company.

Back in December 2003 I had no reasonable idea of what was ahead ... what i did have was passion for the idea of Jobster and for the pursuit of starting and growing a business.

I learned many valuable lessons at Jobster which I will take with me as I start my next company and my next and my next.

Here are some of the key learnings that I hope will benefit many an entrepreneur:

1. The CEO's job is to create value. Determine early on what the keys to value creation are in your industry and map a path for value creation for your business. Return often to measure how you are or are not creating value. Weigh business decisions based on whether they contribute to value creation or not. Avoid paths that do not contribute to value creation regardless of how sexy or fun they might be. Narrow the focus as much as possible. Get one thing right then move on to the next.

2. Try to ride some powerful existing waves vs. just creating new waves. Find some big and important industry trends and ride on top of them. It is very very hard to create your own industry trends. Be careful about getting out too far ahead of any wave.

3. Technology companies are all about the product. Getting the product right is critical before aggressively going to market. We went to market too fast in Jobster's early days. Ultimately your technology company will be judged based on how good your product is and how your target users take to it.

4. Related to #3, the rapid iteration model (ship early, learn from usage, adjust) works well for consumer services but works not as well for B2B services. Consumers will let you learn with them over time. Paying business customers, however, have less patience for your learning on their dime.

5. Hire people who are passionate about the specific problems you are trying to solve. We raised money for Jobster in 2004 when few startups were being capitalized. We were early to social networking. We signed up 150 customers in the first 90 days of going to market. As such, we quickly became the cutest kid on the playground for startup enthusiasts and everyone in town wanted to work at Jobster. A problem, looking back at it, was that many people (not all) joined Jobster because they wanted to work at Jobster, but not because they were passionate about the specific business problems we were trying to solve. Getting this right is very hard but so important.

6. You must get close to your users and customers and live their personas. We often struggled with this at Jobster as not many of our product developers related to recruiters and had trouble walking in their shoes. Likewise, we often had trouble relating to jobseekers and truly understanding their pain, as many of our employees had never really looked for a job. It is critical that you live, sleep, eat, and breathe the personas of your target users. That's one reason for Facebook's success -- their employees use their product all day everyday. It's awesome to be able to build products for yourself. That's what I'm doing in my next company where I am the target persona.

7. The value of your company is directly related to your capital efficiency. Spend every dollar like it is equity. Preserve cash! Preserve cash! Preserve cash! Yes, you need to spend money to build a company and to make money, but every dollar misspent erodes your valuation. We overspent going to market at Jobster in the early days and while we thankfully were able to recognize this and adjust, we are still working at overcoming it. One of the things I'm most proud of at Jobster was our financial discipline in 2007 which enabled us to grow revenues by 50% while cutting our expense base by 50%. That's hard to do but is smart business and drives value creation. That discipline also forced us to (and enabled us to) develop lower cost product development models, and develop a lower cost model for traffic acquisition based on technology and seo instead of spending to acquire users.

8. In the early days, I highly recommend that you force your startup to be resource constrained. Spend as little money as possible until you get some significant product traction. In the early days, if you think you need $1M, take $500k and force yourself to make it work. Our first capital infusion at Jobster was a $2.5M seed round. That was too much and enticed us even in the very earliest of days to go too fast. Within 6 months we had 15 people. For my new company in the early days 3-5 people and at most $750k will do just fine for a long long time until we prove out the product.

9. Don't listen to outsiders who tell you to go faster and ramp sales and marketing. Instead, listen to your current customers and users. The best sign that you are truly ready to ramp the business is customer/user satisfaction. Understand customer/user satisfaction drivers and gaps before ramping sales and marketing.

10. Avoid field sales in favor of telesales. At Jobster we quickly learned that field sales cost twice as much to sell (longer sales cycle, higher salary reps), and that you could sell the exact same product over the phone faster, cheaper, and with a much lower expectation for after sale support.

11. Once you are in the market and have established some measurable and repeatable levels of success, #11 negates #8 on this list: Raise more money than you need when you are in the market and the terms are favorable. We raised $18M at Jobster in mid 2006 at good terms and that fundraising was absolutely key to our being able to make critical adjustments which have Jobster on solid footing today. In hindsight, I should have and would have raised $30M then. Businesses take time to develop and are bound to have rough patches. Having the capital to learn, adjust, and get through to the other side is critical.

12. Have fun. Everyone looks to the CEO everyday to set their own moods and expectations. Being CEO can be lonely -- someone once said to me that CEO is the loneliest job in the world as there are days that your board hates you, your employees hate you, your customers hate you, and your family hates you -- true. That's why you need to make sure to have fun every step along the way. If you are having fun, people will see that and they will follow your energy. Remember, behind every wrong turn is a better path. And remember, that the beauty of startups is that you get to try, try, try again and again and learn a ton along the way.