tag:blogger.com,1999:blog-64939895319425697142024-03-13T21:33:39.570-07:00All your code are belong to usbyargerhttp://www.blogger.com/profile/17771995461564679619noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-6493989531942569714.post-34529643657504994372010-10-05T10:59:00.000-07:002010-10-05T11:04:38.375-07:00My thoughts on JavaOne 2010<span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 17px; "><p style="font-size: 10pt; line-height: 13pt; color: rgb(0, 0, 0); font-weight: normal; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">I got the privilege of attending <span class="blsp-spelling-error" id="SPELLING_ERROR_0">JavaOne</span> 2010, and here are some of the highlights of the technical sessions I attended. These are mostly either sessions to try to catch later, or frameworks that I'd like to give a good look to put in our technical stack.</p><h3 style="line-height: normal; font-weight: bold; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 15pt; margin-top: 28px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; color: rgb(0, 51, 102); "><a name="JavaOne2010-TimetoImprove%3AJSR310DateandTimeAPIStevenColbourne"></a>Time to Improve: <span class="blsp-spelling-error" id="SPELLING_ERROR_1">JSR</span> 310 Date and Time <span class="blsp-spelling-error" id="SPELLING_ERROR_2">API</span> - Steven <span class="blsp-spelling-error" id="SPELLING_ERROR_3">Colbourne</span></h3><p style="font-size: 10pt; line-height: 13pt; color: rgb(0, 0, 0); font-weight: normal; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">This session was both a look at <span class="blsp-spelling-error" id="SPELLING_ERROR_4">JSR</span> 310 (which Steven expects to be in <span class="blsp-spelling-error" id="SPELLING_ERROR_5">JDK</span>8 at this point) and a look a <span class="blsp-spelling-error" id="SPELLING_ERROR_6">joda</span>-time as a solution for "today". He went over the design decisions made, how most of his classes are immutable and why, and how some things in <span class="blsp-spelling-error" id="SPELLING_ERROR_7">joda</span>-time are not flexible and how they're fixing that in <span class="blsp-spelling-error" id="SPELLING_ERROR_8">JSR</span>310. Overall most of the flexibility not allowed by <span class="blsp-spelling-error" id="SPELLING_ERROR_9">joda</span>-time is for special cases and not likely to be needed by most people. They are building lots of flexibility into <span class="blsp-spelling-error" id="SPELLING_ERROR_10">JSR</span>310, but always providing sensible defaults.</p><p style="font-size: 10pt; line-height: 13pt; color: rgb(0, 0, 0); font-weight: normal; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">My takeaway from this was something that I already knew, but haven't got around to doing. Start using <span class="blsp-spelling-error" id="SPELLING_ERROR_11">joda</span>-time and look forward to a <span class="blsp-spelling-error" id="SPELLING_ERROR_12">JDK</span> where java.util.Date and java.util.Calendar are no longer the preferred way of handling date/times (although according to Steven they won't be deprecated because Oracle says not to).</p><h3 style="line-height: normal; font-weight: bold; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 15pt; margin-top: 28px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; color: rgb(0, 51, 102); "><a name="JavaOne2010-FunkyJava%2CObjectiveScalaDickWall"></a>Funky Java, Objective <span class="blsp-spelling-error" id="SPELLING_ERROR_13">Scala</span> - Dick Wall</h3><p style="font-size: 10pt; line-height: 13pt; color: rgb(0, 0, 0); font-weight: normal; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Besides being a Java Posse <span class="blsp-spelling-error" id="SPELLING_ERROR_14">fanboy</span>, I wanted to go to this talk to see some <span class="blsp-spelling-error" id="SPELLING_ERROR_15">scala</span> and see what he had to say about adding some functional aspects to java code. Overall the talk was a little too much about the domain (genetics) and not enough code. But, the one takeaway I got from this is google collections (now called guava) is something we need to start using, and there are not only a bunch of nice new collections, but also some nice functional additions to working with collections (Predicates, Functions, etc). And of course at the end of this talk he reduced the 20 lines of java code down to 1 line of <span class="blsp-spelling-error" id="SPELLING_ERROR_16">scala</span> - but he cheated a bit by in-lining a bunch of calls on the <span class="blsp-spelling-error" id="SPELLING_ERROR_17">scala</span> side.</p><h3 style="line-height: normal; font-weight: bold; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 15pt; margin-top: 28px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; color: rgb(0, 51, 102); "><a name="JavaOne2010-Clojure%E2%80%99sApproachtoIdentity%2CState%2CandConcurrencyRichHickey"></a><span class="blsp-spelling-error" id="SPELLING_ERROR_18">Clojure</span>’s Approach to Identity, State, and Concurrency - Rich Hickey</h3><p style="font-size: 10pt; line-height: 13pt; color: rgb(0, 0, 0); font-weight: normal; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">This was my favorite talk of the week. I knew almost nothing of <span class="blsp-spelling-error" id="SPELLING_ERROR_19">clojure</span> going in, and still now about the same amount. But, what I really liked was Rich's definition of state, how he defined it in terms of values (immutable) and a point in time. Once you go down that path you see how you never can safely define state in a language like java once you accept that you can't stop time effectively. Given this premise, he went on to talk about how state is handled in <span class="blsp-spelling-error" id="SPELLING_ERROR_20">clojure</span>, which is a very functional, lisp-like language running on the <span class="blsp-spelling-error" id="SPELLING_ERROR_21">JVM</span>. He went over several approaches used in <span class="blsp-spelling-error" id="SPELLING_ERROR_22">clojure</span>: <span class="blsp-spelling-error" id="SPELLING_ERROR_23">STM</span> (software transactional memory), references, and agents. All were different in their semantics, but had a similar looking <span class="blsp-spelling-error" id="SPELLING_ERROR_24">API</span> (shape of <span class="blsp-spelling-error" id="SPELLING_ERROR_25">API</span>) so they can be exchanged very quickly without much change to the <span class="blsp-spelling-error" id="SPELLING_ERROR_26">callee</span>. Overall I thought this talk was great just because it made me think about things in a way I've never thought about them in a programming sense. I highly recommend you watch/listen to this talk if it becomes <span class="blsp-spelling-corrected" id="SPELLING_ERROR_27">available</span> - I would guess Rich does it at several conferences if the <span class="blsp-spelling-error" id="SPELLING_ERROR_28">javaone</span> talk doesn't become available.</p><h3 style="line-height: normal; font-weight: bold; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 15pt; margin-top: 28px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; color: rgb(0, 51, 102); "><a name="JavaOne2010-BeanValidation%3ABestPracticesforRealLifeEmmanuelBernard"></a>Bean Validation: Best Practices for Real Life - Emmanuel Bernard</h3><p style="font-size: 10pt; line-height: 13pt; color: rgb(0, 0, 0); font-weight: normal; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">This was a mostly overview talk about beans validation, which is now standard in <span class="blsp-spelling-error" id="SPELLING_ERROR_29">EE</span>6 I think. He showed lots of examples of how to define validation in both annotations and XML. There were good examples here, and I think it's something worth looking into. I'd like to follow up and see if <span class="blsp-spelling-error" id="SPELLING_ERROR_30">anyone's</span> done a beans validation to <span class="blsp-spelling-error" id="SPELLING_ERROR_31">jquery</span> validation bridge, and if not, perhaps look into doing something at least with <span class="blsp-spelling-error" id="SPELLING_ERROR_32">freemarker</span> templates to get that done. It'd be real nice to define validation in a single place and get it on the client, server, <span class="blsp-spelling-error" id="SPELLING_ERROR_33">JPA</span>, etc all with the same set of rules. He showed how you can define groups and only run a subset if that makes sense (like for client side validation if there are some rules that aren't practical there...). This is another framework I need to look seriously at - even if it's not available on the client side in <span class="blsp-spelling-error" id="SPELLING_ERROR_34">jQuery</span>/<span class="blsp-spelling-error" id="SPELLING_ERROR_35">dojo</span>. I could still remove a bunch of java code and make those rules more declarative.</p><h3 style="line-height: normal; font-weight: bold; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 15pt; margin-top: 28px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; color: rgb(0, 51, 102); "><a name="JavaOne2010-JUnitKungFu%3AGettingMoreOutofYourUnitTestsJohnSmart"></a><span class="blsp-spelling-error" id="SPELLING_ERROR_36">JUnit</span> <span class="blsp-spelling-error" id="SPELLING_ERROR_37">Kung</span> <span class="blsp-spelling-error" id="SPELLING_ERROR_38">Fu</span>: Getting More Out of Your Unit Tests - John Smart</h3><p style="font-size: 10pt; line-height: 13pt; color: rgb(0, 0, 0); font-weight: normal; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">This talk had two interesting things to add to the quality of your unit tests. One, naming them using "Should", and test the intent of the code. Don't test the implementation, test the intent. So in his examples his test class was named "<span class="blsp-spelling-error" id="SPELLING_ERROR_39">WhenYouCreateACell</span>" and a test method was "<span class="blsp-spelling-error" id="SPELLING_ERROR_40">aDeadCellShouldBePrintedAsADot</span>" (testing the game of life). This way they read nice in reports, but you also force yourself not to think about testing the lines of code in the method under test, but instead testing some intent of your method. He also talked about using the AAA approach to unit testing: Arrange, Act, Assert. In this you always first setup your needed environment for the test (maybe mocking what you need to), do the action under test, and then have a SINGLE assertion. He talked about issues with multiple asserts at the end of test methods, and broke into a discussion about the library <span class="blsp-spelling-error" id="SPELLING_ERROR_41">Hamcrest</span> to improve assertions and string them together in a fluent <span class="blsp-spelling-error" id="SPELLING_ERROR_42">API</span>. The other interesting part of this talk was his examples of <span class="blsp-spelling-corrected" id="SPELLING_ERROR_43">parametrized</span> tests with <span class="blsp-spelling-error" id="SPELLING_ERROR_44">junit</span> 4.8.1. In these types of tests you can provide a matrix of data and have <span class="blsp-spelling-error" id="SPELLING_ERROR_45">junit</span> run through a single test method with all the data very quickly. He showed how to use this with <span class="blsp-spelling-error" id="SPELLING_ERROR_46">XLS</span> data, but then also how to apply it to selenium tests which was interesting.</p><p style="font-size: 10pt; line-height: 13pt; color: rgb(0, 0, 0); font-weight: normal; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">So those were my highlights of the conference, and things I left wanting to investigate more. If you can get a hold of any of the above talks, I'd recommend watching/listening to them. I went to quite a few other talks, but these were my favorites.</p></span>byargerhttp://www.blogger.com/profile/17771995461564679619noreply@blogger.com0tag:blogger.com,1999:blog-6493989531942569714.post-6957979873317353782008-11-11T15:39:00.001-08:002008-11-11T15:45:41.166-08:00Exchange android appI got a Tmobile G1 last weekend, and the only thing that I thought it was missing was an app to get my work email through exchange. Sure, you can use the web browser to do it, but it kind of sucks.<div><br /></div><div>So, I started looking into OWA and what is available from an API/protocol level and it supports WebDAV. After a long weekend of playing with it, I had a working (although quite simple) little android app to pull down email from my exchange inbox.</div><div><br /></div><div>There are lots of things is doesn't support yet, that would be nice:</div><div><br /></div><div>* folders other than the inbox</div><div>* dealing with a large number of messages in a folder</div><div>* background syncing</div><div>* calendar/contacts, etc</div><div>* sending mail</div><div>....</div><div><br /></div><div>But, it's a good start and will likely get me by until <a href="http://www.aardvarkforandroid.com/">someone </a>writes a real exchange app. I might work on folder support, but I tend to use a single folder just to archive email on exchange, and I'm not sure how well my code is going to work if I try to pull up a several thousand email folder. That might be a lot of work for something that I'm not likely to use much.</div><div><br /></div><div>I did open source the code, and give it a <a href="http://code.google.com/p/exchangeit/">home </a>over on google code hosting, if anyone would like to join in and make it better, that'd be great! I just paid my registration on the android Market, and I'll probably publish it tonight after I make sure it's all packaged up and signed.</div><div><br /></div>byargerhttp://www.blogger.com/profile/17771995461564679619noreply@blogger.com4tag:blogger.com,1999:blog-6493989531942569714.post-85840241973321051812008-11-11T15:08:00.000-08:002008-11-11T15:13:44.652-08:00PeopleSoft Hash Function<div>This cost me several hours last night, so I want to get it down somewhere that perhaps might save someone else some time in the future. If you are integrating to PeopleSoft (like say, from Java) and need to use it as an authentication store, it uses SHA-1 to hash it's passwords (the ones in PSOPRDEFN), but the trick is you have to use the "UTF-16LE" charset when converting your clear text password to a byte array for passing to the MessageDigest.update() method.</div><br /><div>After that it works just like you would expect it to. I couldn't find that answer anywhere, although I did find several references to it using SHA-1, my hash using UTF-8 or US_ASCII came up wrong. Finally I just decided to try all the available charsets, and voila! it worked.</div>byargerhttp://www.blogger.com/profile/17771995461564679619noreply@blogger.com2