implementation considerations yonglei tao. components of coding standards 2 file header file...

19
Implementation Considerations Yonglei Tao

Upload: dwain-mills

Post on 28-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Implementation Considerations

Yonglei Tao

Page 2: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Components of Coding Standards

2

File header file location, version number, author, project,

update history Description of classes

a functional description for each class including purpose, description of methods, description of fields, and in-code comments

Conventions

Page 3: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Coding Conventions

3

Naming conventions specify rules for naming packages, modules,

paths, files, classes, attributes, functions, constants, and the like.

Formatting conventions specify formatting rules for line breaking,

indentation, alignment, and spacing. In-code comment

conventions define the requirements and guidelines for writing in-code documentation.

Page 4: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Code Review Checklist Does the program correctly implement the

functionality and conform to the design specification? Do the implemented class interfaces conform to the

interfaces specified in the design class diagrams? Does the implementation comply to the coding

standards? Compute a number of required quality metrics and

identify those that are worse than the required indicators A metrics calculation tool is very useful

Are programming constructs used correctly and properly?

4

Page 5: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Code Review Checklist Does the program correctly implement the

algorithms and data structures? Are there any errors or anomalies in the

definition and use of variables? Are there any incorrect uses of logical,

arithmetic, or relational operators, incorrect invocation of functions, incorrect interfacing to devices, or incorrect handling of device interrupts?

Are there any potential performance bottlenecks, or inability to fulfill timing constraints?

5

Page 6: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Organizing Implementation Artifacts

6

Architectural-style organization Classes are organized according to an

architectural style. Functional subsystem organization

Classes are organized according to the functional subsystems of the software system.

Hybrid organizations Architectural-style functional subsystem

organization Functional subsystem architectural-style

organization

Page 7: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

N-Tier Architecture

7

(a) Sequence diagram showing layers of a system

:Use Case GUI:Use Case Controller :Business Object :DB Mgr :Net Mgr

(b) Corresponding N-Tier architecture

GUI Controller Business Objects

Database Connectivity

Network

Page 8: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Corresponding Directory Structure

8

Page 9: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Log4J

Technical Services

Domain

UI

JessPersistence

POSRuleEngine

Inventory

PaymentsServiceAccess

PricingSales

TextSwing

SOAP

Page 10: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Copyright © The McGraw-Hill Companies, Inc.

10

Generating Code from Design Assign classes to team members according to

dependencies between classes to reduce number of test stubs

Implement classes test driven development deriving method skeleton from interaction

diagrams

Page 11: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

SalesLineItem

quantity : Integer

getSubtotal()

ProductCatalog

...

getSpecification(...)

ProductSpecification

description : Textprice : Moneyitem ID: Item ID

...

S tore

address : Addressnam e : Text

addSale(...)

Paym ent

am ount : Money

...

Contains

1..*

Contains

1..*

Register

...

endSale()enterItem (...)m akeNewSale()m akePaym ent(...)

Sale

date : DateisCom plete : Booleantim e : T im e

becom eCom plete()m akeLineItem (...)m akePaym ent(...)getTotal()

Captures

Houses

Uses

Looks-in

Paid-by

Describes

1 1

1

1 1

1

11

1

1

1

1

1

*

A dependency of Register knowing aboutProductSpecification.

Recom m ended when there is param eter,global or locally declared vis ibility.

Logs-com pleted

*

1

Design Class Diagram

Page 12: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Interaction Diagram

12

2: makeLineItem(desc, qty)enterItem(id, qty)

1: desc = getProductDesc(id) 2.1: create(desc, qty)

1.1: desc = get(id)

:Register :Sale

:ProductCatalog

sl: SalesLineItem

lineItems : List<SalesLineItem>

: Map<ProductDescription>

2.2: add(sl)

Page 13: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Creating Class Definitions from Design Class Diagrams

13

ProductCatalog

...

getProductDesc(...)

Sale

isComplete : Booleantime : DateTime

becomeComplete()makeLineItem(...)makePayment(...)getTotal()

Register

...

endSale()enterItem(id: ItemID, qty : Integer)makeNewSale()makePayment(cashTendered : Money)

public class Register{private ProductCatalog catalog;private Sale currentSale;

public Register(ProductCatalog pc) {...}

public void endSale() {...}public void enterItem(ItemID id, int qty) {...}public void makeNewSale() {...}public void makePayment(Money cashTendered) {...}}

1

1

catalog

currentSale

Page 14: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Creating Class Definitions from Design Class Diagrams

14

public class SalesLineItem{private int quantity;

private ProductDescription description;

public SalesLineItem(ProductDescription desc, int qty) { ... }

public Money getSubtotal() { ... }

}

SalesLineItem

quantity : Integer

getSubtotal() : Money

ProductDescription

description : Textprice : MoneyitemID : ItemID

...

1

description

Page 15: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Creating Method Definitions from Interaction Diagrams

2: makeLineItem(desc, qty)enterItem(id, qty)

1: desc := getProductDescription(id)

:Register :Sale

:ProductCatalog

{ ProductDescription desc = catalog.ProductDescription(id); currentSale.makeLineItem(desc, qty);}

Page 16: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Defining Collection Classes

16

SalesLineItem

quantity : Integer

getSubtotal()1..*

Sale

isComplete : Booleantime : DateTime

becomeComplete()makeLineItem()makePayment()getTtotal()

public class Sale{...

private List lineItems = new ArrayList();}

A collection class is necessary to maintain attribute visibility to all the SalesLineItems.

lineItems

Page 17: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Defining Object Creation

17

{ lineItems.add( new SalesLineItem(desc, qty) );}

2: makeLineItem(desc, qty)enterItem(id, qty)

2.1: create(desc, qty)

:Register :Sale

sl: SalesLineItemlineItems :

List<SalesLineItem>

2.2: add(sl)

Page 18: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

SalesLineItem

quantity : Integer

getSubtotal()

ProductCatalog

...

getSpecification(...)

ProductSpecification

description : Textprice : Moneyitem ID : Item ID

...

S tore

address : Addressnam e : Text

addSale(...)

Paym ent

am ount : Money

...

Contains

1..*

Contains1..*

Register

...

endSale()enterItem (...)m akeNewSale()m akePaym ent(...)

Sale

date : DateisCom plete : Booleantim e : T im e

becom eCom plete()m akeLineItem (...)m akePaym ent(...)getTotal()

Captures

Houses

Uses

Looks-in

Paid-by

Describes

1 1

1

1 1

1

11

1

1

1

1

1

*

Logs-com pleted

*

1

1

23

4

56

7

Order of Implementation

Page 19: Implementation Considerations Yonglei Tao. Components of Coding Standards 2  File header  file location, version number, author, project, update history

Test-Driven Development Create the skeleton code for the class to be

implemented identified from the Design Class Diagram has all the methods, each with an empty body

Select features and write tests for features those with high priority requirements first

Implement and test the features detect and remove errors improve code (known as refactoring) add in-code documentations

Iterate until all features are implemented Ensure test coverage

19