Adf development more tales from the trenches
Download
1 / 117

ADF Development More tales from the trenches - PowerPoint PPT Presentation


  • 116 Views
  • Updated On :

NAAM. ADF Development More tales from the trenches. Aino Andriessen AMIS Services. Systems integrator Co-sourcing Maintenance Oracle, Java, Open Source, ADF, DBA, SOA AMIS technology school Pagoni http://www.amis.nl http://technology.amis.nl/blog/. Aino Andriessen.

Related searches for ADF Development More tales from the trenches

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'ADF Development More tales from the trenches' - pooky


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Adf development more tales from the trenches l.jpg

NAAM

ADF DevelopmentMore tales from the trenches

Aino Andriessen

AMIS Services


Slide2 l.jpg

  • Systems integrator

  • Co-sourcing

  • Maintenance

  • Oracle, Java, Open Source, ADF, DBA, SOA

  • AMIS technology school

  • Pagoni

  • http://www.amis.nl

  • http://technology.amis.nl/blog/


Aino andriessen l.jpg
Aino Andriessen

  • Technical Consultant

  • Technical Architect

  • Java, ADF, PL/SQL, XML, ...

  • SOA , Integration

  • Software engineering

  • Quality management

  • Agile development

  • [email protected]

  • http://www.fttech.net


Slide4 l.jpg

Let's build an ADF

application to...


Slide5 l.jpg

experience the

development process

and...


Slide6 l.jpg

to build better

ADF applications...



Stakeholders l.jpg
Stakeholders

customer

developer

maintenance

project lead


Better according to customer l.jpg
better according to... Customer

Fully functional

Within budget

On time


Better according to project lead l.jpg
better according to... Project lead

Within budget

Functional

Big


Better according to developer l.jpg
better according to... Developer

Organized

Fully Featured

Stable


Better according to maintenance l.jpg
better according to... Maintenance

Easy to maintain

Stable

Secure


Better according to girlfriend l.jpg
better according to... Girlfriend

Not being late

Happy

Still have some energy left



Slide15 l.jpg

Knowledge creates good software

A professional attitude creates

better software


5 essentials l.jpg
5 essentials

  • Communication

  • Responsibility

  • Knowledge

  • Organization

  • Fun




Organization l.jpg
Organization...

  • Project

  • Development process

  • Skills

  • Project structure (file structure)

  • Code

  • Design and Architecture

  • Documentation

  • Communication

  • Infrastructure



Slide21 l.jpg

A software factory is

a professional way

of working

supported by tools


Slide22 l.jpg

Documentation

site

Source

control

Tests

Developer

2

Developer

2

Inspection

Developer

2

Developer

Reports

Documentation

Library

Build

automation

Issue reports

Corporate

Library

Custom

Delivery environments

Production

Public

Library

Acceptance

Test

Issue

management

Integration

Development







Slide28 l.jpg

Refactor without fear





Slide32 l.jpg


Slide33 l.jpg
Demo

  • Regatta Management System

  • Application to support sailing regatta's.

    • maintain regatta's

    • registration

    • enter racing data

    • results


Development goal l.jpg
Development Goal

  • Match implementation against stakeholders' concerns :

    • Functional

    • Maintainable

    • Stable

    • Budget

    • Organized

    • Fun

    • . . .



Business logic implementation l.jpg
Business Logic implementation

  • Business Logic can be implemented at many locations

    • ADF Faces components

      • Managed beans

      • Backing beans

      • EL-expressions

      • Attributes

    • Service methods

    • VO's

      • Attributes : transient, calculated

      • Methods

    • Entities

      • Attributes

      • Validators

    • Database

      • Constraints

      • Views

      • Stored procedures

    • ...


The adf challenge l.jpg
The (ADF) challenge

  • Consistent and comprehensible implementation of business logic.



Slide39 l.jpg
FD

  • Requirements

    • Maintain regatta information

    • Allow sailors / boats to enter a regatta.

      • Register skipper and captain (owner) with some personal details

    • Schedule racings

    • Easy registration of race details, only by certain people

    • Publish results

    • Nice look and feel

    • Easy to use

    • Handle handicap system

  • Business rules

    • Participant, skipper, must be older than 18

    • Same boat may enter only once

    • Finishtime after starttime

    • Participant can have only one result

    • It should be able to reset the finish of a participants, in case of error

    • Register if the boat didn't start or finish, using the common codes like DNF, DNS, DSQ etc.

      • Extra information about this situation must be entered

    • Races cannot be scheduled at the same time


Functions use cases l.jpg
Functions / Use cases

  • Maintain regatta's

  • Register for a regatta

  • Enter racing data

  • Publish results

  • Supportive functions



Adf architecture l.jpg
ADF 'architecture'

  • ADF applications tend to evolve instead of being designed.

    • Viewobjects are created when needed

    • Managed beans are created as needed

    • Application Modules function merely as a service-hatch

  • ADF doesn't force you into an organized application, except maybe the model and viewController.

  • ADF offers multiple solutions for the same problem and in the end all of them will eventually appear in the application.

JBF


Adf architecture43 l.jpg
ADF architecture

ADF Faces

ADF model (binding)

ADF BC

Database


Adf architecture44 l.jpg
ADF architecture

ADF Faces

Managed beans

ADF model (binding)

ADF BC

Application Modules

ViewObjects

Objects

Entities

Database

Stored Procedures

Views

Tables


Application integration l.jpg
Application Integration

ADF Application

Webservices

Database

Files

Notification

Messaging



Function use case approach l.jpg
Function / Use Case approach

  • The application module, the service, is the core of the application

  • Each function / use case is implemented as a service.

  • Services can be nested


Adf architecture48 l.jpg
ADF architecture

ADF Faces

Webservices

ADF model (binding)

Service

Service

Service

Service

Service

ADF BC

Webservices

Database

Files

Notification

Messaging


Slide49 l.jpg

Define the Services

(Application Modules)

first.





Datamodel 2 l.jpg
Datamodel 2

  • Views

    • 1 : 1 on tables : vpd,

    • complex queries

  • Stored procedures

  • app_owner and app_user




Development environment l.jpg
Development environment

  • JDeveloper 10g 10.1.3.4

  • JHeadstart 10g 10.1.3.3

  • Oracle 11g R1

  • OC4J 10.1.3.4

  • Maven 2.1

  • Subversion 1.5


Jdeveloper setup l.jpg
JDeveloper Setup

  • External tools

  • Encoding UTF-8

    • Preferences -> Environment

  • Upgrade JDev svn client to 1.5

    • http://technology.amis.nl/blog/5253/upgrade-jdeveloper-10g-subversion-client


Jdeveloper l.jpg
JDeveloper

  • Organize imports

  • Define .vm as text file

    • preferences -> filetypes

  • Default editors : source

    • preferences -> filetypes







Slide64 l.jpg

Business Component

Development



General l.jpg
General

  • SRDemo

  • JHeadstart framework

  • Weblogs

  • Documentation

    • Developer’s Guide For Forms/4GL Developers

  • Simple Emp reference project





Bc creation70 l.jpg
BC creation

  • Services

  • Entities

  • Associations

  • Viewobjects

  • Viewlinks

  • VO usages

  • Apply naming conventions

    • Refactor if needed

  • Organize, organize, organize


Create entities l.jpg
Create Entities

  • Create Business components from table

    • Refactor associations

  • Base on table, change later to database view


Edit entities l.jpg
Edit entities

  • Set Id from sequence

    • DBSequence is a nightmare to refactor

  • Control Hints

    • Enter once, use often


Associations l.jpg
Associations

  • Association properties

    • apply correct plural and singular

  • Define Composition Association

    • Developer’s Guide For Forms/4GL Developers - Chapter 6.3.3


Slide74 l.jpg

Business Rules

implementation


Business rules l.jpg
Business rules

Entity validation

Unique key

FE or DB or 'complex' entity

Unique key

FE function

Datamodel, domain

FE, mandatory dependency

Unique key?

Row validation


Entity business rules l.jpg
Entity Business Rules

  • Mandatory, PK, UK

  • Validation

    • Declarative

    • Method

    • Rules

      • Declare in project properties

    • Very Reusable

  • [Entity constraint]

    • NO validation

    • Only present for creating table from entity


Validators rules l.jpg
Validators / Rules

  • Create Registered Rule in project properties

    • Or reuse an existing one

  • Implement code in validateValue method


Validators l.jpg
Validators

  • Select the Rule as attribute validation

  • Test


Entity validation remarks l.jpg
Entity Validation - remarks

  • The setter immediate triggers the validation

    • actually the setAttributeInternal(...)

  • Validations are executed top to bottom

  • Row validation is performed 'independent' of attribute validation.

  • Declarative Date validators are limited

    • Use Validators

  • Using a select statement for validation is very limited (if it works at all)

    • Avoid it.

  • Consider Validator when the same validation is entered multiple times.

  • Validator exception msg not published to the front-end (as we'll see later)


J unittesting entities l.jpg
(J)Unittesting Entities

  • Create Application Module :

  • Create entity :

import oracle.jbo.client.Configuration;

RegistrationServiceImpl _am;

public void setUp() {

_am = Configuration.createRootApplicationModule

("nl.amis.demo.rms.model.services.RegistrationService"

,"RegistrationServiceLocalURL");

}

public void tearDown () {

Configuration.releaseRootApplicationModule(_am, true);

}

EntityDefImpl empdef =

(EntityDefImpl)EntityDefImpl.findDefObject

("nl.amis.demo.rms.model.entities.CrewMember");

crewMember = (CrewMemberImpl)empdef.createInstance2

(_am.getDBTransaction(), null);


Slide81 l.jpg

Date testDate = (Date)Date.getCurrentDate();

try {

crewMember.setBirthdate(testDate);

fail();

}

catch (Exception e) {

e.printStackTrace();

}

testDate = (Date)testDate.addMonths(-12*20);

try {

crewMember.setBirthdate(testDate);

}

catch (Exception e) {

fail();

e.printStackTrace();

}


Unit testing l.jpg
Unit-testing

↑ code control

↑ code quality

↓development time

  • 'Automatic' regression test

  • TDD improves the testability of your code

  • Unit-testing increases your ADF skills

  • Easy debugging of BC's

  • Automated execution at continuous integration


Unittest framework l.jpg
Unittest framework

  • TestBase per application module

    • provide ServiceImpl

  • Utility methods

    • Create entity

  • Standardization

    • Authorization

    • Context


Slide84 l.jpg

Then, how do you test your code?

I don't write unittests because it takes too much time

I'll start the application, login, navigate to the right screen and then perform the correct actions?

Gee, How long does that take?



Vo remarks l.jpg
VO Remarks

  • Often screen, Use Case driven

  • Organize

    • the number may increase rapidly

    • Separate list-only VO's

  • Apply naming conventions

    • plural

    • Lkp

    • Trnsnt

    • ...By...

  • Don't use 'automatic BC creation from database'

    • Unless you like refactoring...


Vo remarks87 l.jpg
VO remarks

  • Calculated attributes are not updated automatically, but need a requery

    • This may often result in complex code


Domain driven logic l.jpg
Domain driven logic

  • NoFinishCode

    • DSQ, DNF, DNS

  • define constants or enum

  • IsXXX attributes


Vo client interface methods l.jpg
VO client interface methods

  • Implement VO related functions

    • startRace()

    • disqualifyParticipant()

    • ..

  • Maybe also published as Service interface method

  • Beware with nested applicationmodules to bind the correct method

    • or else the getCurrentRow does not work

    • NB, bindings work ok



Viewobject validation l.jpg
Viewobject validation

  • Override validate() method

  • setter method

  • throw JboException

    • define your own


View object usages l.jpg
View object usages

  • Naming conventions

  • Organize them in services


Unittesting vo s usages l.jpg
Unittesting VO's (Usages)

  • Basic test

    • executeQuery

  • Business Logic

  • Beware of detail VO's

    • they are direct available on the AM, but relate to their parent


Programmatic viewobjects l.jpg
Programmatic viewobjects

  • e.g. for Webservice clients

  • See Developer’s Guide For Forms/4GL Developers - Chapter 9

  • JhsProgrammaticViewObject

    • getJhsProgrammaticResultSet

      • ! Executed many times

    • Override executeQuery() to actually retrieve data

    • Store result in JhsProgrammaticResultSet class variable

    • Convert using JhsProgrammaticHelper.convertBean

      • Match attributes with ws return object



Re use l.jpg
Re-use

  • Bases classes

  • Validators

  • Unittest utilities

  • Date handling

  • ADF Binding (model) methods

    • SRDemo : JSFUtils and ADFUtils

  • JHeadstart templates

  • Business Components

  • Task flows

  • Beans

  • Converters

  • Filters

  • ...


Organize re use l.jpg
Organize Re-use

  • Separate projects, libraries, and owners

  • Review / audit criteria


Reuse bc s l.jpg
Reuse BC's

  • Separate project

  • Create deliverable

  • Add jar to project

  • Import jar

  • Beware, sharing database connection from root application module


Slide99 l.jpg

Refactor without fear


Refactoring bc s l.jpg
Refactoring BC's

  • http://technology.amis.nl/blog/2859/fear-for-renaming-refactoring-adf-bc-objects-in-jdeveloper-is-not-unfounded

  • Renaming and moving BC's is handled quite well.

  • Bindings are not automatically adjusted

  • JHeadstart is not automatically updated

    • Generation errors

    • Just reselect the attribute / group

  • Try to be strongly typed


Refactoring remarks l.jpg
Refactoring remarks

  • Matching subversion clients

  • Refactoring DBSequence attributes is a pain...

  • ADF does not always allow you to refactor, in case of dependencies.

  • Validator

    • Re-registration of the Rule

  • Beware of static 'dependencies' in the JHeadstart templates



Jheadstart l.jpg
JHeadstart

  • One application definition vs. multiple

    • Can merge and split quite easily

    • 11g support for multiple improved

  • JHeadstart supports nested application modules

  • Apply standards and naming conventions

  • Configuration

    • tools -> preferences

      • e.g. item prompt

    • AppDef root node

      • AM superclass


Custom templates l.jpg
Custom Templates

  • Application hierarchy matches the default

  • Documentation of templates

  • Try to avoid hard-coded bindings

    • difficult to refactor

    • custom properties

  • Buttons can be generated

    • however, the binding is not


Common recommendations l.jpg
Common recommendations

  • Understand the framework

  • Avoid 'bindings', use a managed bean and dependencies

  • Custom bindings : Disable 'Clear Page Definition'

  • Close pagedefs before generation



Date and time l.jpg
Date and time

  • Using Java Date and Calendar and oracle.jbo.domain.Date and Timestamp can be tricky

    • new oracle.jbo.domain.Date() ?

    • new oracle.jbo.domain.Timestamp() ?

    • Date.getCurrentDate() ?

    • ((Date)Date.getCurrentDate()).timestampValue

      • actually java.sql.Timestamp

  • Current time?


Date and time calendar l.jpg
Date and time - Calendar

Calendar c = Calendar.getInstance();

oracle.jbo.domain.Timestamp ts =

new Timestamp(c.getTime());

Timestamp ts =

new Timestamp(c. getTimeInMillis());

c.set(Calendar.HOUR_OF_DAY,5)


Date time jodatime l.jpg
Date Time - JodaTime

DateTime dt = new DateTime();

Timestamp ts = new Timestamp(dt.getMillis());

DateTime dt=new Da

dt.getHourOfDay();

dt.plusMinutes(10);

dt.minusWeeks(5);

dt.isAfter(dt2);

dt.isBefore(dt2);

dt.isBeforeNow();teTime(2009,6,14,13,0,0,0)


Search programmatic viewobject l.jpg
Search Programmatic viewobject

  • Standard JHeadstart Search

    • Allows searching using the VO attributes

    • Creates 'SQL formatted' ViewCriteria

      • oracle.jheadstart.model.QueryCondition

      • unusable for Programmatic viewobject

  • Somehow retrieve actual data from viewcriteria

    • Strip the formatting

  • Provide the actual value

    • e.g. via the oracle.jheadstart.model.QueryCondition

    • Override JhsApplicationModuleImpl.advancedSearch()


Store search criteria l.jpg
Store search criteria

  • On login requery the latest search

  • Extend JhsSearchBean

  • Override advancedSearch()

    • Serialize the criteria to file

    • Use the userId as name for the file

  • Constructor

    • Retrieve the criteria from file







ad