Meeting 4

Aus Java Student User Group Austria - Java + JVM in Wien Österreich / Vienna Austria
Wechseln zu: Navigation, Suche

When: Monday, July 7th, 2008 - 19:00

Where: Freihaus HS4


Maven Reloaded

Maven Logo

Download the slides (pdf, 1,26 MB).
You can also view the slides online.

Preface

Building Software, small artifacts - big projects. A presentation by Florian Motlik. He compares the traditional build process (using batchfiles, shellscripts, make or ant) with Maven's approach. But its not only a build tool, its a dependency management tool, its a documentation tool, its even a project management tool and much more!

Content

Features

  • Convention over Configuration; obey -your- standards
  • Declarative project object model (pom.xml)
  • Declare dependencies (manage transitive dependencies)
  • Store dependant libraries in central repository
  • Versioning made easy
  • Multi-module builds (each project creates only a single artifact)
  • Archetypes provide a unified project structure
  • Build lifecycle phases (compile, test, package, install, deploy; and many more)
  • And many many many plugins which extends Maven's functionality

Report

You can easily generate a HTML report via executing the single command mvn site. This website includes:

  • CPD report ... duplicate code detection
  • PMD report ... verification of coding rules
  • JavaDocs ... JavaDoc API documentation
  • Surefire report ... report on the test result of the project
  • Cobertura/Clover report ... test coverage of unit tests
  • Source Xref ... HTML based, cross-reference version of source code
  • Tag List ... report on various task tags found in the code

Links

Scala Lightning Talk

Scala Logo

Download the slides (pdf, 115 KB).
You can also view the slides online.

Preface

The second presentation was also conducted by Michael Greifeneder. He talked about Scala, yet another language running on the JVM. It provides both OOP and FOP features (pattern matching, high order functions, parametric polymorphism, operator overloading, closures), unifying the power of two worlds it makes programming a lot of more fun.

Content

  • Its fully compatible to Java (reuse of existing libraries)
  • Its static typed (performance)
  • Its perfect for DSLs (domain specific languages)
  • Its shorter than Java (no need of semicolon or curly braces)
  • It provieds matching expressions

A -more or less- simple example: <source lang="scala"> abstract class SomethingWithName(name:String) {

override def toString():String = name
def does(what:(SomethingWithName)=>unit) {
   what(this);
 }

}

case class Person(name:String) extends SomethingWithName(name:String) {

 def says(msg: String) = {
   print(name + " says " + msg)
 }
 def apply(name:String):Person = new Person(name)

}

case class Stone(name:String) extends SomethingWithName (name:String) {

 def apply(name:String):Bagger = new Bagger(name)

}

def swimming(who:SomethingWithName) = who match {

 case Person(name)=>print("Swims in pool: " + name)
 case Stone(name)=>print("On the ground: " + name)

}

var Tom = Person("Tom") var YellowStone = Stone("YellowStone") Tom says "Hello" Tom does swimming //Tom.does(swimming) YellowStone does swimming; </source>


When executed, the preceding code generates following output:

$ scala dsl.scala
Tom says Hello
Swimming in pool: Tom
On the ground: YellowBagger


Following example shows the usage of closures with Scala: <source lang="scala"> Tom does ((in:SomethingWithName) => { print("Who needs closures? Maybe " + in + "?") }) // prints: "Who needs closures? Maybe Tom?"

// also nice: args.foreach(arg => println(arg))

// or even shorter: args.forach(println) </source>


Using maps becomes very ease (compared to Java): <source lang="scala"> val map = Map(

 "Austria" -> "Vienna",
 "Germany" -> "Berlin",
 "Switzerland" -> "Bern"

) println(map("Austria")) </source>


Example of a matching expression: <source lang="scala"> val friend = args(0) match {

 case "salt" => "pepper"
 case "chips" => "salsa"
 case "eggs" => "bacon"
 case _ => "huh?"

} </source>


Use the wellknown exception mechanism: <source lang="scala"> try {

 doSomething()

} catch {

 case ex: IOException => println("Oops!")
 case ex: NullPointerException => println("Oops!!!")

} </source>