Week 9
Building Multitier
Programs with
Classes
2- 2
Contents
• 1. Review to OOP
– Create properties
– Create methods
• 2. 3-tier application
• 3.Example
• 4. Exercises
2- 3
1. Review OOP
• Create class
– Menu Project->Add Class
– Chage class name
– Make properties
– Make methods
– Make events
2- 4
1. Creating Properties in a Class
• Declare all variables in a class as private
(encapsulation)
• private variable values are only
available to procedures in the class
• When objects are created from a class,
values must be assigned values and values
must be passed from the class
Creating Classes
Creating Classes
object is instantiated.
A constructor is a method that
automatically executes when an
object is instantiated.
Creating Classes
Creating Classes
2- 7
Constructors with parameters
• for some situations, we need a
constructor that accepts parameters.
• Parameters are added to a constructor in
the same way that they are added to a
method
Creating Classes
Creating Classes
2- 8
Overloading the Constructor
class Myclass
{
public Myclass(int input)
{ this.myVar = input; }
public Myclass()
{ this.myVar = 200; }
}
class Myclass
{
public Myclass(int input)
{ this.myVar = input; }
public Myclass()
{ this.myVar = 200; }
Creating Classes
Creating Classes
2- 10
Create method
• Subroutines
2- 11
Throwing and Catching
Exceptions
• The system throws an exception when an
error occurs
• Your program can catch the exception and
take an action
• You can make an exception
• Use the try/catch block to enclose code
that could cause an exception
– Exampe
Creating Classes
Creating Classes
2- 12
3-tier application
• What is 3-tier model?
• Physical & logic model
• What is business tier
• Business object & original object
• Sending message between tier-s
2- 13
2. What is 3-tier model?
Multitier Applications
• Three-tier applications are popular
– Presentation tier
2- 15
What is 3-tier model?
Multitier Applications
• Presentation tier the user interface
You can change the
method of delivery without
changing the processing
You can change the
method of delivery without
changing the processing
2- 16
What is 3-tier model?
Multitier Applications
• Data tier retrieving and storing the data
in a database
• Business tier class(es) that handle the
data
– Calculations
– Validation to enforce business rules
Object-Oriented Programming
Object-Oriented Programming
2- 17
What is 3-tier model?
More detail
2- 18
What is 3-tier model?
Presentation
• some GUI forms with which the user can
interact.
• presents information to the user, and
and the database.
• Why? DAO, RDO, ADO 1.0, ADO 2.0,
ADO.NET,???
• All-Know about data-store
2- 22
What is 3-tier model?
Data storage and management
• Database servers such as SQL Server or MS
Acccess, Oracle
• physical creation, retrieval, update, and
deletion of data.
2- 23
Physical & logic model
Framework Design
2- 24
3-tier in logic and physical
UI
Win.app
UI
Web.app
UI UI
Middle-tier
VB6, VB.Net, C#, Java
Data –tier (DAL)
VB6, VB.Net, C#, Java
Data store
Server 1
Data store
Server 3
Data store