Download presentation
Presentation is loading. Please wait.
1
Agile Java Development
With Spring, Hibernate and Eclipse Anil Hemrajani
2
About This Presentation
Not a tutorial on any one technology! Overview of each technology (use website, books, etc. for details) Downloadable code (working application) Latest buzz in the US, Europe, etc. End-to-end system! Requirements Architecture/design Java development and debugging Deployment Logging/monitoring Advanced considerations Content/format (text, graphs, code, comics)
3
Material In This Presentation Taken Directly From My Book
Agile Java Development With Spring, Hibernate and Eclipse Forewords by Scott W. Ambler and Rod Johnson Introduction to Agile Java Development The Sample Application: An Online Timesheet System XP and AMDD-Based Architecture and Design Modeling Environment Setup: JDK, Ant, and JUnit Using Hibernate For Persistent Objects Overview of the Spring Framework The Spring Web MVC Framework The Eclipse Phenomenon Logging, Debugging, Monitoring and Profiling Beyond the Basics What Next? Parting Thoughts Appendices (with lots of goodies) available on amazon.com
4
My Background (details at VisualPatterns.com)
20 years of experience in the IT Working with Java Technology since late 1995 as a developer, entrepreneur, author, and trainer. Helped several Fortune 100 companies (some smaller organizations) Published a book and 30 articles Presented at conferences and seminars around the world Awards: "Outstanding Contribution to the Growth of the Java Community" "Best Java Client" for BackOnline (a Java-based online backup product) nominated for a Computerworld-Smithsonian award by Scott McNealy Founder of: Isavix Corporation – successful IT solutions company (now Inscope Solutions) DeveloperHub.com (formerly isavix.net) - award-winning online developer community (grew to over 100,000 registered members) At present – VisualPatterns.com and AgileDraw.org
5
Practical Stuff, Not Fluff!
Recently completed project for U.S. Fortune 50 company Application Financial application process billions of $ every week Clustered application (99.9% uptime required) Used most the technologies covered in presentation (spring, hibernate, eclipse, ant, JUnit…)
6
Introduction to Agile Java Development Agile Processes Agile Modeling
Agenda Introduction to Agile Java Development Agile Processes Agile Modeling Agile Development Environment Setup: Directory Structure, JDK, Ant and JUnit Using Hibernate For Persistent Objects (Short Break) The Spring Framework The Eclipse Phenomenon! Logging, Debugging, Monitoring, and Profiling Beyond The Basics
7
Introduction to Agile Java Development
Assume simplicity. Travel light. - Agile Modeling principles: agilemodeling.com
8
What Is Agile Java Development? It Could Include…
Agile Software Lifecycle Processes (e.g. Scrum, XP, TDD) Agile Architecture/Design Modeling Incremental (just-in-time) design “Good enough” diagrams Agile Model Driven Development (AMDD) Agile Java Design/Development Simple design and coding! Test-driven development (TDD) Efficient frameworks and tools (Ant, JUnit, Hibernate, Spring, Eclipse…) Plain Old Java Objects (POJOs), whenever possible
9
Sample (Time Sheet) Application Used In This Presentation
Downloadable code: visualpatterns.com/resources.jsp
10
Agile Processes Requirements change. Design evolves.
Documents are seldom current.
11
Some Stats by The Standish Group (standishgroup.com)
12
The Solution CHAOS Ten – Success Factors source: standishgroup.com In 2001, seventeen methodologists came together to unify their methodologies under one umbrella; they jointly defined the term, Agile! Read story at: martinfowler.com/articles/agileStory.html
13
AgileManifesto.org
14
What Does “Agile” Exactly Mean?
The Term Agile incorporates a wide range of methods, for example: AM - Agile Modeling ASD - Adaptive Software Development AUP - Agile Unified Process Crystal FDD - Feature Driven Development DSDM - Dynamic Systems Development Method Lean Software Development Scrum Xbreed XP - eXtreme Programming
15
Agility - All About Smaller Chunks (Shorter/Frequent Cycles)
Release 1 Release 2 Iteration Iteration 1 ... Iteration n Iteration Iteration 1 ... Iteration n ... software software Incrementally Build Software - Highest Priority Features First!
16
Simple process for product/project management
Agile Method: Scrum Simple process for product/project management Product Backlog - List of known features/changes for product Sprint - 1-month iterations (develop highest priority items) Meetings Sprint Planning Meeting – Done at beginning of each sprint (after planning, features moved from product backlog to sprint backlog) Daily scrum meeting (short: 15 minutes) Sprint review meeting
17
Extreme Programming (XP)
Shorter and Frequent Cycles (smaller chunks!) Release - Quarterly Cycles (set a theme) Iteration - Weekly Cycles (e.g. aim for last day of week) 10-minute builds Continuous integration (multiple times per day; manual or automatic) Incremental Design and Planning (defer investment till needed) Development in small increments using Test-First development Communications - Sit Together, Informative Workspace, on- site customer Flow - sustainable pace versus rigid phases; velocity, continuous integration Others… visit extremeprogramming.org
18
Introduction to Agile Java Development Agile Processes Agile Modeling
Presentation Outline Introduction to Agile Java Development Agile Processes Agile Modeling Agile Development Environment Setup: Directory Structure, JDK, Ant and JUnit Using Hibernate For Persistent Objects The Spring Framework The Eclipse Phenomenon! Logging, Debugging, Monitoring, and Profiling Beyond The Basics
19
Agile Modeling “...your goal is to build a shared understanding, it isn’t to write detailed documentation.” - Scott W. Ambler
20
Quick Poll Have you ever been on a project where documentation was kept up-to-date through end of project?
21
Agile Model Driven Development (AMDD)
Subset of Agile Modeling (agilemodeling.com) Agile version of Model Driven Development (MDD) Instead of extensive models, “barely good enough” Initial modeling activity Requirements Architecture Requirements modeling Usage models Domain models UI models Architecture modeling Free-form diagrams Change cases
22
Project Initiation
23
Problem Statement Our employees currently submit their weekly hours worked using a paper-based timesheet system that is manually intensive and error-prone. We require an automated solution for submitting employee hours worked, in the form of an electronic timesheet, approving them, and paying for the time worked. In addition, we would like to have automatic notifications of timesheet status changes and a weekly reminder to submit and approve employee timesheets.
24
Project Kickoff Meeting
25
Choices Of Release (High) Level Models
domain model user stories UI prototype & flow map architecture Release Level Models scope table, glossary, etc. CRC cards application flow map UML diagrams database model Iteration Level Models acceptance tests Model with a purpose -- shared understanding!
26
Sample Scope Table Shared understanding: what's in and what's out
27
Domain Model Shared understanding: business concepts > key domain objects
28
User Stories Or Use Cases
3 XP Style User Story Card Use Case - Casual, Brief or Fully Dressed Shared understanding: features required of software
29
User Interface (UI) Prototype
Shared understanding: functionality, look-and-feel, etc.
30
UI Flow Map (Storyboard)
Shared understanding: user interface navigation/flow
31
High-Level Architecture Diagram
Controller Spring DispatcherServlet Model Business objects, Hibernate beans RDBMS (Oracle) Web Browser HTTP JDBC View JSP/HTML Spring Scheduler Objects managed by Spring IoC Container BEA WebLogic Server Shared understanding: technologies, scalability, security, reliability
32
Glossary - List Of Common Business/Technical Terms
Accounting The accounting department/staff. Approved Status of a timesheet when a Manager approves a previously submitted timesheet. Employee A person who works on an hourly basis and reports to a manager. Paid Status of a timesheet when the accounting department has issued a check. Etc… Shared understanding: common terminology
33
Choices Of Iteration Level (Detailed) Models
domain model user stories UI prototype & flow map architecture Release Level Models scope table, glossary, etc. CRC cards application flow map UML diagrams database model Iteration Level Models acceptance tests
34
Acceptance Tests (Serve As Detailed Requirements)
Sign In The employee id can be up to 6 characters. The password must be between 8 and 10 characters. Only valid users can sign in. Timesheet List Only a user's personal timesheets can be accessed. Enter Hours Hours must contain numeric data. Daily hours cannot exceed 16 hours. Weekly hours cannot exceed 96 hours. Hours must be billed to a department. Hours can be entered as two decimal places. Employees can only view and edit their own timesheets.
35
Active Stakeholder Participation (With Business Representative)
36
Exploring Classes Using CRC Cards
First, let's reflect on what we know, domain model, UI and architecture Second, let's explore classes on CRC cards using both as input models Timesheet List screen free-form architecture domain model
37
Application Flow Map (Home Grown Artifact)
Complementary to class diagrams and CRC cards Can be extended using CRUD columns
38
UML Class and Package Diagrams
39
Focus Is On Working Software vs. Comprehensive Documentation
Conceptual Models problem statement scope table domain model user stories UI prototypes glossary architecture “…your goal is to build a shared understanding, it isn’t to write detailed documentation.” - Scott W. Ambler Physical Models acceptance tests database model CRC cards application flow map UML diagrams UI prototype & flow map Implementation Data Base Code Base THE FINAL AND LASTING ARTIFACTS!
40
Shifting Some Upfront Design to Refactoring
41
Shifting Some Upfront Design To Refactoring (Continuous Design)
Refactoring is not a new concept; the term is relatively new refactoring.com “Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.” - Martin Fowler Over 100 refactoring techniques; for example: Extract superclass Extract interface Move class Move method
42
Agile Draw - Elegantly Simple Modeling Technique
High-Level Architecture UI Flow Map Conceptual Class Diagram Visit AgileDraw.org
43
Introduction to Agile Java Development Agile Processes Agile Modeling
Presentation Outline Introduction to Agile Java Development Agile Processes Agile Modeling Agile Development Environment Setup: Directory Structure, JDK, Ant and JUnit Using Hibernate For Persistent Objects The Spring Framework The Eclipse Phenomenon! Logging, Debugging, Monitoring, and Profiling Beyond The Basics
44
Agile Java Development:
Environment Setup (Directory Structure, JDK, Ant, and JUnit)
45
How many of you are using Ant, JUnit, Maven, Cruise Control, etc?
Quick Poll How many of you are using Ant, JUnit, Maven, Cruise Control, etc?
46
Personal Opinion: Early Environment Setup Is Essential
Involves more than people expect/plan Cycle 0 Get minimal environment setup (scripts, directory, version control, etc.) Get end-to-end demo working Helps team
47
Directory Structure, Naming Conventions, Version Control, etc.
controller/TimesheetListController.java model/Timesheet.java model/TimesheetManager.java test/TimesheetListControllerTest.java test/TimesheetManagerTest.java view/timesheetlist.jsp
48
Ant (ant.apache.org) Ant task types Compile tasks (that is, javac)
Deployment tasks File tasks such as copy, delete, move, and others. Property tasks for setting internal variables Audit/coverage tasks Database tasks Documentation tasks Execution tasks Mail tasks Preprocess tasks Property tasks Remote tasks Miscellaneous tasks (e.g. echo) <ftp server="mirrors.kernel.org" action="get" remotedir="/gnu/chess" userid="anonymous" verbose="yes" binary="yes"> <fileset file="README.gnuchess"/> </ftp> <mail subject="Hello!" mailhost="myhost.com" user="myuserid" password="mypassword"/>
49
Simple framework – various assert methods
JUnit (junit.org) Originally written by Erich Gamma (Gang of Four, Design Patterns) Kent Beck (author of Extreme Programming and Test Driven Development) Simple framework – various assert methods assertEquals assertFalse assertNotNull assertNotSame assertNull assertSame assertTrue public class SimpleTest extends junit.framework.TestCase { int value1 = 2, value2 = 3, expectedResult = 5; public static void main(String args[]) junit.textui.TestRunner.run(suite()); } public static Test suite() return new TestSuite(SimpleTest.class); public void testAddSuccess() assertTrue(value1 + value2 == expectedResult);
50
JUnit GUI Based Testing
Console Runner Eclipse Plug-in
51
Agile Method: Test Driven Development (TDD) w/ JUnit
A term coined by Kent Beck Also, a XP practice (test-first) “Red - Green - Refactor” Several benefits to this approach: Minimal code written to satisfy requirements (nothing more, nothing less!) If code passes the unit tests, it is done! Can help design classes better (from a client/interface perspective) Refactor with confidence Write unit test code More unit test code More unit test code Write some actual code More actual code More actual code Write Test First Code, Compile, Test
52
Introduction to Agile Java Development Agile Processes Agile Modeling
Presentation Outline Introduction to Agile Java Development Agile Processes Agile Modeling Agile Development Environment Setup: Directory Structure, JDK, Ant and JUnit Using Hibernate For Persistent Objects The Spring Framework The Eclipse Phenomenon! Logging, Debugging, Monitoring, and Profiling Beyond The Basics
53
Agile Java Development:
Using Hibernate For Persistent Objects
54
Quick Poll What persistence solution does your project use (e.g. JDBC, ORM, entity bean)?
55
Where Hibernate Fits Into Our Architecture
56
An Overview of Object-Relational Mapping (ORM)
ORM - Java object to database table/record mapping Java = objects database = relational Relationships unidirectional and bidirectional relations in a relational database are bidirectional by definition Cardinality (OO term is multiciplicity) One-to-one one-to-many many-to-one and many-to-many Object Identity Cascade Others…
57
SessionFactory, Session, and Transaction
Hibernate Basics Dialect (DB2, Microsoft SQL Server, MySQL, Oracle, PostgreSQL, SAP DB, Sybase, TimesTen…) SessionFactory, Session, and Transaction Work with Database Records (as Java Objects) Object States - persistent, detached, and transient Data Types – more than you'll likely need! Hibernate Query Language (HQL) – powerful SQL-like language
58
From Domain Model To A (Denormalized) Physical Data Model
59
Working With Hibernate - Simple Example Using Department
hibernate.cfg.xml – Hibernate configuration file (DB configuration) <mapping resource="Department.hbm.xml" /> Department.hbm.xml – Mapping file for our Department table <class name="com.visualpatterns.timex.model.Department" table="Department"> <id name="departmentCode" column="departmentCode"> <property name="name" column="name"/> Department.java – Bean file with two variables: String departmentCode; String name; HibernateTest.java – Simple test program (on next slide)
60
HibernateTest.java SessionFactory sessionFactory = new Configuration().configure() .buildSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction tx = session.beginTransaction(); Department department = (Department) session.get(Department.class, "IT"); System.out.println("Name for IT = " + department.getName()); ... List departmentList = session.createQuery("from Department").list(); for (int i = 0; i < departmentList.size(); i++) { department = (Department) departmentList.get(i); System.out.println("Row " + (i + 1) + "> " + department.getName() + " (" + department.getDepartmentCode() + ")"); } sessionFactory.close();
61
Other Hibernate Features
Saving (save, merge, saveOrUpdate) session.saveOrUpdate(timesheet) Deleting records session.delete(Object), or session.createQuery("DELETE from Timesheet") Queries using Criteria interface (more OO and typesafe) List timesheetList = session.createCriteria(Timesheet.class) add(Restrictions.eq("employeeId", employeeId)) list(); Related classes: Restrictions, Order, Junction, Distinct, and others Locking Objects (Concurrency Control) Lots More Hibernate (associtions, annotations, filters, interceptors, scrollable iterations, native SQL, transaction management, etc.)
62
Introduction to Agile Java Development Agile Processes Agile Modeling
Presentation Outline Introduction to Agile Java Development Agile Processes Agile Modeling Agile Development Environment Setup: Directory Structure, JDK, Ant and JUnit Using Hibernate For Persistent Objects The Spring Framework The Eclipse Phenomenon! Logging, Debugging, Monitoring, and Profiling Beyond The Basics
63
Agile Java Development:
The Spring Framework
64
Spring Modules
65
Spring Java Packaging (org.springframework.)
66
Are you familiar with Inversion of Control (IoC)?
Quick Poll Are you familiar with Inversion of Control (IoC)?
67
IoC Container And Dependency Injection Pattern
Dependency Injection Styles Two Supported By Spring: Setter/getter based Constructor based Fowler suggests a 3rd, interface injection, Spring IoC Concepts: Beans, BeanFactory, ApplicationContext… Normal Way Using IoC public class A { B myB = new B(); C myC = new C(); } public class A { B myB; C myC; public setB(B myB) public setC(C myC) Class A Class C Class B IOC Container
68
Benefits of Using Spring
Light weight Inversion of Control (IoC) container Excellent support for POJOs (e.g. declarative transaction management) Modular – not an all-or-nothing approach Testing – dependency injection and POJOs makes for easier testing Many others No Singletons Builds on top of existing technologies (e.g. JEE, Hibernate) Robust MVC web framework Consistent database exception hierarchy (e.g. wrap SQLException)
69
Where Spring Framework Fits Into Our Architecture
Optional Hibernate integration
70
Which web framework do you use?
Quick Poll Which web framework do you use?
71
Spring Web MVC Easier testing – mock classes, dependency injection Bind directly to business objects Clear separation of roles – validators, adaptable controllers, command (form) object, etc. Simple but powerful tag libraries Support for various view technologies and web frameworks (e.g. Struts, webwork, tapestry, JSF)
72
Spring MVC Java Concepts
Controller ModelAndView Command (Form Backing) Object Validator Spring Tag Library (spring:bind)
73
Spring MVC Configuration
<servlet> <servlet-name>timex</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <url-pattern>*.htm</url-pattern> </servlet-mapping> web.xml timex-servlet.xml <bean id="urlMapAuthenticate” class= "org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <prop key="/enterhours.htm">enterHoursController</prop> ... <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass"> <value>org.springframework.web.servlet.view.JstlView</value> </property> <property name="prefix"> <value>/WEB-INF/jsp/</value> <property name="suffix"> <value>.jsp</value> </bean>
74
Sample End-To-End Flow Using Spring and Hibernate
75
Timesheet List: A No-Form Controller Example
public class TimesheetListController implements Controller { ... public ModelAndView handleRequest( HttpServletRequest request, HttpServletResponse response) mockHttpServletRequest = new MockHttpServletRequest("GET", "/timesheetlist.htm"); ModelAndView modelAndView = timesheetListController.handleRequest( mockHttpServletRequest, null); assertNotNull(modelAndView); assertNotNull(modelAndView.getModel());
76
Enter Hours: A Form Screen
EnterHoursController.java EnterHoursValidator.java enterhours.jsp public class EnterHoursController extends SimpleFormController
77
View/JSP Code – Spring and JSTL Tag Libraries
<spring:bind path="command.employeeId"> <input name='<c:out value="${status.expression}"/>' value='<c:out value="${status.value}"/>' type="text" size="6" maxlength="6"> </spring:bind> Special (Spring) variable named status status.value status.expression status.error status.errorMessage status.errorMessages status.displayValue
78
Sign In (Authentication) - Spring HandlerInterceptor
public class HttpRequestInterceptor extends HandlerInterceptorAdapter { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) if (!signedIn) response.sendRedirect(this.signInPage); return false; }
79
View with no controllers (e.g. only JSP files)
Other Spring Web Stuff View with no controllers (e.g. only JSP files) <bean id="urlFilenameController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/> <prop key="/help.htm">urlFilenameController</prop> Spring 2.0 – new tag libraries form:form - org.springframework.web.servlet.tags.form.FormTag form:input- org.springframework.web.servlet.tags.form.InputTag form:password - org.springframework.web.servlet.tags.form.PasswordInputTag form:hidden - org.springframework.web.servlet.tags.form.HiddenInputTag form:select - org.springframework.web.servlet.tags.form.SelectTag form:option - org.springframework.web.servlet.tags.form.OptionTag form:radiobutton - org.springframework.web.servlet.tags.form.RadioButtonTag Others… Other Web Flow – gaining a lot of momentum! Wizard-like features. Portlet API – based on JSR-168 Portlet Specification (jcp.org).
80
Spring ORM Module: Support for Hibernate
Management of sessionfactory and session (no close calls) Declarative transaction management in light-weight containers Easier testing (pluggable Sessionfactory via XML file) Less lines of code – focus on business logic!
81
Spring ORM Module: Support for Hibernate (cont’d)
Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); try { session.saveOrUpdate(timesheet); session.getTransaction().commit(); } catch (HibernateException e) session.getTransaction().rollback(); throw e; getHibernateTemplate().saveOrUpdate(timesheet); Less lines of code
82
Scheduling Jobs (with Quartz or JDK timers)
More Spring… Scheduling Jobs (with Quartz or JDK timers) Spring support Much more JEE support Sub-projects (Acegi, BeanDoc, Spring IDE, etc.) <bean id="reminder JobDetail" class= "org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="reminder " /> <property name="targetMethod" value="sendMail" /> </bean> <bean id="reminder JobTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail" ref="reminder JobDetail" /> <property name="cronExpression" value=" ? * 6" />
83
Introduction to Agile Java Development Agile Processes Agile Modeling
Presentation Outline Introduction to Agile Java Development Agile Processes Agile Modeling Agile Development Environment Setup: Directory Structure, JDK, Ant and JUnit Using Hibernate For Persistent Objects The Spring Framework The Eclipse Phenomenon! Logging, Debugging, Monitoring, and Profiling Beyond The Basics
84
Agile Java Development:
The Eclipse Phenomenon!
85
Quick Poll Which IDE do you use?
86
The Eclipse Foundation, Platform and Projects
Originally developed by Object Technology International (OTI), purchased by IBM ($40 million) and donated it to open source! Recruited various corporations; from eclipse.org: Industry leaders Borland, IBM, MERANT, QNX Software Systems, Rational Software, Red Hat, SuSE, TogetherSoft and Webgain formed the initial eclipse.org Board of Stewards in November By the end of 2003, this initial consortium had grown to over 80 members. My view: Eclipse foundation is similar to Apache foundation for GUI tools Platform objectives robust platform for highly integrated dev tools enable view and/or editing of any content type attract a large community of developers to develop plug-ins Projects Application Development, editors, modeling, performance, testing, reporting, and many more
87
Many Platforms Supported (Windows, Unix, Linux, Mac OS X…)
88
Personal Opinion: The Java versus Microsoft Thing First exciting IDE
Huge community - Plug-ins galore (thousand+) Ward Cunningham and Erich Gamma Battle of IDEs has only now begun!
89
Eclipse Basic Concepts
Workspace (directory of projects) Workbench Perspectives Editors and Views Project Wizards (hundreds) Plug-ins (galore!) sample workspace
90
Project/Plug-in: Java Development Tools (JDT)
Java views (e.g. packages, types, members) Intelligent code fix and content assist Compile during save (within the blink of an eye) Powerful debugger (than works!) Pre-configured for JUnit and Ant Others Formatting options Powerful search Code refactoring (some based on Fowler's refactoring.com) TODO lists Scrapbook Export feature (create zip files, etc.)
91
JDT Features Java Browsing JUnit Ant Assist
Java Compile Errors/Warnings
92
Project/Plug-ins: Eclipse Web Tools Platform (WTP)
Tools for developing J2EE Web applications Editors Source - HTML, JavaScript, CSS, JSP, SQL, XML, DTD, XSD, and WSDL Graphical - XSD and WSDL Database access and query tools and models Web service wizards J2EE - project natures, builders, models navigator
93
WTP Web Services Related Screens
94
Other WTP Features Servers JSP Assist Database
95
CVS (Eclipse Team Sharing)
96
Hibernate and Spring Plug-Ins
Spring IDE
97
Startup Time Comparison To IntelliJ and NetBeans
IntellIJ - 1 minute, 5 seconds! NetBeans - 42 seconds. Eclipse with JDT, WTP, Hibernate, Eclipse seconds!
98
Introduction to Agile Java Development Agile Processes Agile Modeling
Presentation Outline Introduction to Agile Java Development Agile Processes Agile Modeling Agile Development Environment Setup: Directory Structure, JDK, Ant and JUnit Using Hibernate For Persistent Objects The Spring Framework The Eclipse Phenomenon! Logging, Debugging, Monitoring, and Profiling Beyond The Basics
99
Agile Java Development:
Logging, Debugging, Monitoring, and Profiling
100
Do you use a GUI debugger? Or, a logging framework?
Quick Poll Do you use a GUI debugger? Or, a logging framework? Or, use println statements?
101
Logging Basics and Frameworks
Types Audit log Tracing Error reporting Pros No human intervention (automated) Great for head-less servers Cons Performance hit Can clutter code Logging Frameworks Alternative to println statements Key benefit - Output control (destination, format, log level) Most popular - Apache Log4J and JDK Logging Jakarta Commons Logging -- bridge to frameworks import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class CommonsLoggingTest { private static Log log = LogFactory.getLog(CommonsLoggingTest.class); public static void main(String[] args) log.fatal("This is a FATAL message."); log.error("This is an ERROR message."); log.warn("This is a WARN message."); log.info("This is an INFO message."); log.debug("This is a DEBUG message."); }
102
Headaches of Finding and Fixing Bugs!
103
Debugging Java Code With Eclipse
Debug perspectives and views Breakpoints Step through code Variable inspection Hotswap Remote debugging “consolidated debugging”
104
Debugging Web User Interfaces Using Mozilla Firefox
JavaScript debugger Web Developer Tamper Data
105
Java Monitoring and Profiling
Spring MBean Exporter Monitoring JSE 5.0 includes JConsole Memory issues Class loading and garbage collection Management of MBeans and JDK logging level, etc … Profiling Memory usage and leaks CPU utilization Trace objects and methods Determine performance bottlenecks <bean id="timexJmxBean” class= "com.visualpatterns.timex.util.TimexJmxBean" /> <bean id="exporter” class= "org.springframework.jmx.export.MBeanExporter"> <property name="beans"> <map> <entry key="Time Expression:name=timex-stats" value-ref="timexJmxBean" />
106
Introduction to Agile Java Development Agile Processes Agile Modeling
Presentation Outline Introduction to Agile Java Development Agile Processes Agile Modeling Agile Development Environment Setup: Directory Structure, JDK, Ant and JUnit Using Hibernate For Persistent Objects The Spring Framework The Eclipse Phenomenon! Logging, Debugging, Monitoring, and Profiling Beyond The Basics
107
Beyond The Basics
108
Custom Tag Libraries <timex:periodcheck checkDate="${command.periodEndingDate}"> <input name="save" type="submit" value="Save"> </timex:periodcheck> public class PayPeriodCheckTag extends TagSupport { public int doStartTag() throws JspException boolean includeText = ; // do something if (includeText) return TagSupport.EVAL_BODY_INCLUDE; return TagSupport.SKIP_BODY; }
109
Security, Reliability and Scalability Considerations
110
Application Security Considerations
Authentication (user and application levels) Authorization (roles, groups, etc.) Encryption (wire protocol, configuration files) Wire protocol (HTTP/S) User-level authentication & authorization Application-level authentication
111
Clustering (serialize, no static variables, simplicity…)
Other Considerations Exception Handling Checked exceptions (e.g. IOException) – required catch or throw Unchecked exceptions (e.g. NullPointerException) - no catch/throw needed Errors (e.g. OutOfMemoryError) Clustering (serialize, no static variables, simplicity…) Multi-threading (JDK 1.5 concurrent API) Rich Internet Applications (RIA) AJaX - Google Web Toolkit (GWT) - Direct Web Remoting (DWR) - Adobe Flex Java Swing and Web Start
112
Cool Concept For Smaller Apps - Entire System In A WAR File!
Code (source, binary) Relational database (e.g. HSQLDB) Job Scheduling More…
113
Wrap Up!
114
Introduction to Agile Java Development Agile Processes Agile Modeling
Presentation Outline Introduction to Agile Java Development Agile Processes Agile Modeling Agile Development Environment Setup: Directory Structure, JDK, Ant and JUnit Using Hibernate For Persistent Objects The Spring Framework The Eclipse Phenomenon! Logging, Debugging, Monitoring, and Profiling Beyond The Basics
115
Constant Learning – Be a “Generalizing Specialist”
116
Don’t Forget - Release Completion Celebration!
RON STEVE RAJ SUSAN
117
Some Near Term Plans
118
available on amazon.com
Book - Released 12th May, 2006 Agile Java Development With Spring, Hibernate and Eclipse Forewords by Scott W. Ambler and Rod Johnson Introduction to Agile Java Development The Sample Application: An Online Timesheet System XP and AMDD-Based Architecture and Design Modeling Environment Setup: JDK, Ant, and JUnit Using Hibernate For Persistent Objects Overview of the Spring Framework The Spring Web MVC Framework The Eclipse Phenomenon Logging, Debugging, Monitoring and Profiling Beyond the Basics What Next? Parting Thoughts Appendices (with lots of goodies) available on amazon.com
119
Interesting Stuff At VisualPatterns.com - Visit Site Periodically
Comics Cheat Sheets R&D Concepts
120
Anil@VisualPatterns.com agilemodeling.com agiledata.org
THE END! agilemodeling.com agiledata.org agilemanifesto.org extremeprogramming.org hibernate.org springframework.org eclipse.org code.google.com/webtoolkit/ getahead.ltd.uk/dwr/ VisualPatterns.com (links, comics, code, cheat sheets…) Stay in touch!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.