create functionality without jvm restart]strategy pattern

Strategy patterns allows you to define a family of interchangeable algorithms, to be selected at runtime. In extreme circumstances, a new algorithm is to be created and to be added immediately without jvm restart. This would be a higher level of flexibility.

Perhaps the highest level of flexibility is offered by a DB containing classnames in the “family”. After you create a new algorithm, you insert its classname into the DB.

Class c = Class.forName( “com.myPackage.Myclass” );
Thing t = (Thing)c.newInstance( );

Also see detailed sample code in http://www.javaworld.com/javaworld/jw-08-2001/jw-0810-extend.html

Advertisements

"PREDICATE" = boolean-expression OR other meanings

In STL, the 2 types of predicates — filter vs the comparator — could cause major confusions to beginners learning the STL syntax details

predicate = any statement that evaluates an expression and returns a boolean.
predicate (xsl) = a filter
predicate = a proposition
predicate = an assertion

— contexts —
xpath?
sql where-clause? filter on list
matlab? filter on list

one-word intro 2 outer join

Outer join (amidst other joins) can be confusing for beginners. Different authors use their favorite anchor keywords. Best one-word intro: subset

Sometimes, one join-column is a subset of the other join-column, where outer join and inner join show their difference. Focus on subset scenario for now. Once you get your mind around this scenario, you are ready to look at the generic scenario where one join column is not a subset of another join column

–2nd word after “subset”? union

In some SQL implementations, u need a union query to do outer join

I believe unions solve more problem than outer joins.

–simplest example: bonus
show employees with and without bonus
“bonus” table {employee_id (forkey), bonus}

wait() means, to a beginner

To avoid overwhelming a beginner, the simpler meaning is “current thread please wait”.

* wait() means “current thread please wait at this statement, inside this waiting area”
* wait() means “Hey the thread executing this statement, please wait at this statement, in this object”

Note: Remember the method enclosing the wait() statement belongs to the “this” object? The “waiting area” is the “this” object.

Note: The “thread” is the real world thread, not to be confused with the Thread object returned by Thread.getCurrentTrhead()

runtime change to object behaviour

[[ head first design patterns ]] repeatedly favors *runtime* change to program functionality, rather than compile-time ie source code change. I assume they have a *practical* reason instead of a doctrine.

Related concepts: Strategy pattern, Decorator pattern,

When we need to change from an old functionality to a new functionality, a good approach is
* we try to create a new functionality class, if at all possible,
* at runtime, use existing setters to assign the new functionality, replacing the old, when needed.
* minimize edits to existing, tested classes

See also post on [[ create functionality without jvm restart]strategy ]]

I think this probably incurs least-impact to existing, tested functionalities.
=> regression test@@ no need
=> Low stress for fellow developers, managers, clients, internal users and any non-technies.
=> no need to worry “Did we miss any other existing classes that need edit?”
( documentation on interdependencies is crucial but often neglected by developers. )

be prepared for entry-level java position interviews

Hi XR,
在美国这三个月, 见面和电话面试了接近十个 Java 职位.
有个不能确定的感觉. 我这样(新移民?)的应聘人, 在 Java 领域主要被看做底层动手编程的角色. 要求手快, 记性好, 写程序”产量”高, 质量 (Performance, Security….) 也不能有明显弱点. 三个字 — 快而准.

不是我的优势.

我的另一些不大不小的特长, 面试公司欢迎但不常问到. 比如 High Volume Java App server 维护, Basic Weblogic Configuration/tuning, Cluster 入门知识, Database design, tuning 入门知识, Java 与 External System 的 Integration …也许有别的人员务责这几块. 但如果是小公司, 可能没有全职 DBA, 全职 Weblogic Admin 之类. 如果真的没有这些方面的专家, 那务责的人可能经验不多, 跟我一样在这些领域只有半桶水. (我曾经单枪匹马挑过 Oracle, Mysql, Weblogic… 这几个重担)

想做小公司的 Architect. 但是没有人考虑我. 也算公平, 自认 Java / SQL 还不精深. 希望你的运气比我好些, 也希望我的运气能慢慢改善. 还希望我能通地更多的面试实战, 能对 Java 就业市场有一个更深入更准确的把握, 不再象这样靠一丁点微弱的灯火摸着黑前进.

你问到工作有多累. 同事们大都是 9 – 5, Mon-Fri. 我每周干 50 个钟头. 9:30 – 6:30. 连续 5 个周六主动回公司加班几个钟头. 在路上/家里, 每天至少一小时学 Java/SQL/PHP, 不觉得苦.
New York 的工作项目更累. 平均 10 小时/天, 路程更长, 单程一个多钟头.

partitioned table: sybase^oracle

— based on http://manuals.sybase.com/onlinebooks/group-as/asg1251e/commands/@Generic__BookTextView/34421;hf=0

An unpartitioned table with no clustered-index (%% irrelevant %%) … each insertion into the table uses the last (newest) page of the chain. Adaptive Server holds an exclusive lock on the last page while it inserts the rows, blocking other concurrent transactions from inserting data into the table.

Partitioning a table with the partition clause of the alter table command creates additional page chains. Each chain has its own last page, which can be used for concurrent insert operations. This improves insert performance by reducing page contention.

If the table is spread over multiple physical devices, partitioning also improves insert performance by reducing I/O contention (lower than page-contention) while the server flushes data from cache to disk.

avoid clustered index on identity column

If you do a large number of inserts and you have built your clustered index on an Identity column, you will have major contention and deadlocking problems. This will instantly create a hot spot in your database at the point of the last inserted row, and it will cause bad contention if multiple insert requests are received at once. See post on [[ batch feature wishlist — integrate ]] There are 2 solutions, based on http://www.faqs.org/faqs/databases/sybase-faq/part14

Solution #1: create your clustered index on a field that will somewhat randomize the inserts across the physical disk (such as last name, account number, social security number, etc) and then create a non-clustered index based on the identity field that will “cover” any eligible queries.

The drawback here, as pointed out in the Identity Optimization section in more detail, is that clustering on another field doesn’t truly resolve the concurrency issues. The hot spot simply moves from the last data page to the last index page of the Identity column index (no longer clustered)

%%Every insert requires a write to the non-clustered index on IC. Since the IC increases for every insert, these index writes occur at the highest IC values. Visualize a B-tree index tree and often these index writes happen on the right-most leaf node.%%

— based on http://www.4guysfromrolla.com/ASPScripts/PrintPage.asp?REF=%2Fwebtech%2Fsqlguru%2Fq021700-1.shtml

Recall that a clustered index physically sorts the data pages in a table. If you put a clustered index on an IDENTITY column, then all of your inserts will happen on the last (newest) page of the table – and that page is locked for the duration of each IDENTITY.

Solution #2: turn on insert row-level locking in SQL 6.5, and that will only lock the row being inserted, thus reducing lock contention. You can also move your clustered index to a different column, thereby scattering the inserts around the table.

sybperl ^ DBD::Sybase

features^ease — my short comparision of the 2, based on hearsay. In other words, sybperl exposes more sybase features but DBD::sybase is easier to learn since it’s standard DBI/DBD. How easy? Nothing more than a change from “dbi:oracle:..” to “dbi:sybase:…”.

Other aspects?

* ease of use@@ Sybase::Simple is part of sybperl, but can’t reach the ease of DBD::Sybase
* Bugs and stability@@ I think by now DBD::sybase is mature and stable, but presumably less battle-tested than sybperl for certain rarely used features.
* performance@@ no idea