Groovy Web Service Client (GroovyWS)
Here’s 2 examples of how simple groovy web service clients can be. You will need to download a groovy lib jar from the GroovyWS Home Site. Basically it just creates the classes dynamically on-the-fly instead of creating stubs.
1. CurrencyConvertor
import groovyx.net.ws.WSClient
proxy = new WSClient("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL", this.class.classLoader)
//'USD', 'EUR', 'CAD', 'GBP', 'AUD', 'SGD'
rate = proxy.ConversionRate('SGD','USD')
print rate
2. Stock Quote
import groovyx.net.ws.WSClient
proxy = new WSClient("http://www.webservicex.net/stockquote.asmx?WSDL", this.class.classLoader)
quote = proxy.GetQuote('GOOG')
print quote
Read Geertjan’s groovy_web_service for more info (Swing).
Read the official Groovy Web Service Doc for more info (Groovy WS) .
First Flex Play-around
This is a great explorer site for flex sample effects.
http://flexapps.macromedia.com/flex15/explorer/explorer.mxml?versionChecked=true
Maintaining record of camping in office
I have a habit of camping in the offices of all my jobs up to now(yes,including working as an intern at MobileOne 6 years ago) , and managed to maintain that record yesterday (sat-sun).
My current office at suntec tower 3. We are rushing for a project to be deployed on wednesday, thus the need for weekend work.
So after watching the England vs Estonia boring game at a screen at level 3, near Eng Wah Cinema, the work began from 11pm till about 5am.
Well, in my previous company 3 yrs ago i used to play starcraft, ghost recon, diablo overnight and continue working the next day at the office, so this is nothing compared to it =D
Postgres – Grant privileges to all tables in a database
Grant privileges to all tables in a database (select, update, insert, delete)
Eg:( Creating a read-only user in postgres)
For Postgres 7.*
–Function to grant access(select,insert,update,delete) to users
CREATE FUNCTION pg_grant(TEXT, TEXT, TEXT, TEXT)
RETURNS integer AS '
DECLARE obj record;
num integer;
BEGIN
num:=0;
FOR obj IN SELECT relname FROM pg_class c
JOIN pg_namespace ns ON (c.relnamespace = ns.oid) WHERE
relkind in (''r'',''v'',''S'') AND
nspname = $4 AND
relname LIKE $3
LOOP
EXECUTE ''GRANT '' || $2 || '' ON '' || obj.relname || '' TO '' || $1;
num := num + 1;
END LOOP;
RETURN num;
END;
' LANGUAGE plpgsql SECURITY DEFINER;
–Function to revoke access(select,insert,update,delete) from users
CREATE FUNCTION pg_revoke(TEXT, TEXT, TEXT, TEXT)
RETURNS integer AS '
DECLARE obj record;
num integer;
BEGIN
num:=0;
FOR obj IN SELECT relname FROM pg_class c
JOIN pg_namespace ns ON (c.relnamespace = ns.oid) WHERE
relkind in (''r'',''v'',''S'') AND
nspname = $4 AND
relname LIKE $3
LOOP
EXECUTE ''REVOKE '' || $2 || '' ON '' || obj.relname || '' FROM '' || $1;
num := num + 1;
END LOOP;
RETURN num;
END;
' LANGUAGE plpgsql SECURITY DEFINER;
–Create users for your database
CREATE USER userreadonly WITH PASSWORD 'userr3ad0nly';
CREATE USER userall WITH PASSWORD 'usersh0pa11';
–Grant respective access to users
select pg_grant('userreadonly ','select','%','public');
select pg_grant('userall ','select,insert,update,delete','%','public');
You might need to create lang for plpgsql if you had not done so
createlang plpgsql yrdatabasename
UML Class Relationships
Multiplicities
- any number (0 or more): *
- one or more: 1..*
- zero or one: 0..1
- exactly one: 1
Association(Aggregation, Composition)

Both are ways of designating or grouping items by relationship. In the case of composition, if the links that bind the objects are broken, then all objects are destroyed. In aggregation, it’s a looser grouping, and if the links are broken the original objects still exist.
“Aggregation differs from ordinary composition in that it does not imply ownership. In composition, when the owning object is destroyed, so are the contained objects. In aggregation, this is not necessarily true. For example, a company owns various departments (e.g., sales), and each department has a number of employees. If the university closes, the departments will no longer exist, but the professors in those departments will continue to exist. Therefore, a Company can be seen as a composition of departments, whereas departments have an aggregation of employees. In addition, an Employee could work in more than one department, but a department could not be part of more than one company.”
Time to abandon the Waterfall SDLC and/or Business Analysts?
Part 1 – Abandon Waterfall SDLC?
I feel gone are the days whereby software companies should force customers to sign off system requirements.
Reason? There is no guarantee that the requirements gathered during the “System Analysis” phase of the Waterfall cycle is fully complete. So if you’re forcing the customer to sign off and get ready to accept something that they might not fully embrace after delivering, then there might be a problem late on.
Instead of contract disputes in the end, why not have constant customer collarboration/communication throught the lifecycle through an agile development methodology like Extreme Programming or Scrum? Customer should be as involved with the success of the project as the project development team.
Your company is foolish not to tap on the customer’s feedback during the project development. At the end of the day, it’s the customer who mark the acceptance tests.
Part 2- Abandon Business Analysts?
This one is abit controversial. Did i meant let the developers take over the job of business analysts? Possible, why not? Developers are supposed to be smarter than BAs, although BAs generally have better communication skills. Generally developers create prototypes anyway, so if there is any mis-communication, changes can be done swiftly.
The key problem is having good communication skills alone does not allow a BA to analyst customer IT problems and churn out technical user requirements/specifications.
It is easier to find a developer with decent communication skills than a sound business analyst with development background or is IT-savvy. And if you ever find one, do whatever it takes to keep him/her. My working experience also made me believe that BAs should come from a technical background. It improves the specs they write, trust me.
Even though generally managers prefer decision-biding employees rather than employees whom speak up and challenge decisions, you can be sure you’ll get more of those if you have such developers. “Can’t these developers just write the damn code” they thought. I’m one of those. CTOs doesn’t scare me 1 bit.
I generally prefer to gather requirements directly from customers. If information gets filtered by BAs, 100% customer requirement accuracy might just be left 80%. If specifications are written incorrectly, you are left with maybe 60%.
XP suggests that a customer be placed at the development site, Thoughtworks practises placing the development team within the customer’s site, with the latter sounding more practical to me. Simply having a key customer decision maker’s MSN account would be fine for me though.
Strings
String s = "f" + "o" + "o"- The comparison
('a' == s.charAt(0)) - The StringBuffer default capacity is 16. If your string is going to be larger than that, you might as well reserve a larger capacity by passing a realistic length such as
StringBuffer sb = new StringBuffer(1024);
is faster than
String s = "f";
s+="o";
s+="o";
is faster than
s.startsWith("a");
Spring Hibernate DAO Implementation with interface
Intro
Assuming we have a module called Account Management in our project called foo,
We might can make use of the following package structure.
- foo.service.AccountManagement
- foo.service.AccountManagementImpl
- foo.dao.AccountDAO
- foo.dao.hibernate.AccountDAOImpl (In this case hibernate)
- foo.model.Account
Spring Wiring
<bean id="accountDAO" class="rb.dao.hibernate.AccountDAOImpl"></bean>
<bean id="accountManagement" class="foo.service.AccountManagementImpl">
<property name="accountDAO">
<ref bean="accountDAO"/>
</property>
</bean>
So note that you can replace the accountDAO with some other implementation class, probably using pure JDBC or ibatis.
Summary
As the experts say, always code to interfaces to cater for different implementations.



