Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows...

64
Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance Separate teams of developers can work in Object model User interface 49

Transcript of Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows...

Page 1: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Model–View Separation

A subschema for ‘view’ classes (forms) enforces• ModelSchema knows nothing of the view• ViewSchema knows of the model through inheritance

Separate teams of developers can work in• Object model• User interface

49

Page 2: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Add controls from palette

Set properties from dialog

Painter

eventssize and positionfont and color

commonspecific

labeltext boxbuttonstatus line

50

Page 3: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Form Class

• Can have properties and methods (like a ‘model’ class)• Has references to controls and menu items on the form• Inherits from the Form and Window classes• Can be the superclass of other forms

51

Page 4: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Event Method

• Automatically invoked when an event (in right pane) happens to a control or the <form> (in middle pane)

• Is a method of the form (So ‘self’ is the form)

52

Page 5: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Lifecycle of a Form

create form;

load - paint - activate - gotFocus

form.show( );

self.unloadForm( );

queryUnload - unload53

Page 6: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Lifecycle of a Form

mnuCustomerAdd_click(menuItem : MenuItem input) updating;

vars

form : CustomerDetails;

begin

create form transient;

form.show();

end;

mnuCustomerAdd_click(menuItem : MenuItem input) updating;

vars

form : CustomerDetails;

begin

create form transient;

form.show();

end;

btnCancel_click(btn : Button input) updating;

begin

self.unloadForm();

delete self;

end;

btnCancel_click(btn : Button input) updating;

begin

self.unloadForm();

delete self;

end;

54

Page 7: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Create a Customer (1)

An event method is executed whenthe Windows event occurs.

55

Page 8: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Create a Customer (2)

A form captures information enteredby a user about a new customer

56

Page 9: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Create a Customer (3)

A model class sets (and possibly)validates information about an instance

58

Page 10: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

MDI (Multiple Document Interface)

• A form that contains other forms is an ‘MDI frame’

• An MDI frame has the menu for the application

• A form inside an MDI frame is an ‘MDI child’

MDI Frame

MDI ChildMDI Child

59

Page 11: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Adding a Menu

60

Page 12: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Form load Event

• Occurs before a form is displayed• Can be used, for example, to put text into text boxes• In this example, sets MDI Frame for application

61

Page 13: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Demonstration

Paint a form Add controls Set properties Size and align controls Test a form Code a button click event Add a menu Code a menu click event Build an MDI application

Your instructor will demonstrate how to

62

Page 14: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

• Add a BankingViewSchema

• Paint a CustomerDetails form

• Code a CustomerDetails::createCustomer method

• Code the click method for btnOK

• Code the click method for btnCancel

Challenge #9

name btnOK

caption OK

maxLength 25

name txtAddress

caption FirstNames:

caption Address:

caption LastName:

maxLength 25

name txtFirstNames

maxLength 15

name txtLastName

name btnCancel

caption Cancel

caption

name statusLine

caption Customer Details

63

Page 15: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

• Paint a MainMenu form

• Use the menu designer

• Code the click method for mnuCustomerAdd

• Code the load method for the form

• Run the form from Painter and add a customer

Challenge #10

name mnuCustomer

caption &Customer

name mnuCustomerAdd

caption &Add

caption Main Menu

mdiFrame True

64

Page 16: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Application-Related Objects

Form Objecttransient copy of persistent object designed in Painter

process

global

aForm

transient

app

transient

Global Objectpersistent object that can validate application logon

Process Objectpersistent object represents thread of execution

Application Objecttransient instance of Application subclass

65

Page 17: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

aCustomer

Objects in an Application

transient

aForm

transient

aButton

aBank

transient

app process

aCustomer

aChequeAcct

transient

aTextBox

transient

aTextBoxaSavingsAcct

aChequeAcct

aCollectionaCollection

transient

aButton aSavingsAcct

global

two objects representing an application

66

Page 18: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Application Type

• Four types– GUI– GUI, No forms– Non-GUI– Web-Enabled

• Specified on Define Application dialog67

Page 19: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Initialize and Finalize Methods

• Methods run at startup and closedown for each process• Methods in the Application class or sub class• Can use other names• Specified on Define Application dialog

68

Page 20: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Root Object

• Persistent object (singleton) that represents the business• Has ‘complete’ collections of model objects• Accessed from the app object

transient

ApplicationSubclass (app)

myBank

initialize () updating;

begin

// set reference to root object

self.myBank := Bank.firstInstance();

end;

initialize () updating;

begin

// set reference to root object

self.myBank := Bank.firstInstance();

end;

3000.1

Bank

allCustomers

// accessing collections

app.myBank.allCustomers

app.myBank.allBankAccounts

// accessing collections

app.myBank.allCustomers

app.myBank.allBankAccounts

CustomerCollection

BankAccountCollection

allBankAccounts

69

Page 21: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Security Methods

• Global class methods– getAndValidateUser– isUserValid

• Application class property– userSecurityLevel

• Form and Controls– securityLevelEnabled– securityLevelVisible

70

Page 22: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Logon Validation

getAndValidateUser(usercode : String output; password : String output): Boolean;

vars

form : Logon;

accept : Boolean;

begin

create form transient;

form.showModal();

accept := form.txtPassword.text.toLower() = 'secret';

if not accept then

app.msgBox('Please enter your password again',

'Access Denied',

MsgBox_OK_Only);

endif;

return accept;

end;

getAndValidateUser(usercode : String output; password : String output): Boolean;

vars

form : Logon;

accept : Boolean;

begin

create form transient;

form.showModal();

accept := form.txtPassword.text.toLower() = 'secret';

if not accept then

app.msgBox('Please enter your password again',

'Access Denied',

MsgBox_OK_Only);

endif;

return accept;

end;

71

Page 23: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Shortcut

c:\jadecourse\bin\jade.exe path=c:\jadecourse\system

app=BankingViewSchema

schema=BankingViewSchema

host=localhost

port=6005

server=multiuser

72

Page 24: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Demonstration

Define an application Display a message box Provide logon validation Run application from development Create an application shortcut

Your instructor will demonstrate how to

73

Page 25: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

In the BankingModelSchema

• Add a Bank class (no properties or methods yet)

• Code and execute a JadeScript::createBank method

• Add a myBank reference to BankingModelSchema

• Code a BankingModelSchema::initialize method

In the BankingViewSchema

• Modify the definition of the application to startwith MainMenu and run initialize

On the desktop

• Create a shortcut to run the application

Challenge #11

74

Page 26: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

• Paint a Logon form

• Code the btnOK_click method

• Code the getAndValidateUser method

• Test the logon security

Challenge #12

name btnOK

caption OK

caption Enter the passwordname txtPassword

passwordField True

mdiChild Not MDI form

default True

75

Page 27: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Distributed Processing

Server

Run the Application

Manage the Database

ClientClient

76

Page 28: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

JADE Database

JADE DatabaseJADE Application

77

Page 29: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

JADE Database

‘data’ objects

branches

accounts

deposits

withdrawals

‘specification’ objects

classes

methods

forms

reports

JADE Database

78

Page 30: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

JADE Database

Persistent Cache automatic storage

automatic retrieval

JADE Database

79

Page 31: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Architecture

Database Server

Internet Server(Microsoft IIS)

Fat Client(Web-Enabled Application)

HTML Client(Browser)

HTML Client(Browser)

Application ServerFat Client Fat Client

Thin Client Thin Client

Runtime Systems OnlyDevelopment and Runtime Systems

80

Page 32: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Node

Persistent Cache Transient Cache

TransientDatabase

Background Process

Process

Process

Node

81

Page 33: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Server Node

Server Node

TransientDatabase

PersistentDatabase

Background Process

Server Application Process

Server Method Process

Persistent Cache Transient Cache

Remote Transient Cache

82

Page 34: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Client Node

Client Node

TransientDatabase

Background Process

Development Process

Client Application Process

Painter Process

Debugger Process

Read-OnlySchema

User Interface

Persistent Cache Transient Cache

83

Page 35: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

AppServer Node

AppServer Node

Background Process

AppServer Application Process

Thin Client Process

Thin Client Process

Thin Client Process

TransientDatabase

Read-OnlySchema Thin Client

User Interface

CachedForms

Persistent Cache Transient Cache

84

Page 36: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Object Editions

Server Node

Persistent Database

edition=4

Node

Persistent Cache

edition=5

Node

Persistent Cache

edition=4

Node

Persistent Cache

edition=2

modified but not committed latest edition obsolete

85

Page 37: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Cache Synchronisation

Obtaining edition information

cust.edition(); // returns edition of customer in cache

cust.latestEdition(); // returns edition of customer on server

cust.edition(); // returns edition of customer in cache

cust.latestEdition(); // returns edition of customer on server

self.exclusiveLock(cust); // any lock ensures latest edition

if previousCustomerEdition <> cust.edition() then

// compare a previous edition number

self.exclusiveLock(cust); // any lock ensures latest edition

if previousCustomerEdition <> cust.edition() then

// compare a previous edition number

cust.resynch(); // customer resynchs itself

self.resynchObject(cust); // 'self' resynchs the customer

Customer.resynchInstances(); // resynchs all Customer instances

cust.resynch(); // customer resynchs itself

self.resynchObject(cust); // 'self' resynchs the customer

Customer.resynchInstances(); // resynchs all Customer instances

Locking to obtain the latest edition then checking editions

Resynching to obtain the latest edition

86

Page 38: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Demonstration

Run the JADE monitor program Run a JADE application server Run a JADE thin client Extract your schema Run the JADE loader program

Your instructor will demonstrate how to

87

Page 39: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

• Run the JADE monitor program

• Monitor ‘Users’ – processes and nodes

• Run your application from a shortcut

• Run a JADE application server

• Run JADE development in thin client

• Run a second development thin client

• Identify processes and nodes

Challenge #13

88

Page 40: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Challenge #14

Run the default application in the Architecture schema89

Page 41: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Challenge #15

• Extract your schemas

• Remove your schemas

• Run the JADE loader program

90

Page 42: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Lock Diagrams

“The process . . . . . . . . . . has a lock on . . . . . . . . the object”

Who owns the lock?

object1.exclusiveLock (object2);object1.exclusiveLock (object2);

self.exclusiveLock (object2);self.exclusiveLock (object2);

91

Page 43: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Lock Combinations

shared

shared

shared

shared

process A process B

process Cprocess D

Shared

shared

shared

reserve

shared

process A

process D

process B

process C

Reserve

exclusive

process AExclusive

92

Page 44: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Lock Durations

• Session– released when process ceases

• Transaction– released when abortTransaction or commitTransaction

93

Page 45: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Latest Edition

edition=2

Persistent CacheDatabase Server

edition=3

edition=3

successful lock edition check cache updated

resynchObject(object); // object marked as obsolete

write object.name; // edition checked so

// latest object now in cache

resynchObject(object); // object marked as obsolete

write object.name; // edition checked so

// latest object now in cache

94

Page 46: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Transactions

session

process start

beginLoad

(beginLock)

endLoad

(endLock)

read

transaction

beginTransaction

update

transaction

process end

commitTransaction

(abortTransaction)

95

Page 47: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Read Transactions

• Locks not required but must guarantee correct result. Has logical start and end.

• beginLock/endLock or beginLoad/endLoadbeginLock;

trial := trial + account.balance; // balance is a property, account is locked

endLock; // account is unlocked

beginLock;

trial := trial + account.balance; // balance is a property, account is locked

endLock; // account is unlocked

beginLock;

trial := trial + account.getBalance(); // getbalance is a method, account is locked

endLock; // account is unlocked

beginLock;

trial := trial + account.getBalance(); // getbalance is a method, account is locked

endLock; // account is unlocked

beginLoad;

sharedLock(account); // account is locked

trial := trial + account.getBalance();

endLoad; // account is unlocked

beginLoad;

sharedLock(account); // account is locked

trial := trial + account.getBalance();

endLoad; // account is unlocked96

Page 48: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Updating Transactions

edition=4

Persistent CacheDatabase Server

edition=3

edition=4

successful transaction database updated

edition=4

Persistent CacheDatabase Server

edition=3

failed transaction ‘dirty’ object discarded

97

Page 49: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Locking an Object

lock (object, type, duration, timeout);

sharedLock (object);lock (object, Share_Lock, Transaction_Duration, LockTimeout_Server_Defined);

reserveLock(object);lock(object, Reserve_Lock, Transaction_Duration, LockTimeout_Server_Defined);

exclusiveLock(object);lock(object, Exclusive_Lock,Transaction_Duration, LockTimeout_Server_Defined);

tryLock (object, type, duration, timeout);

lock (object, type, duration, timeout);

sharedLock (object);lock (object, Share_Lock, Transaction_Duration, LockTimeout_Server_Defined);

reserveLock(object);lock(object, Reserve_Lock, Transaction_Duration, LockTimeout_Server_Defined);

exclusiveLock(object);lock(object, Exclusive_Lock,Transaction_Duration, LockTimeout_Server_Defined);

tryLock (object, type, duration, timeout);

98

Page 50: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Lock Queue

Lock

Exception

ServerTimeout=10000 (10 sec)

LockQueueCheckInterval=1000 (1 sec)

Lock Queue

If lock has not been obtained

If lock cannot be obtained

immediately

99

Page 51: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Monitoring Locks

100

Page 52: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Changing a Lock

• Duration• Type

Lock could attempt to change

Guidelines Duration upgrade Duration downgrade Type upgrade

(if object is locked with a session lock, a transaction duration upgrade inside a transaction is reversed when the transaction ends)

Type downgrade outside a transaction Type downgrade in a transaction

(if object is locked with a session lock, a session duration downgrade inside a transaction is delayed until the transaction ends)

101

Page 53: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Collections and Locking

while i < collection.size() do // collection is locked

if collection.includes(object) then // collection is locked

while i < collection.size() do // collection is locked

if collection.includes(object) then // collection is locked

foreach object in collection do // collection is locked

. . .

endforeach; // collection is unlocked

iter := collection.createIterator();

while iter.next(object) do // collection is not locked

. . .

endwhile;

foreach object in collection do // collection is locked

. . .

endforeach; // collection is unlocked

iter := collection.createIterator();

while iter.next(object) do // collection is not locked

. . .

endwhile;

foreach object in collection do // collection is locked

beginTransaction;

object.update();

commitTransaction; // all locks released so collection is unlocked

endforeach;

foreach object in collection do // collection is locked

beginTransaction;

object.update();

commitTransaction; // all locks released so collection is unlocked

endforeach;102

Page 54: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Lock Exceptions

“The process . . . . . . . . tries but cannot lock . . . . . . the object”

process A process B

process A

process B

process C103

Page 55: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Lock Exception Object

LockException

lockDurationlockTimeoutlockTyperetryCounttargetLockedBy

lockTargetretryLock

initialize() updating;

begin

on LockException do app.globalLockException (exception) global;

end;

initialize() updating;

begin

on LockException do app.globalLockException (exception) global;

end;

104

Page 56: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Deadlocks

process A process B

shared

process Bprocess A

shared

exclusive

exclusive

105

Page 57: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Deadlocks Many Processes

process A process B

process D process C

106

Page 58: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Dirty Reads

Client or AppServer Node

Persistent Cacheedition=4

cache overflow partial commit ‘dirty’ object

Client or AppServer Node

Persistent Cache

Server Node

Transaction Log File Persistent Database

edition=3

edition=4

107

Page 59: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Node

Persistent Cache Transient Cache

TransientDatabase

Background Process

Process

Process

Node

108

Page 60: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

getLockStatus (object, lockType, lockDuration, lockedBy);

isLockedByMe (obj);

create lockArray transient;

system.getLocks (lockArray, max);

getLockStatus (object, lockType, lockDuration, lockedBy);

isLockedByMe (obj);

create lockArray transient;

system.getLocks (lockArray, max);

Information on Locks

109

Page 61: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Shared Transient Objects

beginTransaction;

create object persistent; // persistent

commitTransaction;

create object transient; // process transient

beginTransientTransaction;

create object sharedTransient; // shared transient

commitTransientTransaction;

beginTransaction;

create object persistent; // persistent

commitTransaction;

create object transient; // process transient

beginTransientTransaction;

create object sharedTransient; // shared transient

commitTransientTransaction;

110

Page 62: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Demonstration

Lock and unlock an object Create a lock exception Carry out a read transaction Carry out an update transaction Monitor locks Monitor queued locks Execute code and observe locking Create transient and shared transient objects Cause a deadlock exception

Your instructor will demonstrate how to

111

Page 63: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Run the default application in the TransactionAndLocking schema

Challenge #16

112

Page 64: Model–View Separation A subschema for ‘view’ classes (forms) enforces ModelSchema knows nothing of the view ViewSchema knows of the model through inheritance.

Code a CustomerDetails::isInputOK method

Challenge #17

• Return true if all text boxes contain textand false otherwise

• If a text box is empty – display a message on the statusLine – set the focus to the text box

Code a CustomerDetails::clearTextBoxes method

Modify the btnOK_click method

• Call isInputOK and return if input is not OK• If input is okay

– create the customer as before – clear text boxes – display a message on the statusLine – set focus to txtLastName

113