tirsdag 24. mai 2011

Meetup om testing i Framsia

Det handler om å kjøre (all) koden din, så ofte som mulig, med så gode tilbakemeldinger som mulig.

Buster.js ble presentert.

OperaDriver og ChromeDriver kommer sannsynligvis til Selenium 2 beta 4

Mange tester for html5 er skrevet i WebDriver

onsdag 18. mai 2011

Doing SW Architecture / Research Project

When researching a new tool or a framework API for use I find myself getting tired or bored after spending time doing work that will not be directly productive, and previously I have made rush decisions or didn't "go all the way", thinking that "barely sufficient" = enough.

The other day, I started thinking that different ways of revisiting such projects should add real value. preferably, there should be (at least) 1 more person with a fresh attitude who can continue from where I left, and/or do:

  • review / inspection
  • come up with new ideas
  • bring more involvement / acceptance from the whole group

If it is too hard to get 1 more person, it may be wise to simulate him by taking a break from this project and revisiting it later.

 

fredag 1. april 2011

SiteMesh

SiteMesh

From OpenSymphony.

Code can be downloaded here.

 

Overview

Web-page layout and decoration.

Aids generating consistent look/feel, navigation and layout scheme.

Can include other pages (server-side include).

J2EE, but can be used outside as well (PHP, CGI...).

Extensible.

 

 

Setting up

 

pom.xml:

<dependency>

<groupId>opensymphony</groupId>

<artifactId>sitemesh</artifactId>

<version>2.4.2</version>

</dependency>

web.xml:

<filter>

<filter-name>sitemesh</filter-name>

<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>

</filter>

<filter-mapping>

<filter-name>sitemesh</filter-name>

<url-pattern>*.jsp</url-pattern>

</filter-mapping>

<filter-mapping>

<filter-name>sitemesh</filter-name>

<url-pattern>*.do</url-pattern>

</filter-mapping>

<jsp-config>

<taglib>

<taglib-uri>sitemesh-page</taglib-uri>

<taglib-location>/WEB-INF/sitemesh-page.tld</taglib-location>

</taglib>

<taglib>

<taglib-uri>sitemesh-decorator</taglib-uri>

<taglib-location>/WEB-INF/sitemesh-decorator.tld</taglib-location>

</taglib>

</jsp-config>

Copy in mentioned files (tld)

decorators.xml:

<decoratorsdefaultdir="/decorators">

<decorator name="main" page="main.jsp">

<pattern>*</pattern>

</decorator>

 

<decorator name="printable" page="printable.jsp"/>

</decorators>

 

Default logic to determine what decorator to apply, first match:

  1. Meta decorator tag in page
  2. Don't apply a decorator to frame set
  3. Url with printable=true parameter (If so, use the printable decorator.)
  4. Does the page specifically request a decorator by the decorator file name?
  5. Does the page url match a pattern in the decorators.xml file?

Can be overridden.

Decorator example

<%@taglib uri="sitemesh-decorator" prefix="decorator"%>

 

<decorator:usePageid="myPage"/>

<html>

<head>

<title>SiteMesh main - <decorator:title default="Welcome!"/></title>

 

<decorator:head/>

</head>

 

<body>

<h1>SiteMesh main <decorator:title default="Welcome!"/></h1>

<h3><a

href="mailto:<decorator:getProperty property="meta.author"

default="staff@example.com"/>">

<decorator:getProperty property="meta.author"

default="staff@example.com"/>

</a>

</h3>

<hr/>

 

<decorator:body/>

 

<p><small> (<a href="?printable=true">printable version</a>)</small></p>

</body>

</html>

torsdag 10. juni 2010

BluKbapp

Bluetooth keyboard

Plan

Details in ReadMe file.

Maybe also (books code):

User-Space Java Bluetooth (JSR-82) Keyboard Driver.

BlueCove

JSR-82 implementation on Java Standard Edition (J2SE). I had some problems making it work on Mac OSX 10.6, but this seems to be fixed by a beta version 2.1.1-SNAPSHOT (cf. BlueCove does not work with Mac OS 10.5.x, Java 1.6.0 - 64 Bit).

To get tester running I had to use 32-bit mode from command-line:

  • java -jar bluecove-tester-app.jar -cp bluecove-2.1.1-SNAPSHOT.jar -d32

 

Research

Put in deli tag bluekey.

Java bluetooth home.

jsr82.com.

Palo Wireless has som l2cap details.

torsdag 26. november 2009

Scala - learning notes

Plan

Do it standing, about same mix of slides and coding as before, handouts.

Slide: Tom Waits + install
Slide/Code: fire up scala and show off syntax (REPL)
Slide: motivation
Slide: My verdict + References
Slide/Code: Bonus section

Presentation

“Your hands are like dogs, going to the same places they’ve been. You have to be careful when playing is no longer in the mind but in the fingers, going to happy places. You have to break them of their habits or you don’t explore; you only play what is confident and pleasing. I’m learning to break those habits by playing instruments I know absolutely nothing about, like a bassoon or a waterphone.”—Tom Waits

(Picture from flickr / Conor Lawless).

Install

Download zip-file, unzip, set SCALA_HOME and add to PATH.
Then: install plugins for NetBeans (6.7+, prefer 6.8) and eclipse (3.5+).
I did best letting NetBeans handle project (not Maven).

Syntax / REPL

scala.bat: Quick Read Evaluate Print Loop



































Code Points
to make

class PhoneNumber( val kind: String, var no: String ) {

override def toString(): String = {
no + " (" + kind + ")"
}
}

switch to name: type

val / var / def

primary constructor

Concise

object PhoneNumber{

def apply( kind: String, no: String ) : PhoneNumber = {
new PhoneNumber( kind, no )
}
}

object, no statics

apply is "default method"

val phonebook = Map(

"Tommy mobil" -> PhoneNumber( "cell", "92012201" ),
"ICE Medisinsk" -> PhoneNumber( "work", "113" )
)

Expressive
println( phonebook("Tommy mobil" ).no ) Concise
phonebook.foreach(tuple => println( tuple._1 + ":" + tuple._2 )) High-level

functional iteration
1.1.+(2.2)

1 until 10
Pure OO

operator mode for methods

val xmlE = <a href="index.html"> {3 + 4} </a>

(xmlE \ "@href").text

Pragmatic

.

Motivation

Evolution, not revolution: Java-like, interoperates with java (seamlessly).
  • can extend java classes
  • can implement java interfaces
  • understands java generics
  • uses java primitives
Leads you into functional programming.
Easy to do easy stuff, AND facilitates the hard stuff.
More up2date language - builds on java lessons, adds:
  • Facilitates DSL with several short-hand notations
  • Traits (~multiple inheritance)
  • ++
One vision (Martin Odersky), not designed by comitee
Pragmatic



"I can honestly say if someone had shown me the Programming Scala book by by Martin Odersky, Lex Spoon & Bill Venners back in 2003 I’d probably have never created Groovy." — James Strachan

"If I were to pick a language to use today other than java, it would be Scala" — James Gosling (from before he left Oracle)

My verdict: lead me into...

Wonderful way of coming from Java to Functional programming. I started out writing java-like OO, but wolfed out by the end of my second 3-hour session.
The book fuelled this transformation.
Scala feels very good so far, I now like Java less...

References

Scala site.

Book "Programming in Scala" (Odersky++) is very good for learning, not so for reference.

The busy Java developer's guide to Scala: articles on DeveloperWorks

From JavaZone 09:

Bonus section

Start with Java Discovery and refactor a suitable class:
  • common.ServiceDescription (for properties and basics) NB! keep scala-code for equals / canEqual
Show off in code
Code Points to make
TestServer object and main
client.v2.Notifier operators
client.ServiceBrowser:
  • class extends with
  • tryto
  • getReplyDescriptor
traits
Function is first-class object
Option + match
sclanb.Main.recurse2 Closures, and how crazy I got
sclanb.Main
client.ServiceBrowserListener abstract, no interface
FirstSwingApp. DSL, Swing
Code from ch30 Actors