robustness analysis data layer dr. neal cis 480. review of use case
Post on 21-Dec-2015
214 views
TRANSCRIPT
Robustness AnalysisData Layer
Dr. Neal CIS 480
Review of Use Case
Use Case “Register a Seller”• Preconditions
– SELLER must not exist in system
• Use Case Description– Primary Flow:
• The SELLER is directed to a secure Web page.• The SELLER must enter a user name, password, address, telephone, and e-mail
address.• All data is is validated when the SELLER submits request.• The password should be entered twice to verify typing errors. the submit button.
– Alternate Flow:• The SELLER can cancel the registration process and return to the main page.
– Alternate Flow:• Data entered is not complete causing registration form to be redisplayed with errors
highlighted.– Alternate Flow:
• The SELLER has previously registered or a duplicate name exists causing the registration form to be redisplayed
• Postconditions– An entry for SELLER information is created in the database.– A new ACCOUNT is created for the SELLER.
“Register a Seller” UI Prototype
Incomplete data or duplicate person
DesignClasses
ObjectSequence
How do we design the access to the database with error handling?
Database Definition
ERD for Register a Seller
SELLERENTITY
PK USERID
NAMEADDRESSEMAILPHONEUPASSWORD
FK1 ACCOUNTNUMBER
SELLERACCOUNT
PK ACCOUNTNUMBER
ACCUMULATEPAYMENTDATELASTPAYMENT
Added UniqueaccountNumber as primary key
DDL for Database Creationcreate sequence acctno increment by 2;
create table selleraccount(accountnumber number(10),accumulatepayment number(12,2),datelastpayment date,constraint selleraccount_pk primary key (accountnumber));
create table sellerentity (name varchar2(20),address varchar2(40),email varchar2(40),phone varchar2(12),userid varchar2(15),upassword varchar2(15),accountnumber number(10),constraint sellerentity_pk primary key (userid),constraint selleraccount_fk foreign key (accountnumber) references selleraccount(accountnumber));
Sequence will be used to create
unique numbers
Oracle Connectivity Framework
Oracle Connectivity Overview
YourApplicationClass
OracleDatabase
OracleConnection
OracleCommand
OracleTransaction
OracleParameter
Commit/Rollback()
BeginTransaction()
Open()
Parameter.Add()
ExecuteReader()
ExecuteNonQuery()ExecuteScalar()
INSERT INTO SELLER VALUES(:PARM1, :PARM2, … )
Command String
Parameter Definition
User Id=you;Password=yourpass
Logon String
OracleDataReaderResults
Oracle Classes
OracleMethods()
ORACLE PARAMETERS
Legend
Database Access ConceptsClass Responsibilities
Registration Controller•Has Oracle Connection•Creates Command Object•Provides the Transaction Context•Handles Exceptions
SellerEntity•Fetches a Seller to Confirm•Creates new Seller
Account•Fetches a New Account Number•Creates new Account
Data Access Robustness
RegistrationController(from Business Services)
Error(from Web Interface)
Exception(from Data Services)
process
Menu(from Web Interface)
redirect
SellerEntity(from Business Domain Classes)
Account(from Business Domain Classes)
1
1
1
1
IN: transfer from Registration formOUT: seller and account created to Authentication
OracleDataReader(from Data Services)
rows ?
exception error
fetch
creates
creates
OracleCommand(from Data Services)
instanitiatesread/insert
read /insertcreate
OracleTransaction(from Data Services)
begin
11 11
OracleConnection(from Data Services)
instanitiates
1
1
1
11
1
1
1
Object Discovery and Modification
• A new page for data errors called Error.aspx is discovered
• Expanded attributes and methods for SellerEntity, RegistrationController and Account classes are found
• Oracle classes OracleConnection, OracleCommand, OracleTransaction, OracleDataReader, OracleParameter need to be added to design classes
• Exception class is needed for handling errors
Data Access Design Classes
RegistrationController
con : OracleConnectioncmd : OracleCommandtxn : OracleTransaction
cancelRegistration(resp : HttpResponse) : voidprocessRegistration(resp : HttpResponse, se SellerEntity) : voidRegistrationController()getConnected() : void
(from Business Services)
<<control>>
OracleConnection
BeginTransaction() : OracleTransactionOracleConnection(constr : string) : OracleConnectionOpen() : voidcreateCommand() : OracleCommandDispose() : void
(from Data Services)
OracleCommand
Parameters : CollectionCommandText : StringTransaction : OracleTransaction
Dispose() : voidExecuteNonQuery() : voidExecuteReader()ExecuteScalar() : StringOracleCommand() : void
(from Data Services)
Error
txtMessage : TextBoxtxtSource : TextBoxlblSource : LabellblMessage : LabelbtnClear : ButtonlblError : Label
clearErrorClick(object sender, e : EventArgs) : void
(from Web Interface)
<<boundary>>
SellerEntity
accumulatePayments : doubledataLastPayment : Datename : Stringaddress : stringemail : Stringphone : Stringuserid : Stringpassword : String
createSeller(cmd : OracleComponent, acct : Integer) : voidfetchSeller(cmd : OracleCommand) : boolSellerEntity(name : String, address : String, email : String, phone : String, userid : String, password : String)
(from Business Domain Classes)
<<entity>>
Account
accountnumber : intaccumulatepayments : doubledatelastpayment : DateTime
createAccount(cmd OracleCommand) : intfetchAccount(cmd : OracleCommand)Account()fetchAccountNumber(cmd : OracleCommand) : void
(from Business Domain Classes)
<<entity>>
1
1
1
1
OracleTransaction
Commit() : voidRollback() : voidDispose() : voidOracleTransaction()
(from Data Services)
Exception
Source : StringMessage : String
Exception(message : String) : Exception
(from Data Services)
OracleDataReader
HasRows : bool
Read() : boolOracleDataReader()
(from Data Services)
OracleComponent(from Data Services)
System.Web.UI.Page(from Web Interface)
New Attribute
New Methods
New Oracle Classes
New Exception
Class
Error Page
New Attributes
Design Sequence Diagrams
: RegistrationController : RegistrationController : Error : Error : Menu : Menu :
OracleConn... :
OracleConn... :
OracleCo... :
OracleCo... :
OracleDat... :
OracleDat... :
OracleTrans... :
OracleTrans... : SellerEntity : SellerEntity : Account : Account
1: getConnected( )
6: fetchSeller(OracleCommand)
10: Account( )
11: fetchAccountNumber(OracleCommand)
2: OracleConnection(string)
3: Open( )
4: createCommand( )
5: OracleCommand( )
7: ExecuteReader( )
8: OracleDataReader( )
9: Read( )
12: ExecuteScalar( )
13: BeginTransaction( )
14: OracleTransaction( )
15: createAccount( )
16: ExecuteNonQuery( )
17: createSeller(OracleComponent, Integer)
18: ExecuteNonQuery( )
19: Commit( )
20: Dispose( )
21: Dispose( )
22: Dispose( )
NormalFlow
Data Access
: RegistrationController : RegistrationController : Error : Error : Menu : Menu :
OracleConn... :
OracleConn... :
OracleCo... :
OracleCo... :
OracleDat... :
OracleDat... : Exception : Exception
: SellerEntity : SellerEntity
1: getConnected( )
2: OracleConnection(string)
3: Open( )
4: createCommand( )
5: OracleCommand( )
6: fetchSeller(OracleCommand)
7: ExecuteReader( )
8: OracleDataReader( )
9: Read( )
10: return
11: Exception(String)
12: Throw
13: catch
14: clearErrorClick( )
15: redirect
Duplicate Seller Alternate Flow Data Access
: Seller : Seller : RegistrationController : RegistrationController : Error : Error : Menu : Menu :
OracleConn... :
OracleConn... :
OracleCo... :
OracleCo... :
OracleDat... :
OracleDat... :
OracleTrans... :
OracleTrans... : Exception : Exception
: SellerEntity : SellerEntity : Account : Account
1: getConnected( )
6: fetchSeller(OracleCommand)
7: ExecuteReader( )
8: OracleDataReader( )
9: Read( )
10: Account( )
11: fetchAccountNumber(OracleCommand)
12: ExecuteScalar( )
2: OracleConnection(string)
3: Open( )
4: createCommand( )
5: OracleCommand( )
13: BeginTransaction( )
14: OracleTransaction( )
15: createAccount( )
17: catch exception
18: Rollback( )
19: Dispose( )
20: Dispose( )
21: Dispose( )
22: redirect
24: redirect
23: clearErrorClick( )
16: throw
DatabaseErrorFlow Data Access