Implementation

Download Report

Transcript Implementation

Implementation Phase
• The objective of this section is to introduce how the
software design is realized as a set of programs or
program units. When you have read this section you
will:
o understand the importance of the design phase;
o know how the java templates of the design phase are
converted into java programs.
Unit 23
1
What is Implementation?
 Now we must focus on implementing the solution as
software.
 It has two distinct parts:
o writing programs that implement the design.
o conducting unit tests.
Unit 23
2
Characteristics of Good Programming
 Here we explain some of the software engineering
practices that you should keep in your mind as you write
your code.
o Naming Conventions and Coding Standards – Does the
organization have its own naming conventions and coding
standards? Does the programmer follow these naming
conventions and coding standards?
o Reusable code – Does the programmer follow the patterns
of the design so that the code is reusable?
o Documentation – Does the programmer write internal and
external documentations which are clear, crisp, and
understandable?
Unit 23
3
The Techniques of Unit Testing


Unit testing is an integral part of Implementation
Phase.
The unit testing process has two techniques:
o Static Testing
o Dynamic Testing
Unit 23
4
Static Testing

Static Testing does not require the system to be
executed.
1. It checks/reviews Software Requirements
Specification, Design documents (both architectural
and detailed design), the program source code.
2. It checks for traceability.
3. It checks for the coding standards and naming
conventions.
4. It checks whether the design methodology follows the
OO principles.
5. It checks programs for the unused or overused program
segments or variables.
Unit 23
5
Dynamic Testing

Dynamic Testing requires the system to be
executed.
1. It checks the prototypes and the program source code.
2. It checks for logical errors.
3. It checks for data validation (what will happen if the
age in the input screen is given a negative integer?).
4. It checks non – functional characteristics such as
performance, reliability, scalability, security etc.
Unit 23
6
Coding
 Now we list the corresponding java code of the java templates of
the design.
 There are two java files and one html file:
o Account.java
o Customer.java and
o Bank.html.
Unit 23
7
Account.java
public class Account{
private int balance;
public Account(int qty) {
balance = qty;
}
public void withDraw(Customer customer) {
if ( balance > 0){
balance -= 50;
customer.tellResult("Thanks for your custom-- " +"come back soon.");
}
customer.tellResult("Sorry -- your balance is nil."+" Want to depositing money?");
}
public void deposit(Customer customer) {
balance += 50;
customer.tellResult("Thanks for depositing in our bank.");
}
public int getBalance( ) {
return balance;
}
}
Unit 23
8
Customer.java
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Customer extends Applet implements ActionListener{
private final static int INITIAL_BAL = 500;
private Button theWithDrawButton;
private Button theDepositButton;
private TextField theBalance;
private TextField theMessage;
private Account account = new Account ( INITIAL_BAL );
public void init( ){
setLayout( new GridLayout(3, 1));
theWithDrawButton = new Button( "Withdraw" );
theDepositButton = new Button( "Deposit" );
theBalance = new TextField( 10 );
theMessage = new TextField( 64 );
Panel north = new Panel( );
north.setLayout(new FlowLayout( ));
north.add(theWithDrawButton);
north.add(theDepositButton);
add(north);
Panel center = new Panel( );
center.setLayout(new FlowLayout( ));
center.add(new Label("Your Balance: "));
center.add(theBalance);
theBalance.setText(new String(new Integer(INITIAL_BAL).toString()));
add(center);
Panel south = new Panel( );
south.setLayout(new FlowLayout( ));
south.add(new Label("Message: "));
south.add(theMessage);
add(south);
}
theWithDrawButton.addActionListener(this);
theDepositButton.addActionListener(this);
Unit 23
9
Customer.java - contd
public void actionPerformed( ActionEvent ae )
{
Object source = ae.getSource( );
if (source == theWithDrawButton){
account.withDraw(this);
theBalance.setText("" +new String(new
nteger(account.getBalance()).toString()));
}
else if (source == theDepositButton){
account.deposit(this);
theBalance.setText(""+new String(new
Integer(account.getBalance()).toString()));
}
}
public void tellResult(String msg){
theMessage.setText(msg);
}
}
Unit 23
10
Bank.html
<HTML>
<HEAD>
<TITLE>This is a Banking Software </TITLE>
</HEAD>
<BODY>
<H1>Welcome to <I>Riyadh Bank</I>
<BR>
This is Paul Manuel's Account
</H1>
<H4>you have an initial deposit of 500 riyals.
<HR>
To withdraw money, just press Withdraw.
To deposit money, just press Deposit
<HR></H4>
<APPLET CODE=Customer WIDTH=500 HEIGHT=150>
</APPLET>
</BODY>
</HTML>
Unit 23
11
Exercises
1.
Write a java program using SUN coding standard.
2. Write a java program using Microsoft coding standard.
3. What is Hungarian notation?
Unit 23
12