Java EE | Clean Code and Java EE 6 | Adam Bien

Post on 01-Sep-2014

5,113 views 1 download

Tags:

description

2011-11-01 | 10:40 AM - 11:40 AMAlthough you can build Java EE 6 applications with only a fraction of the code that’s necessary with J2EE, many projects are still based on the bloated and exaggerated J2EE patterns and best practices. This session discusses how to build lean applications in a productive and maintainable way. The following pragmatic tools, patterns, and best practices will be covered with working source code, which are especially interesting to Java EE developers and architects: - Mixing CDI, JPA, EJB, JSF, and JAX-RS to save code - Mocking, unit testing, stress testing, and integration testing - Continuous integration and build (Maven 3, Git) - Efficient data access without DAOs - CAP and BASE - Asynchronous CDI events for decoupling and pub/sub - Pro-active JMX monitoring instead of logging

transcript

blog.adam-bien.com / twitter:@AdamBien

Java EE Clean Code[kill the bloat]

blog.adam-bien.com / twitter:@AdamBien

• Expert Group Member (jcp.org) of Java EE 6, Java EE 7, JPA 2.1, EJB 3.2, CDI 1.1, JMS 2.0 (...)

• Java Champion, (JavaONE) speaker + rockstar, freelancer, consultant and author: >100 articles, 7 German books,

• Author: “Real World Java EE Patterns– Rethinking Best Practices” and “Real World Java EE Night Hacks” http://press.adam-bien.com

• NEW: workshops.adam-bien.com

• http://kenai.com/projects/javaee-patterns/

http://java.net/projects/x-ray

blog.adam-bien.com / twitter:@AdamBien

Adam Bien, press.adam-bien.com

blog.adam-bien.com / twitter:@AdamBien

Adam Bien, press.adam-bien.com

blog.adam-bien.com / twitter:@AdamBien

“Perfection (in enterprise development) is achieved not when there is nothing more to add, but rather when there is nothing more to take away.”

--Antoine de Saint-Exupéry

General Advice: Don't Distribute (CAP)

adam-bien.com

J2EE Patterns in Java EE

adam-bien.com

It’s Not Overengineering...

adam-bien.com

...It’s Cargo Cult Programming:

[http://en.wikipedia.org/wiki/Cargo_cult_programming]

blog.adam-bien.com / twitter:@AdamBien

“...Cargo cult programming is a style of computer programming that is characterized by the ritual inclusion of code or program structures that serve no real purpose...”

blog.adam-bien.com / twitter:@AdamBien

“...Cargo cult programming can also refer to the results of (over-)applying a design pattern or coding style blindly without understanding the reasons behind that design principle in the first place. Examples are adding unnecessary comments to self-explanatory code, adding deletion code for objects that garbage collection would have collected automatically with no problem, creating factory objects to build simple objects, etc. It often happens when programmers are inexperienced with the programming language, or simply overzealous...”

Verify Your Design With …Aliens

adam-bien.com

...or ask a Ruby / Python developer...

Continuous Everything (Integration,

Deployment, QA)

Mocks, Unit-, Integration- and Stress Testing

Strict Separation Between Unit-, Integration-, and

System Tests

Java EE 6, Maven 3, Continuous Integration

And Git

Convention Over Configuration with DI

No, I don't want your XML!

Homegrown Frameworks?

JavaDoc Is Suspicious

DRY And DIE

package private fields or public setters?

Back To Java SE Thinking

Rich Domain Objects

No Interfaces

No Extensive Layering

Rethink J2EE Patterns

Rethink GoF Patterns

Factory

Observer

Builder

Facade

Bridge

Strategy

Decorator

Entity Control Boundary

adam-bien.com

Thank You!blog.adam-bien.com

twitter.com/AdamBien