Thursday, June 08, 2006

Trying to get added to technorati

More blogs about java101.

Tuesday, June 06, 2006

Week of 06-02-2006

I am currently involved in the development of a portal project using IBM websphere portal. The project involves integration of portal and documentum based publishing. It is surprising that there is no direct integration between the two products, something like what BEA portal and documentum has. Here one system has no idea about the other so we are writing glue code that integrates the two. We are providing customization around personalization, navigation, and content rendering.

Project will continue for few more weeks and this week was focussed on integrating the navigation feature. Authors will be publishing the content and associating the navigation with taxonomy files (represented as xml files) and our glue code will take that content and render it withing a portal page. Navigation glue code is in a custom portal theme which paints the left nav. Now I will be focussing on the different scenarios how the navigation should behave. There are several requirements where the entire tree will be displayed or display just the same level nodes and so on. Each level is denoted in the taxonomy file and there can be n-levels.

Continuous integration thoughts

I came across the continuos integration concept a while back and found the idea interesting. I have been developing j2ee applications for a while in teams of 1 to 15 people now and this seemed like an helpful process to deliver less buggy code in a well controlled environment. But I have looked at this concept at a very high level and hoping to dig a little deeper in future. What prompted me to blog was chance hit at Martin Flower's blog on the subject at : http://martinfowler.com/articles/continuousIntegration.html.

One of the issues that we have been facing is how to do unit testing of components that go out to external systems like database and web services. And this article sheds some light on what possible steps can be taken : http://martinfowler.com/articles/evodb.html

Need to start looking into this more seriously.


Sunday, June 04, 2006

Why not integrate design patterns directly into java language?

I have been doing java programming for over 5 years now and trying these days to understand the design patterns better especially the ones proposed by gang of four. The more I read these design patterns the more I feel that these patterns should have direct support in the java language (and for that matter any OO language). I mean think about this for a minute why not let the language evolve in the direction of best practises by building the same into it so that there is less and less scope for doing things wrong. I believe that if there are more than one way to do something and a particualr way is a design pattern or best practices than it should be directly built into the language as default and if someone wants to use some other way than he has to follow extra steps to do so. Today you have to follow extra steps to do the right thing.

I am hoping to post my thoughts on each pattern as I read more about it. Some initial thoughts are as follows. Take Observer design pattern, it is currently built into java which is good. The Singleton design pattern support is somewhat provided by java's static keyword but should be expanded so that it is not required to worry about doing those extra steps of making the constructor private and providing getInstance() method or front it by Factory pattern and so on.

test for tagworld widget

Wednesday, May 31, 2006

some c# stuff

I have been for sometime working on a .NET project where we are using c# to make web service calls and populate an excel sheet. I would be blogging my experience while working on this project as it relates to .net, c#, and vsto (excel mainly). I have mostly J2EE experience so this is a very interesing as well as challenging experience. I would also like to blog some cookie cutter code or just what I think is useful.

Some .net training notes

Below are some notes that I took while attending .NET training which is useful.

Casting
there is hard cast and soft cast, examples below

int x = (int) obj; //hard cast, so if obj is not of type int there will be class cast exception
int x = obj as int; //soft cast, in this case if obj is not of type int than x will be null

Boxing C# has a feature called boxing and unboxing which is basically copying value types from stack
to object on heap and vice versa. An example is below:

int x = 3;
Object obj = x; //boxing
int y = (int) obj; //un-boxing.

Second more subtle example below:

Console.WriteLine(" {0} ", 3); //boxing

Boxing from performance perspective is not good so best to avoid. So for the above
examples change as below.

int x = 3;
Object obj = x.ToString();
int y = int.Parse((string)obj);


Console.WriteLine(" {0} ", 3.ToString());


Use command line utility, ildasm, to check generated MSIL code if boxing code is generated.

ildasm <name of dll>


WMI -- windows management and instrumentation, can be used for performance analysis.

Inheritane
keywords: constructor chaining, virtual chain of methods, sealed classes,
marker interfaces (interface with no methods)

use "is" in C# is same as "instanceof" in java

in c# it is possible to hide methods of implemented interfaces by using interface
name for method declaration. So to use it you have to cast object to the specific
interface.

ADO
DataSet -- reads and remembers -- composed of DataTables. DataTables composed of
DataRows and DataColumns

DataReader -- just reads

DataSet uses DataReader to get the data.

For very small amount of data use DataReader to get the data and store in some
collection object like arraylist, etc instead of using DataSet.


With DataReader you have to explicity open/close connection but with
DataSet since you are using DataAdapter it will open/close connection
automatically.

best practices -- http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/adonetbest.asp


DataSets are typed and un-typed. If you have xml xchema (or can create one) than
DataSets can be created out of this schema. typed are faster and compiler checked.
Also, you are using GUI to auto generate DataSet code.

DataTables and DataSets can keep track of changes (diffgram).

Use Transaction objects if rollback is needed.


Config file
App.config is default, do not chnage the name. This file can be added to projects. Works only
for .exe and not for .dll

Web Services
proxies stand between client code and web service.
.asmx files represent web service in .net world.
.net has something similar to java annotations called "attributes" (just declare above method definition).
you can type the location of .asmx file in browser which can be used for testing.
.asmx?wsdl will return the wsdl file
wsdl.exe /l:CS /o:c:\testproxy.cs <wsdl-url> //will generate client proxy code, another way is to use webreference from IDE.
for webrefernce there is an option to update web service
for webservice proxy you can set credential, timeout, proxy, etc.

VSTO
to run .xls without running dll run the .xls by pressing shift key

if a solution has only execute permission (and not full trust) than web service call will fail.

PIO code is under c:\windows\assembly folder, format of the file name is Microsoft.Office.Interop.xxx

+= is used for event registration called delegation

-= is used for de-registration

if += is called 3 times and -= is called once than the registration of event is still ther, you would
need to call -= 2 more times to actually un-register.

dlls get downloaded in "documents and settings"...."application data" directory.

AssemblyInfo.cs has version number, [assembly: AssemblyVersion(" 1.0.*")], which is used for creating
different versions of the dll. this version gets referenced in c:\windows\assembly\download folder

to combine multipe ranges can use "union"

RecordSet in un-managed code is equivalent to DataSet in .net, there are apis to copy from one to another.

To add a windows form to excel, add a form and than from officecodebehind create an instance of
form.

Also, since windows form is built into .net no need to worry about registering events like
onclick, etc but for excel you have to worry.

When need to pass data from form to OfficeCodeBehind, it is possible to pass OfficeCodeBehind
to form class or other way around. Second approach is preferred where form class provides public
api to access data which is than called by OfficeCodeBehind.

Events
Delegates holds references to callback methods

delegates can be called asynchronously.

difference between ABO and ABO.NET

At a high level ABO.NET is an enhancement over ABO as it provides support for disconnected mode and is integrated with XML. Will make more enhancement to this blog as I learn more. One more note is that ABO.NET looks very similar to SDO (Service Data Object) in J2EE world.

Wednesday, March 08, 2006

JSF notes on event handling

Three different kinds of listeners:
  • Phase listener -- listener is invoked as jsf goes through each of the 6 phases, you can register for a specific phase or all of them.
  • Action listener -- listener is invoked when an action like command button is clicked.
  • Vlaue change listener -- listener is invoked when an input component like textbox value is entered and form submitted
There is subtle difference between the use of action handlers and action listeners, handlers are meant for business rules, iterfacging with backend systems, and
navigational logic whereas listeners are meant to handle with UI elements only.

Action listeners are invoked before action handlers.

Value change and action listeners can be added as UI element attibutes as well as tags. It is better to add as tags.

Below are the execution of different phases for different scenarios:
  • value change listener --> 1 -- 2 -- 3 (listener called) -- (4 -- 5 -- 6)
  • value change listener with immediate --> 1 -- 2 (listener called) -- 3 -- (4 -- 5 -- 6)
  • action listener --> 1 -- 2 -- 3 -- 4 -- 5 (listener called) -- (6)
  • action listener with immediate --> 1 -- 2 (listener called) -- (6)

JSF General Notes

Some notes from the core jsf servlets book.

  • value binding expressions, eg., "#{....}". property getter is invoked when the component is rendered and setter is invoked when when the user response is processed.
  • method binding expressions
  • JSF connects the view and model
  • each ui tag is associated with a tag handler. tag handlers collaborate with each other to build a component tree (not necessarily binary tree)
  • encoding is when the renderer of a component generated the output. eg., html output
  • decoding is when the html elements are processed by JSF container to do things like update component values, navigation, etc.
  • six life cycle steps: restore view, apply request values, process validations, update model values, invoke application, render response
  • action methods have 2 roles, first carry out the model updates and second tell the navigational handler where to go next
  • action method can return null to indicate that the same page should be redisplayed
  • all form controls (ui elements like textbox, etc) generated by JSF have names that conform to formName:componentName. if you do not specify id attributes, jsf framework creates automatically
  • DataTable : The body of h:dataTable tags can contain only h:column tags and all the other component tags are ignored.
  • DataTable: value attribute can be set to an array, List, ResultSet, javax.servlet.jsp.jstl.sql.Result, javax.faces.model.DataModel
  • DataTable: h:dataTable wraps objects in a model that extends the javax.faces.model.DataModel class which provides apis like getWrappedObject() and setWrappedObject() which can be used to add/remove table rows.
  • Conversion: this happens in the "apply request values" phase where the string values submitted as part of form is converted to appropriate objects.
  • Conversion:
  • <meta http-equiv="Refresh" content= "0; URL=index.faces"/>