Escolar Documentos
Profissional Documentos
Cultura Documentos
Anil Hemrajani
anil@visualpatterns.com
Appendices
© Visual Patterns,(with
Inc. lots of goodies) 3
Book Related Talks
• Founder of:
Isavix Corporation – successful IT solutions company (now
InScope Solutions)
Isavix Community (now DeveloperHub.com) - award-winning online
developer community (grew to over 100,000 registered members)
• Application
Financial application process billions of $ every week
Assume simplicity.
Travel light.
Requirements change.
Design evolves.
• Others…
Release 1 Release 2
Iteration
0
Iteration
1
...Iteration
n
Iteration
0
Iteration
1
...Iteration
n
...
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
- Scott W. Ambler
Communic
ation, simplicity, feedback, courage and humility.
Practices Principles
• Requirements modeling
Usage models
Domain models
Let’s apply
UI models
this to a
• Architecture modeling sample
Free-form diagrams
application
Change cases
, next ...
© Visual Patterns, Inc. 23
Initiating A New Software Application Project
Release
scope table, UI prototype
Level domain model user stories architecture
Models glossary, etc. & flow map
Iteration
acceptance application UML database
Level CRC cards
Models tests flow map diagrams model
Scope Functionality
Include Time Expression will provide the capability to enter, approve, and
pay for hours worked by employees.
Defer Time Expression will not calculate deductions from paychecks, such
as federal/state taxes and medical expenses.
Defer Time Expression will not track vacation or sick leave.
Description
This process allows User to log into the System
Actors/I nterfaces
XP Style User Story •
Card
•
Web HTTP
Controller Model JDBC
Spring Business objects,
RDBMS
Browser DispatcherServlet Hibernate beans (Oracle)
Spring
View Schedul
JSP/HTML er
Release
scope table,
UI prototype
Level domain model user stories architecture
Models glossary, etc. & flow map
Iteration
acceptance application UML database
Level CRC cards
Models tests flow map diagrams model
Timesheet List
screen
TimesheetManager
Timesheet
domain model table
user stories
UI glossary
prototypes • Model in Small Increments
architecture
tests model
CRC cards
• Prove it with code
application UML
flow map diagrams
- agilemodeling.com
Implementation THE FINAL AND LASTING ARTIFACTS!
• 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
High-Level
Architecture
UI Flow Map
Visit AgileDraw.org
Conceptual Class
Diagram
➔controller/TimesheetListController.java
➔model/Timesheet.java
➔model/TimesheetManager.java
➔test/TimesheetListControllerTest.java
➔test/TimesheetManagerTest.java
➔view/timesheetlist.jsp
• Originally written by
Erich Gamma (Gang of Four, Design Patterns)
Kent Beck (author of Extreme Programming and Test Driven
Development)
Console Runner
Eclipse Plug-in
What persistence
solution does your
project use (e.g.
JDBC, ORM, entity
bean)?
• 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
© Visual Patterns, Inc.
Hibernate Basics
• Dialect
(DB2, Microsoft SQL Server, MySQL, Oracle,
PostgreSQL, SAP DB, Sybase, TimesTen…)
Transaction tx = session.beginTransaction();
Department department = (Department)
session.get(Department.class, "IT");
System.out.println("Name for IT = " + department.getName());
...
...
sessionFactory.close();
• Deleting records
session.delete(Object), or
session.createQuery("DELETE from Timesheet")
• Many others
No Singletons
Builds on top of existing technologies (e.g. JEE,
Hibernate)
Robust MVC web framework
© Visual Patterns, Inc. 69
Where Spring Framework Fits Into Our Architecture
Optional
Hibernate
integration
1.Controller
2.ModelAndView
3.Command (Form
Backing)
Object
4.Validator
5.Spring Tag
Library
(spring:bind)
web.xml timex-
<bean id="urlMapAuthenticate” servlet.xml
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>
<property name="suffix">
<value>.jsp</value>
</property>
</bean> © Visual Patterns, Inc. 74
Sample End-To-End Flow Using Spring and Hibernate
mockHttpServletRequest =
new MockHttpServletRequest("GET",
"/timesheetlist.htm");
ModelAndView modelAndView =
timesheetListController.handleRequest(
mockHttpServletRequest, null);
assertNotNull(modelAndView);
assertNotNull(modelAndView.getModel());
1.
EnterHoursController.jav
a
2.
EnterHoursValidator.java
3. enterhours.jsp
<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>
getHibernateTemplate().saveOrUpdate(timesheet);
Less lines of
code
© Visual Patterns, Inc. 82
More Spring…
• Scheduling Jobs (with Quartz or
JDK
<bean timers)
id="reminderEmailJobDetail" class=
"org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="reminderEmail" />
<property name="targetMethod" value="sendMail" />
</bean>
<bean id="reminderEmailJobTrigger"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="reminderEmailJobDetail" />
<property name="cronExpression" value="0 0 14 ? * 6" />
</bean>
• Much more
JEE support
Sub-projects (Acegi, BeanDoc, Spring
IDE, etc.)
© Visual Patterns, Inc. 83
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
• 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
© Visual Patterns, Inc. 87
Personal Opinion:
The Java versus
Microsoft Thing
• Workspace (directory of
projects)
• Workbench
• Perspectives
• Editors and Views
• Project
• Wizards (hundreds)
• Plug-ins (galore!)
sample
workspace
JUnit
Ant Assist
Java Compile 91
© Visual Patterns, Inc.
Errors/Warnings
JDT: Other Notable Features
• Compile during save (within the blink of an eye)
• Formatting options
• Scrapbook
• TODO lists
• Others
Powerful search
Code refactoring (some based on Fowler's
refactoring.com)
Export feature (create zip files, etc.)
• Editors
Source - HTML, JavaScript, CSS, JSP, SQL, XML, DTD, XSD,
and WSDL
Graphical - XSD and WSDL
• Much more…
Database
Web Services
© Visual Patterns, Inc. 94
CVS (Eclipse Team Sharing)
Hibernate
Spring
© Visual Patterns, Inc. IDE
96
Startup Time Comparison To IntelliJ and NetBeans
IntellIJ - 1 minute, 5
seconds!
NetBeans - 42
seconds.
Eclipse with JDT, WTP, Hibernate, Eclipse... 19
seconds!
hit
• Can clutter © Visual Patterns, Inc. 101
Headaches of Finding and Fixing Bugs!
and views
• Breakpoints
• Step through
code
• Variable
inspection
• Hotswap
• Remote
debugging
Web Developer
collection
Management of
MBeans and JDK
logging level,
etc …
• Profiling
Memory usage and
leaks
CPU utilization
Trace objects and
methods
Determine © Visual Patterns, Inc. 105
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
<timex:periodcheck
checkDate="${command.periodEndingDate}">
<input name="save" type="submit" value="Save">
</timex:periodcheck>
return TagSupport.SKIP_BODY;
}
User-level
authentication
& authorization
Wire protocol
(HTTP/S) Application-level
authentication
“A
generalizing
specialist
is someone
with a good
grasp of how
everything
fits
together.”
© Visual Patterns, Inc. 115
Most Important… Don’t Forget To Have Fun! :-)
visualpatterns.com/resources.jsp
• Spring
• Hibernate
• Ant
• JUnit
• DisplayTag
• HSQLDB
Model
Web HTTP
Controller
Business JDBC RDBMS
Spring
Browser DispatcherServlet
objects, (Oracle)
Hibernate beans
View Spring
Scheduler
JSP/HTML
Planning Coding
• User stories are written. · The customer is always available.
· Release planning creates the · Code must be written to agreed
schedule. standards.
· Make frequent small releases. · Code the unit test first.
· The Proje ct Velocity is measured. · All production code is pair programmed.
· The project is divided into iterations. · Only one pair integrates code at a time.
· Iteration planning starts each · Integrate often.
iteration. · Use collective code ownership.
· Move people around. · Leave optimization till last.
· A stand -up meeting starts each day. · No overtime.
· Fix XP when it breaks.
Designing Testing
· Simplicity. · All code must have unit tests.
· Choose a system meta phor. · All code must pass all unit tests before it
· Use CRC cards for design sessions. can be released.
· Create spike solutions to reduce risk. · When a bug is found tests are created.
· No functionality is added early. · Acceptance tests are run often and the
· Refactor whenever and wherever score is published.
possible.
Comics
Cheat Sheets
R&D Concepts
© Visual Patterns, Inc. 118
THE END!
• agilemodeling.com
• agiledata.org Stay in touch!
• agilemanifesto.org
• extremeprogramming.org Anil@VisualPatterns.com
• hibernate.org
• springframework.org
• eclipse.org
• code.google.com/webtoolkit/
• getahead.ltd.uk/dwr/