Wednesday, November 21, 2007

EJB Caching

http://wiki.jboss.org/wiki/Wiki.jsp?page=CMPCacheInvalidation

What is a container configuration?

Dependencies

Examples:
* any kind of service (eg session bean)
* config
* Transporta appconfig

Problems
* testing - dependency which requires initialization, eg. transporta appconfig
helper invokes through xcs for the appconfig
* config reads from database
* injection doesnt work for non-ejb components
* need a uniform way of handling these things
* where do you initialise things?

Solution Ideas
* dependency injection
* put all dependencies in the constructor, use interfaces
* have service locators or singletons

Dependency Injection
=====================

have an interface, and component is
injected with a working service at run time - BUT - this is troublesome if you
don't have an injection container.

alternatives to DI - new, static, Factory, JNDI

What is Spring?

Non Dependency Injection
========================

Declare dependencies in constructor, use interfaces if they need to be mocked
out. Initialization can be through JNDI container-created components, otherwise
through a setup class.

through constructors, you can make sure dependencies are met, you can easily see
what a class uses.



Links
* http://www.onjava.com/pub/a/onjava/2006/02/08/j2ee-without-application-server.html
* http://www.brandonwerner.com/category/technology/architecture/service-oriented-architecture/page/2/
* http://www.theserverside.com/tt/articles/article.tss?l=SpringFramework

Monday, October 15, 2007

EXEC sp_change_users_login 'Auto_Fix', 'vertical'

Tuesday, October 9, 2007

kml, google maps

Adding labels to markers:
http://googlemapsbook.com/2007/01/22/extending-gmarker/

kml tutorial
http://code.google.com/apis/kml/documentation/mapsSupport.html

Thursday, September 27, 2007

Composite Entity Pattern

Introduced in EJB 2.0 period to reduce the number of entity beans and use of entity beans remotely. Idea was you would have more coarse-grained entities which would have other entities as dependent objects and manage their lifecycles.

With a Composite Entity, a client can obtain all required information with just one remote method call.

Wednesday, September 26, 2007

Getting row with latest timestamp

Idea of having a separate table with current status

http://www.sql-server-performance.com/articles/per/history_status_table_performance_p2.aspx

What if, since they should be inserted in order of time, we just did a MAX(id)?

Tuesday, September 25, 2007

javascript undefined and strict comparators

Use === and !=== when you want to compare types as well. Otherwise you can get things like "" == 0 evaluating to true.

There is a difference between a variable being undefined and null. Use if(someObject) since it should evaluate both undefined and null to false.

from http://weblogs.asp.net/bleroy/archive/2005/02/15/Three-common-mistakes-in-JavaScript-_2F00_-EcmaScript.aspx

You can't overload a function.
Developers who are used to languages like Java and C# overload methods all the time. Well, in JavaScript, there are no overloads, and if you try to define one, you won't even get an error. The interpreter will just pick the latest-defined version of the function and call it. The earlier versions will just be ignored.

Undeclared variables are global.
Always, always declare your variables using the var keyword. If you don't, your variable is global. So anyone who makes the same mistake as you (or more likely, if you do the same mistake in two different places) will create nice conflicts which give rise to very difficult-to-track bugs. Even loop counters should be properly declared.

There is actually a good way to do some basic sanity checks on your script files (like multiple declarations, forgotten declarations, unassigned variables, etc.): in Firefox, go to the about:config url and look for the javascript.options.strict entry.

from http://joeyjavascript.com/2007/04/25/javascript-difference-between-null-and-undefined/

n JavaScript, undefined means a variable has been declared but has not yet been assigned a value, such as:

var TestVar;
alert(TestVar); //shows undefined
alert(typeof TestVar); //shows undefined

null is an assignment value. It can be assigned to a variable as a representation of no value:

var TestVar = null;
alert(TestVar); //shows null
alert(typeof TestVar); //shows object

From the preceding examples, it is clear that undefined and null are two distinct types: undefined is a type itself (undefined) while null is an object.

Unassigned variables are initialized by JavaScript with a default value of undefined.

JavaScript never sets a value to null. That must be done programmatically. As such, null can be a useful debugging tool. If a variable is null, it was set in the program, not by JavaScript.

null values are evaluated as follows when used in these contexts:

Boolean: false
Numeric: 0
String: “null”

undefined values are evaluated as follows when used in these contexts:

Boolean: false
Numeric: NaN
String: “undefined”