Extreme Java G22.3033-006

Session 1 – Main Theme Introducing Extreme Java

Dr. Jean-Claude Franchitti

New York University Computer Science Department Courant Institute of Mathematical Sciences

Agenda

• Course Logistics, Structure and Objectives • Java Features • Java Environment Limitations • Upcoming Features in “Tiger” 1.5 • Model Driven Architectures for Java Systems • Java Enterprise Application Enabling • Agile Modeling & eXtreme Programming • Aspect-Oriented Programming & Refactoring • Java Application Performance Enhancement • Readings, Class Project, and Assignment #1a 2

1 Course Logistics

• Course Web Site • http://cs.nyu.edu/courses/spring03/G22.3033-006/index.htm • http://www.nyu.edu/classes/jcf/g22.3033-007/ • (Password: extjava) • Course Structure, Objectives, and References • See detailed syllabus on the course Web site under handouts • See ordered list of references on the course Web site • Textbooks • Mastering Java 2, J2SE 1.4 • J2EE: The Complete Reference • Expert One-on-One: J2EE Design and Development

3

Part I

Java Features

4

2 Java Features Review

• Language Categories • Imperative • Functional • Logic-based • Model-based PL Comparison Framework • Data Model • Behavioral Model • Event Model • Execution, Persistence, etc. • See Session 1 Handout on Java Review

5

J2SE 1.4 Features http://java.sun.com/j2se/1.4/index.html

6

3 J2SE 1.4 Features (continued) • HotSpot virtual machine • Full 64-bit support • Improved garbage collection • Ability to exploit multiprocessing • Optimization of the Java2D API • Classes/API Enhancements and Additions • Internationalization ( 3.0) • JDBC SPI to J2EE Connector architecture • Java.nio, java.util.regex, assertions, JAXP, java.util.properties, java.util.logging • J2SE 1.4.1 Enhancements • http://java.sun.com/j2se/1.4.1/changes.html 7

Java Environment Limitations

• No Support for Behavioral Reflection (BR) • Reification is the inverse of reflection (e.g., class loader) • Structural reflection reifies structural aspects of a program (inheritance/data type) • Behavioral reflection reifies computation and their behavior • http://www4.informatik.uni-erlangen.de/Projects/PM/Java/ (JX) • http://www4.informatik.uni-erlangen.de/TR/pdf/TR-I4-97-10.pdf • http://www.dcc.unicamp.br/~oliva/guarana/ • Limited Execution State Control • Hard to implement agent-based systems (e.g., IBM’s agglets project) • Limited Performance • See later slides •etc.

8

4 The JX Operating System http://www4.informatik.uni-erlangen.de/Projects/JX/

9

New Features in “Tiger” 1.5 http://www.jcp.org/en/jsr/detail?id=176

• Mantis 1.4.2 • Bug fixes and performance improvements •Tiger 1.5 • Generics, similar to templates in C++ • Autoboxing of primitives • Addresses some of the problems with casting • When value types need to be treated as objects, the JVM wraps them within a heap-allocated reference type using a process called boxing • Better support for constants • Programming shortcuts using import statements • Improvements for iterating over collections • Metadata either as a keyword addition or a javadoc feature

10

5 “Tiger” 1.5 Generics http://www.jcp.org/en/jsr/detail?id=176

• Generics feels like C++ Templates++: • Compile time checking • Apply on everything from classes to methods • Support constraints on generic arguments using a where clause •Example • interface IComparable { int CompareTo(T obj); }

class Dictionary: IDictionary where K: IComparable, V: IKeyProvider, V: IPersistable, V: new() { ... } 11

Part II

Software Architectures Engineering and Java Enterprise Application Enabling

12

6 Enterprise Foundations

• Enterprise Architecture Model • Business Architecture • Application Architecture • Technical Architecture • Object-Oriented Software Development • Iterative/Incremental Development Process • OO Concepts (modularity, encapsulation, abstraction, reuse) • Component-Based Software Development • Process paired with OO Development • Canned component models

13

Enterprise Architectures Enablers • User Interfacing • XHTML, XML, AWT, Swing, thinlets, etc. • Distributed Communications Enabling • TCP/IP, Java IDL, CORBA, RMI/IIOP, DCOM, etc. • Services for Distributed Communications • JNDI, CORBA Trading, JINI, JAF, JMS, JavaMail, JTA/JTS, JAAS/JCE/JSSE, etc. • Data Enabling • JDBC, SQLJ, EJB-QL, CMP/BMP, etc. • Systems Assurance • Security, Reliability, Availability, Maintainability, Safety • Web Enabling • Java Web Start, Servlets, JSP, XSP, etc. • Application Enabling • Web Services, EJB, EAI/B2Bi, JCA, JMX, Java XML Pack, JAXB, etc. 14

7 Software Development Infrastructure

• OO Development •UML • OOPLs (Java, C++, C#, Jython, etc.) • Component-Based Development • UML (patterns, frameworks), MOF, XMI • Web Services, Java Web Start, JavaBeans, CORBA, RMI/IIOP, DCOM, Java APIs (J2SE foundation classes), J2EE (Servlets, JSPs, EJBs), CORBAcomponents, COM+/DNA/.Net, etc. • JPDA (Java Platform Debugger Architecture)

15

Distributed Communications Enabling Underlying Protocols

•TCP/IP • Web/HTTP, SSL • XMLP, SOAP • CORBA/IIOP, GIOP, HTTP-NG •RMI/JRMP • RMI/IIOP •DCOM

16

8 Distributed Communications Enabling Core Common Services • Naming • DNS, JNDI • Directory • NIS, NDS, LDAP, Microsoft Active Directory • Trading • CORBA Trading Service, JINI • Activation • CORBA LifeCycle Service, Java Activation Framework • Messaging • JMS, JavaMail, CORBA Events/Messaging/Notification • Transaction • CORBA OTS, JTS, JTA • Security • JSSE, JCE, JAAS 17

Sample Enterprise Application Design

• See Sub-Topic 1 Presentation: • Best Practices in Technical Architectures for Fixed Income Market Participants

18

9 The first level of automation ~ 30 Years

(Platform independent to platform specific model projection)

Programming IDEs (e.g. JBuilder, Visual Age, NetBeans)

Environment •Higher level of expression PIM Programming Language •Easier to understand •Portable •Standardized

•Dependable Generator, •Flexible Projection Compiler Engine •Configurable •Optimizing •Complete: Linker, Debugger, Etc. PSM Diverse HW/OS Platforms 19

MDA= New automation levels ~ Last 8 Years http://www.omg.org/mda Architectural IDEs

Environment •Higher level of expression PIM Model (UML, BOM…) & •Easier to Modeling Style (J2EE, eEPC, COBOL, .NET…) understand •Portable •Standardized

•Dependable Generator, •Flexible Generator Engine Projection •Configurable •Debuggable •Optimizing Models to Code •Complete Models to Models

P-Stack: A Level of Automation PSM 20

10 Architectural IDEs http://www.io-software.com,

The Unified Process Std. MDA Projections

ArcStyler Core Modules J2EE/EJB, .NET

BEA WebLogic Open MDA/UML/XML Repository MDA Cartridges

Business Pattern UML MDA-Engine Build, IBM WAS NT, z/OS Object Refinement Refinement Engine Deploy & Test with Meta IDE Modeler Assistant Assistant Support Borland, JBoss Optional integrated Tools

IDS ARIS Rational Rose Programming IDE Oracle, IONA

Architect MDA-Cartridge IDE & MDA Engine Edition adds support for custom infrastructure

21

Part III

Mainstream Modeling and Programming Techniques

http://www.agilemodeling.com/essays/agileModelingXP.htm

22

11 eXtreme Programming (XP)

http://www.extremeprogramming.org/ • A lightweight software methodology • Few rules and practices or ones which are easy to follow • Emphasizes customer involvement and promotes team work • See XP’s rules and practices at http://www.extremeprogramming.org/rules.html

23

eXtreme Programming Project

24

12 XP Project Lifecycle

25

Agile Modeling & XP http://www.agilemodeling.com/, http://www.agilemodeling.com/resources.htm

• Practices-based software process whose scope is to describe how to model and document in an effective and “agile” manner • One goal is to address the issue of how to apply modeling techniques on software projects taking an agile approach such as: • eXtreme Programming (XP) • Dynamic Systems Development Method (DSDM) • SCRUM •etc. • Using modeling throughout the XP lifecycle • http://www.agilemodeling.com/essays/agileModelingXPLifecycle.htm

26

13 Aspect-Oriented Programming http://www2.parc.com/csl/projects/aop

• Technology for separation of concerns (SOC) in software development • AOSD makes it possible to modularize crosscutting aspects of a system such as • Design or architectural constraints • Systemic properties or behaviors (e.g., logging and error recovery) • Features •etc. 27

AspectJ

http://aspectj.org • A seamless aspect-oriented extension to Java • Enables the modular implementation of a wide range of crosscutting concerns • Compilers • AspectJ (www.aspectj.org) • HyperJ (www.alphaworks.ibm.com/tech/hyperj)

28

14 AspectJ Example

http://www.voelter.de/data/articles/aop/aop.html

01 aspect DataLog { 02 advise * Worker.performActionA(..), * Worker.performActionB(..) { 03 static after { 04 if ( thisResult == true ) 05 System.out.println( "Executed "+thisMethodName+ 06 "successfully!" ); 07 else 08 System.out.println( "Error Executing "+ 09 thisMethodName ); 10 } 11 } 12 }

29

Refactoring

http://www.refactoring.com/

• Technique to restructure code in a disciplined way • Small code changes (a.k.a., refactorings) are applied to support new requirements and/or keep design as simple as possible • Enables programmers to safely and easily evolve their code to fulfill new requirements or improve its quality • Refactoring is a fundamental coding practice of XP and is orthogonal to Agile Modeling, which does not address programming-related issues • See Java refactoring guidelines at • http://www.cafeaulait.org/slides/javapolis/refactoring/ • Refactoring tools: • Eclipse supports renaming refactorings that allow you to rename a compilation unit, type, method, field, or parameter • Other refactorings allow you to move code, extract methods, and self encapsulate fields 30

15 Part IV

Java Application Performance Enhancement

31

Application Performance Monitoring

• Java Profiling • java -Xrunhprof:cpu=samples,file=prof.txt Pgm • Jprobe from KLGroup (www.klg.com) • OptimizeIt from Intuitive Systems (www.optimizeit.com) • Timing measurement • java.lang.System’s currentTimeMillis (current time in ms since 12:00 AM GMT, Jan 1 1970 • Heap monitoring, System Tools • java -Xms280k -Xmx1665k -verbose:gc Pgm • JIT and Static Compilation

32

16 Java Performance Problem Areas

• JIT (e.g., HotSpot) and Static Compilation • Creating and Reusing Objects • Using Constants (e.g., static final int X = 5;) • Using Strings (String, StringBuffer, char arrays) • Exception Usage • Loop Techniques • loop constants/variables, early termination • Casting (unecessary casts and instanceofs) • Synchronization • Garbage collection • Collections 33

Assignment • Readings • Mastering Java 2: Part 1 & Appendix A • Expert One-on-One: Chapter 5 as a project template • Selected readings mentioned in class or referenced in the handouts • Handouts posted on the course web site • Assignment #1a: • C++/C#/Java/Jython Comparison • See http://www.jython.org/ • See http://www.25hoursaday.com/CsharpVsJava.html • Explore frameworks implementing behavioral reflection • Select and setup open source Java development tools for XP (e.g., Ant, JUnit, Cactus) • Project Framework Setup • Java Plug-in, Java Web Start, Apache’s Xerces/Xalan • J2SE 1.3.1, 1.4.0 or 1.4.1 (SDK) • IDE: Eclipse, NetBeans, Sun ONE Studio, JBuilder, Visual Age, Visual Café, Codewarrior, WebGain Studio, Oracle JDeveloper, etc. • Editors: JCreator, UltraEdit, etc. 34

17