Best Practices in Java Development JA-SIG Summer Conference Denver, CO June 24 – 27, 2007.

Slides:



Advertisements
Similar presentations
xUnit Test Patterns (Some) xUnit Test Patterns (in practice) by Adam Czepil.
Advertisements

Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
Extreme Programming Alexander Kanavin Lappeenranta University of Technology.
Programming Paradigms and languages
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
1 Copyright 1998 by Dragos Manolescu and Joseph W. Yoder Building Frameworks With Patterns “An Active Object-Model For A Dynamic Web-Based Application”
Spring, Hibernate and Web Services 13 th September 2014.
PS4: Test Driven Development Based on Test Driven Development by Example By Kent Beck.
Review Amit Shabtay. March 3rd, 2004 Object Oriented Design Course 2 Review What have we done during the course? Where to learn more? What is for the.
Computer Science 162 Section 1 CS162 Teaching Staff.
© 2005, Cornell University. Rapid Application Development using the Kuali Architecture (Struts, Spring and OJB) A Case Study Bryan Hutchinson
Pragmatic Application Building: Step by Step Jay Sissom Principal Systems Analyst Indiana University
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
Oakkar Fall The Need for Decision Engine Automate business processes Implement complex business decision logic Separation of rules and process Business.
Address - #22, 1 st Floor, Station View Road, Kodambakkam, Chennai JTech Soft Solutions Website:
Struts 2.0 an Overview ( )
UNIT-V The MVC architecture and Struts Framework.
Test-Driven Development With Visual Studio 2005 Erno de Weerd Info Support.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
UPortal 3 – What's New? JA-SIG Conference, Spring 2008 uPortal What's New? Eric Dalquist University of Wisconsin - Madison.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse.
NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework.
M1G Introduction to Programming 2 4. Enhancing a class:Room.
BEST PRACTICES - Java By Configuration Use global-forwards/results Helps to avoid duplicate jsp files and redundancy forward mapping.
Introduction to AOP.
Designing For Testability. Incorporate design features that facilitate testing Include features to: –Support test automation at all levels (unit, integration,
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 11 : Frameworks SWE 316: Software Design and Architecture  To understand.
Todd Snyder Development Team Lead Infragistics Experience Design Group.
Aspect Oriented Programming Razieh Asadi University of Science & Technology Mazandran Babol Aspect Component Based Software Engineering (ACBSE)
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
1 Another group of Patterns Architectural Patterns.
Opus College - overview. OpusCollege - background First project: ICT Capacity Building Mozambican Higher Education Institutions Partners: RUG Groningen,
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
The Java Programming Language
Spring Framework. Spring Overview Spring is an open source layered Java/J2EE application framework Created by Rod Johnson Based on book “Expert one-on-one.
Objected Oriented Programming & Design JAVA Shishir Gupta (704) (704)
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Testing and Debugging Session 9 LBSC 790 / INFM 718B Building the Human-Computer Interface.
Architectural Patterns Support Lecture. Software Architecture l Architecture is OVERLOADED System architecture Application architecture l Architecture.
A Presentation By V AIBHAV S AHARAN Web-enHanced Information Management COMS E6125.
.  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.
BMTRY 789 Lecture 11: Debugging Readings – Chapter 10 (3 rd Ed) from “The Little SAS Book” Lab Problems – None Homework Due – None Final Project Presentations.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Introduction to Software Architecture.
CS5103 Software Engineering Lecture 02 More on Software Process Models.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
Scalatest. 2 Test-Driven Development (TDD) TDD is a technique in which you write the tests before you write the code you want to test This seems backward,
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
SEA Side – Extreme Programming 1 SEA Side Software Engineering Annotations Architectural Patterns Professor Sara Stoecklin Director of Software Engineering-
Cross Language Clone Analysis Team 2 February 3, 2011.
Kansas City Java User’s Group Jason W. Bedell July 12, 2006
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
Clean Code “Keep it Clean, Your Mother Doesn’t Work Here”“Keep it Clean, Your Mother Doesn’t Work Here” William PenberthyWilliam Penberthy Application.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Overview of the Spring Framework Introducing.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
Refactoring and Integration Testing or Strategy, introduced reliably by TDD The power of automated tests.
Configuration & Management for Joachim Flammer Integration Team EGEE is a project funded by the European Union under contract IST JRA1 all-hands-meeting,
Singleton Academy, Pune. Course syllabus Singleton Academy Pune – Course Syllabus1.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
Leveraging ColdSpring to build a robust Flex applications Chris Scott, Cynergy Systems.
Unit Testing.
Types for Programs and Proofs
Application Development Theory
Testing a persistence layer
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
CS 240 – Advanced Programming Concepts
Developing and testing enterprise Java applications
Review of Previous Lesson
Games Development 2 Entity / Architecture Review
Presentation transcript:

Best Practices in Java Development JA-SIG Summer Conference Denver, CO June 24 – 27, 2007

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Who am I? I’m Scott Battaglia! Application Rutgers Java Developer for 5+ Years Lead Developer/Architect on JA-SIG CAS Committer to Acegi Security

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Agenda Methodologies Language Features Non Language Specific Tool Chest Discussion

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development 1. Methodologies

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Test Driven Development Writing a test case and implementing only code necessary to pass test A method of designing software, not merely a method of testing Can still produce crappy code Unit vs. Integration Tests Useful when used judiciously

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Test Driven Development Three rules from “Uncle Bob” –You are not allowed to write any production code unless it is to make a failing unit test pass. –You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. –You are not allowed to write any more production code than is sufficient to pass the one failing unit test. ulesOfTdd

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Test Driven Development What makes a good unit test? –Run fast (they have short setups, run times, and break downs). –Run in isolation (you should be able to reorder them). –Use data that makes them easy to read and to understand. –Use real data (e.g. copies of production data) when they need to. –Represent one step towards your overall goal.

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Domain Driven Design The premise of domain-driven design is two-fold: –For most software projects, the primary focus should be on the domain and domain logic; and –Complex domain designs should be based on a model.

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Domain Driven Design Business people talk naturally in Business terms (using ubiquitous language): - Open grading period, Pending class roster, Student eligible for grading, Course grading policy, etc. Objects shift language from data to behavior - Away from flags and if conditions - Toward responsibilities and naming

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Domain Driven Design Models the business domain concepts Maps to Screens and DB Easier to test, and change Reusable (different application clients) ‏

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Domain Driven Design Business logic can be complex - Rules in Domain Model (DM) describe the many cases & variations DM creates a web of interconnected objects where each represents a meaningful concept some as large as an entire company or as small as a person’s name

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Iterative Development Cyclic/incremental Milestones, Release Candidates… Feedback before its too late! Allows you to take advantage of previously gained knowledge

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Code Reviews Systematic examination of course code Goals –Improve quality of code –Share knowledge Ideally… –Short –Focused on code Many ways of doing it

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Aspect Oriented Programming Deals with the separation of concerns (cross-cutting concerns) ‏ Breaking down a program into distinct parts that overlap in functionality as little as possible Examples –Transactions, logging, security, ContractByDesign

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development 2. Language Features

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development “final” Keyword Used as follows: –final Object o = new Object(); Advantages: –Prevents accidental assigning of variables –Turns logical errors into compile errors –JVM can optimize final constants –Limit Scope of Variables Gotchas: –Final primitives and Strings are substituted at compile-time –Final means no variable re-assignment

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development StringBuilder Usage: –final StringBuilder builder = new StringBuilder(50); –builder.append(“myString”); –builder.append(“moreOfMyString”); StringBuilder vs. StringBuffer vs String “Best Guess” StringBuilder size

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Enumerations Traditional Enumerations: –public final int ENUM_VALUE_1 = 1 –public final int ENUM_VALUE_2 = 2 –… Type Safe Enums: –Implementation of Java classes Java 5 Enumerations –enum COLOR {BLACK, WHITE, RED, GREEN, BLUE, YELLOW}

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development JPA JPA is –Java Persistence API –-Entities –Java Persistence Query Language Advantages –Pluggable backend (TopLink, Hibernate, etc.) ‏ –Database agnostic DAO layer –No complex mapping files Disadvantages –Difficult to retrofit “legacy” tables

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development PreparedStatements Statements vs. PreparedStatements Advantages: –Compiled –Correctly escape characters –As of JDBC 3, can be pooled

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Annotations Extra information associated with Class, Method, Variables Most useful for non-frequently changing information Keeps meta data and object together Examples: –Spring Transactions –CAS Property Validation

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development 3. Non-Language Specific

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Design Patterns Recurring solutions to common problems Solve design problems not computational problems Five types of Patterns Benefits: –Easy to understand code –General solutions –Allow people to communicate using the same language

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Model-View-Controller Division of Labor into the following parts: –Those responsible for business logic (the Model -- often implemented using Enterprise JavaBeans™ or plain old Java objects). –Those responsible for presentation of the user interface (the View). –Those responsible for application navigation (the Controller -- usually implemented with Java servlets or associated classes like Struts controllers).

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Interfaces Interface vs. Abstract Class Coding to Interfaces Examples –Collections Framework –CAS

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Logging Makes debugging easier Everywhere you would have put a System.out, put a logger statement log.isXXXXEnabled() vs. log.XXXX(“data”) ‏ Logging via AOP

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Exception vs. Runtime Exception Two types of Exceptions in Java –Exception (checked) ‏ –Runtime Exception (unchecked) ‏ Checked Exceptions indicate something that can be handled. Unchecked Exceptions indicate something that can’t be.

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Don't Re-Invent the Wheel Use Common well know frameworks –Spring, Hibernate, Web Flow, Acegi... Don't fall for “not invented here” syndrome Balance needs of application vs. library

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Documentation & Comments Documentation is pretty much the bane of all developer’s existences Be sure to place comments in code, but don’t put too much –// send the mail message –javaMailSender.send(message); You never know when you need to revisit your code –Document methods, classes, configuration

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Unit Testing Use a Code Coverage tool Don't Mandate 100% test coverage Add tests when you see they don't exist Add tests to prove a bug Run your tests frequently Make sure the tests execute quickly Don’t let the tests become out of date Don’t throw them away when they stop passing - fix them!

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development 4. Tool Chest

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Build Tools

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Wiki

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Issue Tracking

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Continuous Integration

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Version Control

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Integrated Development Environment

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development 5. Discussion

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development Further Reading.. Thinking in Java by Bruce Eckel J2EE Design and Development by Rod Johnson Refactoring: Improving the Design of Existing Code by Martin Fowler Effective Java by Joshua Bloch Domain Driven Design by Eric Evans

JA-SIG Summer Conference – June 24 – June 27, 2007 Best Practices in Java Development ? What are Your “Best Practices?”