Useful Design Patterns for Enterprise Applications with Java

16
USING GRASP IN ENTERPRISE APPS Enhancing Human Capacity

Transcript of Useful Design Patterns for Enterprise Applications with Java

Page 1: Useful Design Patterns for Enterprise Applications with Java

USING GRASP IN ENTERPRISE APPS

Enhancing Human Capacity

Page 2: Useful Design Patterns for Enterprise Applications with Java

Agenda

• ShineTech and Workshop for OCA Course Promotion

• GRASP in Enterprise Apps

Page 3: Useful Design Patterns for Enterprise Applications with Java

I - ShineTech and Workshop for OCA Course Promotion

• ShineTech, a professional training company

• Universities Partnerships

• Focused in the computing Market

• Promotes events in technology área

• Courses

• Workshops

• Entertainment

• Next Event ISTEC Auditorium Wednesday 7 PM

• Workshop

• OCA Preparation Course Promotion

• www.shinetech.co/events

Who we are?

Page 4: Useful Design Patterns for Enterprise Applications with Java

I – GRASP in Enterprise Apps

• Elementary Design Patterns for System Development

• Define the responsibility to an object or a set of objects

(classes)

• General Responsibility Assignment Software Patterns

• Creator, Information Expert, Low Coupling , High Cohesion, Controller,

Polymorphism, Pure Fabrication, Indirection, Protected Variation

What is GRASP?

Page 5: Useful Design Patterns for Enterprise Applications with Java

II – GRASP in Enterprise Apps

• Defines who creates an Object or instance of class

• Factories podem ser usadas usando SingleTons

Creator

Page 6: Useful Design Patterns for Enterprise Applications with Java

III – GRASP in Enterprise Apps

• Gives to the object a expertize in a specific area

• DAO classes are experts in database access

• GUI classes are experts in human interface

Expert

Page 7: Useful Design Patterns for Enterprise Applications with Java

IV – GRASP in Enterprise Apps

• Reduces the dependency between objects

• Improve maintenance and component reuse

• Using interfaces helps decoupling

Low Coupling

Page 8: Useful Design Patterns for Enterprise Applications with Java

V – GRASP in Enterprise Apps

• MVC foi descrito em 1979

• MVC first used with Smalltalk 1969 ~ Java 1995

• Delegates GUI layer requests to Business Layer

• Controllers acts as Mediator

• Example of Controllers Delegating Business Rules

• Web Apps with MVC frameworks

• Normally implemented as Servlet (Action)

• Spring, Struts, JSF, etc.

Controller

Page 9: Useful Design Patterns for Enterprise Applications with Java

VI – GRASP in Enterprise Apps

• Directing a class/object to only one responsibility

• Packages help the system to be cohesive

• It helps heaps the system maintenance

• Fundamental for low coupling promotion

High Cohesion

Page 10: Useful Design Patterns for Enterprise Applications with Java

VII – GRASP in Enterprise Apps

• Multiple elements variation in the same object family

• Allows:

• Dynamic elements of the same family replacing in run-

time

• Practical examples:

• Printer drivers (Epson, Lexmark, HP,…)

• JDBC drivers (Oracle, DB2, PostgreSQL,…)

Polymorphism

Page 11: Useful Design Patterns for Enterprise Applications with Java

VIII – GRASP in Enterprise Apps

• Assign responsibility that is not related to the app

domain

• Example of needed classes that are pure fabrication:

• DAO classes

• Log classes

Pure Fabrication

Page 12: Useful Design Patterns for Enterprise Applications with Java

IX – GRASP in Enterprise Apps

• To avoid the direct relationship between elements

• Supply an intermediate unit to communicate units

• Forces the unit decoupling

• Examples of implementation:

• Façades

• Interfaces

Indirection

Page 13: Useful Design Patterns for Enterprise Applications with Java

X – GRASP in Enterprise Apps

• Pattern to avoid the elements variations (changes) in

other elements

• Examples:

• Data encapsulation (private attributes)

• Interfaces

Protected Variation

Page 14: Useful Design Patterns for Enterprise Applications with Java

XI – GRASP in Enterprise Apps

• Creator

• Information Expert

• Low Coupling

• Controller

• High Cohesion

• Indirection

• Polymorphism

• Protected Variation

• Pure Fabrication

Enterprise App Sample Using GRASP

Page 15: Useful Design Patterns for Enterprise Applications with Java

Perguntas?

Page 16: Useful Design Patterns for Enterprise Applications with Java

Agradecimento

• Referência: Craig Lairman

• Applying UML and Patterns

• Presentes

• Especial para:

• O PTJUG