1.2k likes | 1.22k Views
An overview of agile Java development with a focus on Spring, Hibernate, and Eclipse. Includes downloadable code and covers requirements, architecture, development, deployment, logging, and advanced considerations.
E N D
Agile Java Development With Spring, Hibernate and Eclipse Anil Hemrajani anil@visualpatterns.com
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)
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
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
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…)
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
Introduction to Agile Java Development Assume simplicity. Travel light. - Agile Modeling principles: agilemodeling.com
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
Sample (Time Sheet) Application Used In This Presentation Downloadable code: visualpatterns.com/resources.jsp
Agile Processes Requirements change. Design evolves. Documents are seldom current.
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
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
software software software software software software Agility - All About Smaller Chunks (Shorter/Frequent Cycles) Release 2 Release 1 Iteration 0 Iteration 1 Iteration n Iteration 0 Iteration 1 Iteration n ... ... ... Incrementally Build Software - Highest Priority Features First!
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
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
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
Agile Modeling “...your goal is to build a shared understanding, it isn’t to write detailed documentation.” - Scott W. Ambler
Quick Poll Have you ever been on a project where documentation was kept up-to-date through end of project?
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
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.
scope table,glossary, etc. domain model user stories UI prototype& flow map architecture ReleaseLevelModels acceptancetests CRC cards applicationflow map UML diagrams databasemodel IterationLevelModels Choices Of Release (High) Level Models Model with a purpose -- shared understanding!
Sample Scope Table Shared understanding: what's in and what's out
Domain Model Shared understanding: business concepts > key domain objects
3 XP Style User Story Card Use Case - Casual, Brief or Fully Dressed User Stories Or Use Cases Shared understanding: features required of software
User Interface (UI) Prototype Shared understanding: functionality, look-and-feel, etc.
UI Flow Map (Storyboard) Shared understanding: user interface navigation/flow
High-Level Architecture Diagram RDBMS (Oracle) ControllerSpringDispatcherServlet Model Business objects, Hibernate beans Web Browser HTTP JDBC View JSP/HTML SpringScheduler Objects managed by Spring IoC Container BEA WebLogic Server Shared understanding: technologies, scalability, security, reliability
Glossary - List Of Common Business/Technical Terms • AccountingThe accounting department/staff. • ApprovedStatus of a timesheet when a Manager approves a previously submitted timesheet. • EmployeeA person who works on an hourly basis and reports to a manager. • PaidStatus of a timesheet when the accounting department has issued a check. • Etc… Shared understanding: common terminology
scope table,glossary, etc. domain model user stories UI prototype& flow map architecture ReleaseLevelModels acceptancetests CRC cards applicationflow map UML diagrams databasemodel IterationLevelModels Choices Of Iteration Level (Detailed) Models
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.
Active Stakeholder Participation (With Business Representative)
free-form architecture domain model Timesheet List screen Exploring Classes Using CRC Cards Second, let's explore classes on CRC cards using both as input models First, let's reflect on what we know, domain model, UI and architecture
Application Flow Map (Home Grown Artifact) • Complementary to class diagrams and CRC cards • Can be extended using CRUD columns
Physical Models Implementation Conceptual Models THE FINAL AND LASTING ARTIFACTS! Data Base Code Base UI prototype& flow map Focus Is On Working Software vs. Comprehensive Documentation problemstatement scopetable domain model user stories glossary UIprototypes “…your goal is to build a shared understanding, it isn’t to write detailed documentation.” - Scott W. Ambler architecture databasemodel acceptancetests CRC cards applicationflow map UML diagrams
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
UI Flow Map High-Level Architecture Conceptual Class Diagram Agile Draw - Elegantly Simple Modeling Technique Visit AgileDraw.org
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
Agile Java Development: Environment Setup (Directory Structure, JDK, Ant, and JUnit)
Quick Poll How many of you are using Ant, JUnit, Maven, Cruise Control, etc?
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
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
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" password="guest@guest.com" verbose="yes" binary="yes"> <fileset file="README.gnuchess"/> </ftp> <mail tolist="friend@somehost.com" subject="Hello!" from="me@myhost.com" mailhost="myhost.com" user="myuserid" password="mypassword"/>
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); } }
JUnit GUI Based Testing Console Runner Eclipse Plug-in