Building Applications in Java
Dec 21, 2015
Building Applications in Java
PROJECT MANAGEMENT
• Involves the planning, monitoring and control of the people, process and events that occur as software evolves from preliminary concept to operational implementation
• The four P’s: People, product, process, project!
• A project plan is produced as management activities commence (team work important for large enterprise applications!)
Unified Modelling Language (UML)
• Modelling is the designing of software applications before coding!
• UML helps you to specify, visualise, and document models of SS, including their structure and design!
• You can model using diagrams: application structure, dynamic behaviour and ways to organise and manage your application modules (structural diagrams, behaviour diagrams, model management diagrams)!
• You need to select a methodology and select a UML development tool!
Unified Modelling Language (UML)
• Scalability
• Robust execution
• Maintenance
• Code reuse
UML
A patient calls the clinic to make an appointment for a yearly check up. The receptionist finds the nearest empty time slot in the appointment book and schedules the appointment for that time slot
UML (Class diagrams)
UML (Packages and object diagrams)
UML
UML (Sequence diagrams)
UML (Collaboration diagrams)
UML (Statechart diagrams)
UML (Activity diagrams)
UML (Component & Deployment diagrams)
A Typical Industry Process
• Analysis– Requirements / Feasibility.
• Design– Functional Specification
• Design all input / output for the application (in a web application this would be the screens to be displayed).
• Sign off on this document before progressing to the technical design.
– Technical Design• Choose the development environment through which you are going to
deliver the application (e.g. Java with Servlets/JSP/EJB, Visual Basic / ASP, PHP etc.)
• Choose/design the architecture you will use to deliver the application (if one is necessary).
• Design the database schema for the application (the data model).• Design the main classes in the system using a class diagram (the
object model).• Describe the main interactions between these components via a set of
sequence diagrams.
A Typical Industry Process
• Implementation– Divide the developers into small teams that are responsible for
delivering parts of the application.– Perform cross-team code reviews to ensure that code follows best-
practices.– Once this phase finishes, no new functionality will be added to the
application.
• Testing– Define test scripts based upon the use cases and functional
specification.– Perform regular “builds” of the application and test each one for bugs.– Fix any bugs of existing functionality based upon tests.– Delivery of the product is at the end of this phase!
• Piloting / Maintenance– Set up a pilot of the application with a restricted user group.– Administer and monitor pilot.– Continue with bug fixing and builds.
Planning to Deliver on time
• Most delivery dates are based upon business needs.– The yearly results are posted on X; we only have enough money to last
until Christmas; …
• Planning is concerned primarily with Design and Implementation.– Estimating is difficult when you don’t know what you’re building!
• The critical phase in a software project is the development phase.– Good analysis can help to improve design.
– Good design can help to speed up development.
– Good development can reduce the amount of time needed for integration / testing.
– There is no point in spending 80% of the time designing your application if you have to deliver it in 20% of the time!
– Nothing can replace experience.
Planning to Deliver on time
• Estimating the development time.– Select an appropriate measure for the work to be
done.• For example, the number of screens/components.
– Use a metric to try to evaluate the time required per unit per phase.
• For example, the metric for the implementation of an application may be estimated as:
– Easy unit = 1 day– Medium unit = 3 days– Hard unit = 5 days.
– Evaluate the distribution of the work units.• For example, how many units are easy, how many are
medium, and how many are hard.
Example Application
• Consider a letting web application– Letting Agents post properties available to be let.
– Tenants receive details of a number of properties per week based upon some search criteria.
– Each of the user types will require their own portal where they can edit the relevant information.
Home Page
Letting AgentPortal Page
Edit TennantDetails
Forgotten Password
Register
Tennant PortalPage
Add / Edit PropertyDetails
AdministrationPage
Add / Edit LettingAgent Details
Example Application
• Work unit distribution:– Easy: Forgotten Password, Home Page– Medium: Registration, Administration Page, Add / Edit
Letting Agent Details, Letting Agent Portal Page, Add / Edit Property Page, Tenant Portal Page
– Hard: Edit Tenant Details Page
• Use metric to calculate development time:– 2 x 1 + 6 x 3 + 1 x 5 = 25 man days (or 5 weeks for one
developer)
• What about design/testing?– Estimates is 1/2/3; time for design is 17 days.– Estimate is 0.5/1/2; time for testing is 9 days.
• Other issues?– Holidays / Sick Days / Risk (increase estimate by at least 20%)
Total Time
(9 + 17 + 25) * 1.20= 62 days
or 12 man weeks
Example Application
• The estimate of 62 days does not consider business needs!– A more realistic schedule may take the form:
• One mechanism for dealing with business needs is to adjust the application scope.– This involves moving functionality to version 2 of the
product!
• However, sometimes it just comes down to late nights…
15 18 22 25 29 2 6 9 13 16 20 23
Developers Fri Mon Tue Wed Thu Fri Mon Tue Wed Thu Fri Mon Tue Wed Thu Fri Mon Tue Wed Thu Fri Mon Tue Wed Thu Fri Mon
Developer 1Developer 2Graphic Designer
Functional SpecTechnical Design
HTML Template
November December
Implementation Testing
Example Functional Specification
• The most basic features of a functional specification are:– The application screens
– The primary relationships between these screens.
• Other useful features:– Description of Validation Requirements for the screen.
• The username field may not be empty.
– Description of Information presented on the screen.• The name field holds the name of the property being displayed
– Description of Actions that are associated with the screen.• Clicking on Add New Property takes the user to the Add / Edit
Property Page• Clicking on save saves the property information and returns the
user to the Letting Agent Portal Page
Letting Agency
E-mail:
Password:
Login
Home Page
Forgotten your password?
Register
Letting AgencyWelcome Message
Letting Agency
Email Address:
OK
Forgotten Password Page
You will receive a reminder of your password by e-mail
Letting Agency
Register
Registration Page
Password:
Re-Enter Password:
Name:
E-mail:
Address:
Letting Agency
Tennant Portal Page
Edit Details
Your current search details:
Name Joe Bloggs
E-mail [email protected]
Mobile Number 0879994444
Maximum number of mails per day
5
Gender Male
Year of birth 1975
Smoker No
Pets No
Occupation Administration & Secretarial
Type of Property Apartment
Desired Lease Length No Preference
Available From Today
Minimum number of bedrooms 1
Maximum number of bedrooms No Preference
Furnishing Furnished
Parking Yes
Upper Price Limit 1600
Locations Ballsbridge, Donnybrook, Ranelagh, Clonskeagh, Bray
Occupation:
Year of Birth:
Gender:
Letting Agency
Edit Tennant Details Page
Max daily mails: 5 8 12
Male Female
Smoker: Yes No
Pets: Yes No
Desired lease length: No Preference
Type of Property: No Preference
Administration & Secretarial
Available from: Today
Minimum no
of bedrooms:
1
Maximum no
of bedrooms:No Preference
Furnishing: No Preference
Parking: Yes No
Upper Price Limit: 800
Use CTRL to make multiple selections
Save Cancel
Mobile Number:
Add Locations:
Dublin City South Ballsbridge Belfield Blackrock
City Dublin
Add
Selected Locations:
BrayRanelaghRathminesClonskeagh
Remove
Property Reference Number
Letting AgencyAdd New Property Delete Property
Letting Agent Portal Page
Location Price
00134489 Ballsbridge 1400
05634489 Donnybrook 1400
78965567 Clondalkin 1400
78986654 Bray 1500
Type
Apartment
Apartment
Apartment
House
Desired Tennant Details:
Letting AgencyCancel Save
Add / Edit Property Page
Occupation
Gender
Smoker
Pets No Preference
No Preference
No Preference
No Preference
Property Details:
Number of bedrooms
Property Type
Desired Lease Length
Available from Today
Apartment
1 year
2
Furnishings Unfurnished
Parking No
Price
Location: Dublin City South Ballsbridge Belfield Blackrock
City Dublin
Other Details
Max 93 chars
Name
Letting Agency
Add New Letting Agent Delete Letting Agent
Administration Page
Address Contact Number
Acme Estates 10,big avenue, Ballsbridge, Dublin 4 014445555
Superletters 45 acacia avenue, Donnybrook, Dublin 4 012334567
Letting AgencyCancel Save
Add / Edit Letting Agent Page
Name:
Contact Number:
Address:
The Data Model
Users
PK «column» id: INTEGER«column» emai l : VARCHAR(200)«column» password: VARCHAR(20)«column» name: VARCHAR(50)«column» address: VARCHAR(50)
+ «PK» PK_Users(INTEGER)
Roles
PK «column» id: INTEGER«column» name: VARCHAR(10)
+ «PK» PK_Roles(INTEGER)
UserRoles
PK «column» userID: INTEGERPK «column» roleID: INTEGER
+ «PK» PK_UserRoles(INTEGER, INTEGER)+ «FK» FK_UserID(INTEGER)+ «FK» FK_RoleID(INTEGER)
Tenant
PK «column» userID: INTEGER«column» numTexts: INTEGER«column» yearOfBirth: INTEGER«column» genderID: INTEGER«column» occupationID: INTEGER«column» smokerID: INTEGER«column» nopets: VARCHAR(1)«column» propertyTypeID: INTEGER«column» leaseLengthID: INTEGER«column» moveDate: DATE«column» m inBedrooms: INTEGER«column» maxBedrooms: INTEGER«column» furnishingID: INTEGER«column» upperPriceLim it: INTEGER«column» mobi leNumber: VARCHAR(20)
+ «PK» PK_Tenant(INTEGER)+ «FK» FK_TenantUserID(INTEGER)+ «FK» FK_NumTexts(INTEGER)+ «FK» FK_OccupationID(INTEGER)+ «FK» FK_PropertyType(INTEGER)+ «FK» FK_LeaseLength(INTEGER)+ «FK» FK_TFurnishingID(INTEGER)+ «FK» FK_TgenderID(INTEGER)+ «FK» FK_TsmokerID(INTEGER)
NumTexts
PK «column» number: INTEGER
+ «PK» PK_NumTexts(INTEGER)
Occupation
PK «column» id: INTEGER«column» name: VARCHAR(20)
+ «PK» PK_Occupation(INTEGER)
PropertyType
PK «column» id: INTEGER«column» name: VARCHAR(20)
+ «PK» PK_PropertyType(INTEGER)
LeaseLength
PK «column» id: INTEGER«column» name: VARCHAR(15)
+ «PK» PK_LeaseLength(INTEGER)
Region
PK «column» id: INTEGER«column» name: VARCHAR(20)
+ «PK» PK_Region(INTEGER)
Area
PK «column» id: INTEGER«column» name: VARCHAR(20)«column» regionID: INTEGER
+ «PK» PK_Area(INTEGER)+ «FK» FK_RegionID(INTEGER)
Locality
PK «column» id: INTEGER«column» name: VARCHAR(20)«column» areaID: INTEGER
+ «PK» PK_Local i ty(INTEGER)+ «FK» FK_AreaID(INTEGER)
TenantLocalities
PK «column» userID: INTEGERPK «column» local i tyID: INTEGER
+ «PK» PK_TenantLocal i ties(INTEGER, INTEGER)+ «FK» FK_TLUserID(INTEGER)+ «FK» FK_TLLocal i tyID(INTEGER)
Property
PK «column» id: INTEGER«column» lettingAgentID: INTEGER«column» genderID: INTEGER«column» occupationID: INTEGER«column» smokerID: INTEGER«column» pets: VARCHAR(1)«column» propertyTypeID: INTEGER«column» leaseLengthID: INTEGER«column» avai lable: DATE«column» numBedrooms: INTEGER«column» furnishingID: INTEGER«column» parking: VARCHAR(1)«column» price: INTEGER«column» local i tyID: INTEGER«column» detai ls: VARCHAR(93)«column» updated: DATET IME«column» deleted: DATET IME
+ «PK» PK_Property(INTEGER)+ «FK» FK_PropertyOccupationID(INTEGER)+ «FK» FK_PPropertyTypeID(INTEGER)+ «FK» FK_PLeaseLengthID(INTEGER)+ «FK» FK_PLocal i tyID(INTEGER)+ «FK» FK_LettingAgentID(INTEGER)+ «FK» FK_PFurnishingID(VARCHAR)+ «FK» FK_PgenderID(VARCHAR)+ «FK» FK_PsmokerID(INTEGER)
LettingAgent
PK «column» id: INTEGER«column» userID: INTEGER
+ «PK» PK_LettingAgent(INTEGER)+ «FK» FK_LAUserID(INTEGER)
Furnishing
PK «column» id: INTEGER«column» name: VARCHAR(15)
+ «PK» PK_Furnishing(INTEGER)
Gender
PK «column» id: INTEGER«column» name: VARCHAR(7)
+ «PK» PK_Gender(INTEGER)
Smoker
PK «column» id: INTEGER«column» name: VARCHAR(15)
+ «PK» PK_Smoker(INTEGER)
+FK_PropertyOccupationID
+PK_Occupation+FK_UserID
+PK_Users
+FK_RoleID
+PK_Roles
+FK_TenantUserID
+PK_Users
+FK_NumTexts
+PK_NumTexts
+FK_OccupationID
+PK_Occupation
+FK_PropertyType
+PK_PropertyType
+FK_LeaseLength
+PK_LeaseLength
+FK_RegionID
+PK_Region
+FK_AreaID
+PK_Area
+FK_TgenderID
+PK_Gender
+FK_TLLocal i tyID
+PK_Local i ty
+FK_PsmokerID
+PK_Smoker
+FK_PPropertyTypeID
+PK_PropertyType+FK_PLeaseLengthID
+PK_LeaseLength
+FK_PLocal i tyID
+PK_Local i ty
+FK_LettingAgentID
+PK_LettingAgent
+FK_LAUserID
+PK_Users
+FK_TFurnishingID
+PK_Furnishing
+FK_PFurnishingID
+PK_Furnishing
+FK_PgenderID
+PK_Gender
+FK_TsmokerID
+PK_Smoker
+FK_TLUserID
+PK_Tenant
The Object Model
helper::LettingAgentHelper
+ createProperty(PropertyDataBean) : long+ getProperty(long) : PropertyDataBean+ setProperty(PropertyDataBean) : void+ deleteProperty(long) : void+ getPropertyList(long) : PropertyList+ getRegionIDForLocal i ty(long) : long
«ejb»ej b::PropertyEntityBean
- id: long- lettingAgentID: long- genderID: long- occupationID: long- nonsmoker: boolean- nopets: boolean- propertyTypeID: long- leaseLengthID: long- avai lable: Calendar- numBedrooms: int- furnishingID: long- parking: boolean- price: long- local i tyID: long- updated: Calendar- modified: boolean
+ ejbCreate(PropertyDataBean) : PropertyPK+ ejbLoad() : void+ ejbStore() : void+ ejbActivate() : void+ ejbPassivate() : void+ getPropertyDataBean() : PropertyDataBean+ setPropertyDataBean(PropertyDataBean) : void+ findByPrimaryKey(long) : PropertyPK
dto::PropertyDataBean
- id: long- lettingAgentID: long- genderID: long- occupationID: long- nonsmoker: boolean- nopets: boolean- propertyTypeID: long- leaseLengthID: long- avai lable: Calendar- numBedrooms: int- furnishingID: long- parking: boolean- price: long- local i tyID: long
«ejb»ej b::PropertySessionBean
+ getPropertyList(long) : PropertyList+ getMatchingProperties(long) : PropertyList+ getRegionIDForLocal i ty(long) : long
helper::PropertyMatcherHelper
+ getMatchingProperties(long) : PropertyList
dto::PropertyList
+ getID() : long+ getLocal i tyID() : long+ getPropertyTypeID() : long+ getPrice() : long+ newInstance() : PropertyList
dto::PropertyListRecord
- id: long- local i tyID: long- properyTypeID: long- price: long
helper::StaticLookupHelper
- propertyTypeData: StaticData
+ getPropertyType(long) : String+ getPropertyTypeList() : ArrayList+ resetPropertyTypes() : void
dto::StaticData
- l ist: ArrayList- map: HashMap
+ getValue(long) : String+ getDataList() : ArrayList+ newInstance(rs) : StaticData
dto::StaticDataRecord
- id: long- value: String
ej b::StaticDataSessionBean
+ getPropertyType() : StaticData
«value object»v alueobj ect::LettingAgentPortalValueObj ect
- l ist: ArrayList- current: int
+ next() : boolean+ getID() : long+ getLocal i ty() : String+ getPropertType() : String+ getPrice() : long+ populate() : void
v alueobj ect::LettingAgentPortalDetails
- id: long- local i ty: String- propertyType: String- price: long
+ newInstance(long, String, String, long) : PropertyListDetai ls
action::LoginAction
+ ini t(HttpServletRequest) : void+ execute() : int
v alueobj ect::AddEditPropertyValueObj ect
- nonsmoker: boolean- nopets: boolean- occupationID: long- propertyTypeID: long- leaseLengthTypeID: long- avai lable: Calendar- numBedrooms: int- furnishingID: long- parking: boolean- price: long- regionID: long- local i tyID: long- genderHTML: String- smokerHTML: String
+ populate() : void
action::LettingAgentPortalAction
- properties: ArrayList
+ ini t(HttpServletRequest) : void+ execute() : int
helper::TenantHelper
+ createTenant(TenantDataBean) : long+ getTenant(long) : TenantDataBean
dto::TenantDataBean
- userID: long- mobi leNumber: String- numberTexts: long- yearOfBirth: long- genderID: long- occupationID: long- smokerID: long- petsID: long- propertyTypeID: long- leaseLengthID: long- moveDate: Calendar- m inBedrooms: long- maxBedrooms: long- furnishingID: long- upperPriceLim it: long- local i tyIDs: ArrayList
ej b::TenantEntityBean
- userID: long- mobi leNumber: String- numberTexts: long- yearOfBirth: long- genderID: long- occupationID: long- smokerID: long- petsID: long- propertyTypeID: long- leaseLengthID: long- moveDate: Calendar- m inBedrooms: long- maxBedrooms: long- furnishingID: long- upperPriceLim it: long- updated: Calendar- modified: boolean- local i tyIDs: ArrayList
+ ejbCreate(TenantDataBean) : void+ ejbLoad() : void+ ejbStore() : void+ setTenant(TenantDataBean) : void+ getTenant() : TenantDataBean
ValueObj ectBase
ActionBase
Sequence Diagrams
User
Home Page
Control ler
:LoginAction
Invoker
«value object»
:LettingAgentPortalValueObject
LettingAgentPortalPage
submit login info
request(actionID=LoginAction)
create
ini t(request)
executeAction(action)
execute
resul t
getNextPage
getValueObject
create
populate
valueObject
forward(request)
Sequence Diagrams
{whi le propertyList.next() is true}
«value object»
:LettingAgentPortalValueObject
:LettingAgentHelper
:PropertyList
:LettingAgentPortalDetai ls
setT i tle("Letting Agent Portal")
getPropertyList(lettingAgentID)
newInstance()
propertyList
getXXXnewInstance(price,type,local i ty,id)
Implementing the Code
• Package Structure– Common Practice is to use the inverse of your companies
domain name.• E.g. the example application base package may take the form:
ie.ucd.lettingagency
– All the code for the application should appear within one or more subpackages of this base package.
• E.g. database access code should be placed in:
ie.ucd.lettingagency.database
Application architecture code should be placed in:
ie.ucd.lettingagency.architecture
– There should be as few a number of dependencies between these packages as possible.
Implementing the Code