Dear
Software Developers,
This CPTTM Software Developer newsletter is to bring useful news to
you, software developers in Macau, for references without obligations,
so that you can do your jobs easier and better! Hope you like it. if
you'd like to unsubscribe or recommend your friends to subscribe, just
email me at kent@cpttm.org.mo.
Old issues are available here.
Topics in this issue:
Wicket adoption in Macau
Recently I learned that there are quite
some organizations in Macau have adopted the excellent Apache Wicket framework
for rapid web application development. These include a major higher
education institute, two large government agencies, an small software start-up, in addition to CPTTM itself.
This information should be useful for you
to persuade your management to adopt it, so that you can enjoy
a much higher productivity (e.g., than Struts or JSF). If your
organization is already using it, don't hesitate to let me know (I will
not disclose the name of the organization unless you want me to) so
that other poor programmers can benefit.
How to set up and use auto-complete in
Eclipse
In Eclipse, if you like to type, say, the
following line:
List l = ...;
You could type "Li" and then Alt+/ and it will
suggest "java.util.List". This is called auto-complete or content
assist. To enable this feature:
- Choose Windows | Preferences | General | Keys.
- Use "Word Completion" as the search key.
- Remove its binding (by default, Alt+/ is bound
to "Word Completion", not "Content Assist").
- Use "Content Assist" as the search key.
- Bind it to Alt+/.
Improving
database access performance from your program
If your program is very slow when accessing the
database, usually there are only two reasons: You are are fetching more information than you
actually use or fetching the information in too many roundtrips. More
specifically:
- Fetching
more rows than needed. Will the SELECT statement
match a lot of
rows? Even if your code will only actually read a few of the rows, many
JDBC drivers will fetch all matching rows from the
database server before returning anything to your code. The solution is
to use OFFSET
and LIMIT (useful for paging). Another solution is to call,
say, setFetchSize(50) on the query so that it will fetch at most 50
rows at one time. However, this is only a hint to the JDBC driver; it
may or may not obey.
- Fetching
more columns than needed. Are you
fetching long columns such as those
varchar(1024) by using "SELECT *"? If you don't need those columns,
specify exactly those you really need such as:
SELECT ID, NAME from PRODUCTS
- Using
many small queries. Are you selecting, say, all the
products using
one SELECT and then issue a SELECT to find all the parts for each
product? If you have N products, you will issue N+1 queries. A much
better way is to use a single query using join such as:
SELECT A.ID, A.NAME, B.NAME from PRODUCTS A JOIN PARTS B ON A.ID=B.PRODUCT_ID
Do you have a tip not listed here? Don't hesitate to let me know.
  
Feedbacks
Any questions, ideas or experiences to share? Contact me at 28781313
or kent@cpttm.org.mo. We also
have two other newsletters: CIO newsletter
and Network
administrator newsletter,
your friends may like to subscribe.
Until next time,
Kent Tong |