ajax paradigm is imperfect

based on http://en.wikipedia.org/wiki/Rich_Internet_application

Ajax has recently been used most prominently by Google for projects such as Gmail and Google Maps. However, creating a large application in this framework is very difficult (echoed by the “lunch interviewer” in Google), as many different technologies must interact to make it work, and browser compatibility requires a lot of effort. In order to make the process easier, several open source Ajax Frameworks have been developed, as well as commercial frameworks.

Ajax complicates software testing activities. These complications lengthen the software development process.

perl one-liners for xml

based on http://www.xml.com/pub/a/2002/04/17/perl-xml.html.

Find all section titles in a DocBook XML:

# cat files/mybook.xml | xpath //section/title

Retrieve just the significant text (not including nodes containing all-whitespace) from a given document:

# cat files/mybook.xml | xpath “//text()[string-length(normalize-space(.)) > 0 ]”

Save the entire data stored in the ‘users’ table as a huge file users.xml:

# sql2xml.pl -sn myserver -driver Oracle -uid user -pwd seekrit -table user -output users.xml

Pretty-print a bad xml file:

# cat overwrought.xml | xmlpretty > new.xml

Use the built-in HTML parser to convert ill-formed HTML to XML before further processing:

# xmllint –html khampton_perl_xml_17.html | xpath “//a[@href]”

AND MORE….

parallel source tree junit #open q

See http://junit.sourceforge.net/doc/faq/faq.htm#organize_1

keyword: junit
keyword: default “package” access — such members would be testable

src.com.verizon.myClass.java
test.com.verizon.myClassTest.java
util.com.verizon.myUtil.java
old.com.verizon.oldVersionMyClass.java

Q: If they all have “package com.verizon;”, would jvm see them in the same package?

Q: in a distributable jar, would they go into a merged /com/verizon directory?

%%struts quiz

brief points? ok
j4: keep for review in 2 years

[g=generic servlet/jsp issue]
[i=interview]

  1. [i] error-handling is relatively simple but imp2iview. What kind of entities read ActionErrors and how are they used? views?
  2. ActionForward ^ ActionForwards ? P 113
  3. where does Struts use reflection and introspection? P 114
  4. do you need to manage sessions or struts does it for you?
  5. [i] what kind of data structure to hold multiple errors in ActionErrors (No need to be exact) ?
  6. how2get an afbean from a mapping object? Is the afbean “contained” (HAS-A) in the mapping obj? I think when the afbean object exists in JVM, the mapping obj provides a path to it.
  7. [gi] when does a session start and in which method? probably by ActionServlet
  8. [i] signature and usage of findForward()? defined in which class? P 741 [[ ?? ]]
  9. [gi] is ActionServlet a singleton?
  10. which object invokes the afbean’s validate()?
  11. how does execute() retrieve the afbean? from the argugment mapping obj or from the request argument?
  12. how2get formbean from req? when ? when req is forwarded to a non-struts servlet or another struts servlet?
  13. [i] which method(s) return ActionErrors (see the trailing s), following which well known design pattern?
  14. let’s zoom into Struts’ usage of dataSource class in standard java. which struts components interact with a datasource?
  15. [g] is ActionServlet a single-threaded servlet, and need many sisters to service simultaneous requests?
  16. [gi] How is ActionServlet thread-safe?
  17. session in struts is same as session in other servlets?
  18. <action input=…. means?
  19. <action name=…. means?
  20. struts connection pooling? no answer
  21. beside global forward and local forward, there’a 3rd way to DEFINE an afward. P189
  22. which validator xml file contains the javascript function? What’s the other major content in the samel xml? name of a method?
  23. controls the (non-validator) validate() method u create in your afbean, but what if u use validator?
  24. 1 basic use of var in validator.xml? p378
  25. #1 most basic validator in the validator package? how do u configure it in validator-rules.xml? p375
  26. aforward obj is returned by which method to whom? How is it used?
  27. [gi] in which method do u do jdbc connect? perhaps a M object not defined by struts
  28. why execute() need the map? local forwards?
  29. g how does a non-struts servlet retrieve afbean from the request (received by forward)? P221
  30. Without struts-validator, what page is returned to browser upon validation error? How do u make this takes place by configuration?
  31. biggest 2 struts extensions each can be used outside struts, and each defines its taglib. What’re the 2 tag prefixes?
  32. what return type do u use with a formbean getAmount() ? P155
  33. simple yet important AR question: which obj calls execute()? P 741
  34. where 2 spell out a regex? how 2 pass it into a validator
  35. can take one of 3 { include, forward, ???? } I think it’s type
  36. ignore validator for now. afbean usually defines an public instance method validate(). what’s the signature? revealing! P740
  37. [i] simple yet tricky question: exactly which object (loaded into the servlet container) acts as the router, inspecting and dispatching requests to other objects?
  38. signature of execute(). AR-revealing
  39. [gi] how does the query result get into the view? aforward? req obj? P 741 [[servlet]]
  40. [i] which obj auto-populates a formbean? ActionServlet?
  41. where is the Model object instantiated? P 741 [[ servlet ]]
  42. is the mysterious but important ActionServlet (full class name) mentioned in any prominent place? Hint: along with struts-config.xml. P 743 [[servlet]]
  43. during request processing flow, describe when the mapping object is loaded and how it controls each module such as form population/valiation, forward, custom action etc. P47.
  44. example of httpSession in struts? P79


migrate between jsp & php

Hi LS,
Ideas for the migration, if migration is on your mind.
Inside or outside the database,
* squeeze as much business rules into DB as possible. Unique constraints, referential integrity (triggers), check constraints, input validation constraints for insert/update/delete, not-null constraints, stored proc, triggers, user-defined functions …
* Without an enormous effort, you can move every single SQL out of java/php/asp source and into some (xml) “query-listing” file. Every SQL sent to the DB will be taken from this listing. Performance penalty can be managed with some kind of simple caching, which I think can be quite effective.

* Many if not most jsp projects encourage a DAO pattern, sometimes quite elaborate or sophisticated. PHP supports DAO patten in PEAR::DB, albeit lightly. It helps your migration. However, small PHP sites may not warrant the extra effort

* Avoid Object-Relational-Mapping tools such as Hibernate or iBatis, since PHP isn’t comfortable with ORM yet.

With regard to so-called “presentation layer” or page templates
* smarty and JSP-EL/JSTL are highly recommended. They are simple and straight-forward. With them you can create templates free of business logic. The only “programming” remnants left in the template are simple variables, and the simplest loops and if-then-else — all easy stuff to migrate between jsp and php.
* squeeze as much business logic into javascript as possible. Over the years, more and more functionalities have become transferrable from server-side to javascript
* Not sure if AJAX is necessary for your site. AJAX requires you to create special server-side components. The browser-side ajax function communicates with the server-side components. Server-side components are coded in php or java or asp.
Lastly, we finally turn our attention to the jsp/php files. Even with the DB/presentation layer hacks, some, perhaps the bulk, of the functionality may remain in your java/php source code. You need to think of server-side software design ideas that are transferrable between jsp/php/asp. Many things to consider. Here are A few trivial items.
* avoid servlet/jsp forward. I don’t think php supports it.
* PHP guys tend to put a few related functionalities into one php file, motivated by maintainability, readability and other reasons, whereas jsp/servlet tends to separate them into individual jsp files (even separate javabean/servlet classes). The java approach is viable in PHP too, and helps migration.
* If you need automated testing, consider black-box test tools. These are transferrable and agnostic to the server-side language, be it jsp or asp or whatever

sum(field_with_all_null) == null

http://www.oracle.com/technology/oramag/oracle/05-jul/o45sql.html shows how aggregate functions react to empty sets ie “no entry except nulls”.

COUNT returns zero whereas AVG, SUM, MAX, and MIN return null.

If you have no values to count, it’s fair to say that you have zero values, whereas you can’t really come up with, say, a maximum value without at least one value from which to choose. We can make a reasonable argument that SUM should return zero instead of null, that the sum of no values is zero, but Oracle’s implementation of the behavior we describe here is fully compliant with the SQL standard.

Wall Street interviews cover 1% of java topics

Hi LS,
 
I said wall street asks only 1% of java topics so a java candidate need to know close to nothing about the other 99%. This is perhaps close to the truth but potentially misleading.
 
* I have 2 books [[ java threads ]] and [[ concurrent programming in java ]]. Wall street multithreading interview questions require 0.1% to 0.5% of the knowledge in them.
 
* If you look at the published java Collections API, again wall street java collections questions require less than 2% of that body of knowledge.
 
* Similar for servlet/jsp, sql joins, and garbage collection.
 
However, 1% still requires months of focused study. I'm still weak in design patterns, GC and SQL tuning
 
tan bin

TreeSet won’t keep insertion order

When you see tree*, think of “sorted”. In java, Tree* includes TreeSet, TreeMap…

I believe all tree constructs (in computer science) are sorted.

A collection (set or list or queue …) are physically stored in one order only [1]. The physical storage order can only follow one of the following:
* sorted
* insertion-order maintained
* parent-child relationship
* etc

It’s now obvious that Tree* constructs don’t keep insertion order.

[1] Same as Clustered Index