stored-proc ^ dynamic-sql

In some apps, these are the 2 main solutions.

I think dynamic sql isn’t industry-standardized (stored proc has an ANSI standard) and depends heavily on rdbms server support.

In theory, once microsoft/oracle has a good dynamic-sql feature, other vendors could follow.

Search for “dynamic sql oracle/sybase/db2/…”

eclipse build-path

J4: 10% of the non-trivial but /tractable/ beginner eclipse problems are related [1] to build-path. If you don’t mind studying “too much” on a topic, study build path.

Each source folder can define an exclusion-filter to specify which resources inside the folder should be invisible to the compiler.

offline help > Java Development User Guide > Reference > Property Pages > Java Build Path page

[1] indirectly, perhaps in hind sight

Eclipse compiler warning — customize

— based on offline help:

“For some other types of problems you can, however, specify if you want the Java compiler to report them as warnings, errors or to ignore them. To change the default settings, use the Java > Compiler > Errors/Warnings preference page.”

Suggestion (untested): During rush phase, many of your colleagues would probably ignore the hundreds of warnings anyway. On the config window, Try to turn every listed item from “warning” to “ignore”. May reduce noise. When you want to work on your code quality, you may wnat to turn on specific items.

eclipse, randome learning notes

2 common practices
– src && class files in the same folder
– src && class files in separate folders, by default named

When you encounter an existing body of source code (perhaps on a colleague’s system), recognize this common /pattern/

A project contains only files and folders. The notion of a Java package is introduced by a Java project’s class path.

Q: “How do I prevent having my documentation files from being copied to the project’s output folder?”

Q: Can I have an output or source folder that is located outside of the workspace?
A: Yes, you can create a linked folder that points to the desired location and use that folder as the source or output folder in your Java project.

Eclipse offline help

Eclipse offline help is (too) complex and often frustrating to a beginner.

Tip: remember there are 3 important “tabs” at the bottom when you are reading only one of them. Without this knowledge, you can easily get derailed by a search in the offline help.
– search results
– index
– table of contents — tree

q[SET]^q[EXPORT]^plain assignment #no-arg SET

(Not sure about csh. Let’s focus on /bin/sh and bash for now. I bet everything here also applies to ksh.)

“set” is mostly used to set options. I see it less often used to manipulate variables, which is possible but unnecessarily complicated. In fact

set a=1; echo $a # shows nothing

  • “set” alone displays variables, but “set” doesn’t modify/create variables. [1]
  • “export” has a single meaning and you see it used consistently (whereas “set” isn’t).

Are you managing variables in bash? A simple “binary” advice is
– use export for ENV variables
– use “nothing” to manage shell variable — Nothing but “a=1”

How about “let”? Only needed for arithmetic. I would say don’t let this stranger join the club and confuse yourself.

[1] In DOS, “set” command creates variables (

Eclipse — dir for output/src classes

–to change default from src and bin to something else, like “classes”,
window -> preferences -> java -> build path

–to change per-project setting
project -> properties -> java build path -> source -> go to page bottom.

You can set “Default output folder” to “myproject1/classes” even though there’s no physical directory named “myproject1”. Instead, the ../classes/ directory will show up in the project’s root directory — confusing.

Similar confusion arises when you see an explorer-style directory tree with “myproject1” as the root (no such directory) and real directories as branches.

eclipse jargon: project

From the user’s perspective, there are three different types of resources: projects, folders, and files.

A project IS-A …
* a dir
* a logical grouping of things. Eclipse manipulates them as a unit

A project HAS-A …
* build path
* list of jars for build path

q: When creating a new project, can you create an empty project somewhere outside the workspace-directory?
a: yes

q: must src live in the project-dir?
A: i think so

eclipse jargon: workspace

Q: What exactly does it mean in the context of various texts generated by Eclipse?

#1 tip: call it “workspace-directory” whenever possible. For now, I call it “ecl_ws dir”

We see a z:\workspace created by Eclipse. I think “a workspace is a directory” more or less, even though eclipse documentation doesn’t put it so simply.

Eclipse usually (but not always) stores your projects in a folder called a workspace. Choose a workspace folder to use for this session. Without a workspace, I think you can’t proceed to create a project. A workspace can have any number of projects, each of which can be stored in a different location in some file system. workspace-dir can be on C: drive, and source dir (src-dir) can be on another (even samba share).

A workspace’s resources are organized into a *tree* structure, with projects at the top, and folders and files underneath. seems to shed some light

eclipse perspective, view

J4: a new Eclipse user is a poor thing. Under a deadline, she had to figure out a ton of Eclipse jargons (in online help, config windows …) and get Eclipse to work, jargons like “perspective”.

A perspective IS-A “blanket layer” covering the entire Eclipse display window.
A perspective IS-A … basically a layout.

A perspective-layout HAS-A … panels (known as “views”) and menus.

When you switch to CVS perspective, you won’t see any java “panels”.

To refresh a “view”, click in the view first. Why refresh? U can make changes outside Eclipse !

ref-counter Garbage collector

#1 drawback = “island”. Probably uncurable.
#2 drawback = “unavoidable[1] overhead[2]” in terms of ref-counter updates for (almost) every assign and every “unassign”
The #2 drawback is not the only “unavoidable overhead” — There’s also an unavoidable overhead in a handle-table compactor GC, which
maps every variable [3] to a handle, and every handle to an address in the jvm’s memory space. This adds one additional level to a
direct variable-addr mapping. Probably additional CPU cycle required for every variable[3] load or store.

ref-counter is the only GC without root objects.

[1] Most if not all other GC algorithms add overheads[2] in other ways but They don’t add overhead for every single assign.
[2] overheads = additional CPU cycles
[3] excluding primitives

Re: Put releasing resource process in Object.finalize() is !! safe.

Excellent research. If you mention this to an interviewer, you will look good.
The finalizer technique is widely used, which may not always imply effectiveness. The basic idea is, if my object (for example, a shopping cart object) holds a reference to a resource like a DB connection, then in my object’s finalize(), it ought to release the resource. Logically sound ideas like this are not always 100% reliable, but still effective in my humble opinion.
“Defensive programming in-depth” suggests “design more than one layer of protection”. If one layer is not “safe” as in this case, another layer may protect us.
Therefore, we should use both 1) finalizer and 2) finally(), if possible.
My new company (I should slowly learn to avoid mentioning my company’s name) uses the finally{} technique in a lot of classes. I think probably every time a method gets a db connection, there’s a finally() in that method.
I feel DB connection release is important. Some DB vendors charge license fees based on max simultaneous connections. If we pay x dollars for 20 simultaneous connections, then those 20 simultaneoud connections become a potential bottleneck. As soon as you release the connection, another (waiting) thread can use it to read/write data.
3) A third idea (?) — An architect can instruct programmers to explicitly release resource as soon as they are done. Programmers are busy and forgetful, though. That’s why architects like the finalizer idea.
4) Do you think a DB can detect idle connections and close them after x minutes of inactivity? Do you think a connection pool manager can?
Thanks for the excerpt. Quite relevant for me.
On 11/7/07, rong xia

Hi, Tan Bin,

We have ever discussed about garbage collection.
You mentioned a question that I can just roughly recall as: How do you make sure to release resource, such as DB connection or something else?
I answered without any hesitation: put it in the Object.finalize(). And it seems you agreed with me.
But I found it’s not correct, because of the following reasons: I copied and pasted.
As you program in Java, you must keep in mind that it is the garbage collector that runs finalizers on objects. Because it is not generally possible to predict exactly when unreferenced objects will be garbage collected, it is not possible to predict when object finalizers will be run. As mentioned in Chapter 2, “Platform Independence,” you should avoid writing programs for which correctness depends upon the timely finalization of objects. For example, if a finalizer of an unreferenced object releases a resource that is needed again later by the program, the resource will not be made available until after the garbage collector has run the object finalizer. If the program needs the resource before the garbage collector has gotten around to finalizing the unreferenced object, the program is out of luck.
So, simply put the process in the Object.finalize() is not safe.
I can think of putting the process in finally statement block in a logic block.
Do you have any other good ideas to achieve this requirement?

what in addition to java^dotnet

Hi JunLi

A few days ago I said something like “enterprises application development usually choose between java and dotnet”. A few qualifications

* Where stored procedures are required (or clearly superior), then obviously java and dotnet must give way to the stored procedure language, such as pl/sql and Transact-SQL.

* Where shell/perl/python scripts are required (or clearly superior), then obviously java and dotnet must give way. However, most enterprise applications use less scripting languages than compiled languages.

* C++ is probably the third biggest language in enterprise app development. I have personally witnessed the important role of C++ in financial and telecom systems. I believe that in both financial and telecom, C++ offers somewhat better performance.

* Python was adopted by JPMC, BAML and Macquarie.

* PHP is increasingly chosen by enterprises such as facebook, yahoo, NBC-Universal and MTV.

By the way, software vendors and system programmers favor C more than java and dotnet. (JVM and the dotnet compilers were probably written in C), but our focus in this discussion is “enterprise app development” rather than platform/library/tool development.