Title: SSD3 Unit 3
1- SSD3 Unit 3
- Introduction to Java Components
- Presentation 3.1A
- Website http//www.icarnegie.com
2Anatomy of a Java Application
3Java Anatomy, cont.
4Model - View Separation
- A technique known as separating the model from
the view is an important design approach when
developing a graphically-oriented application - Relates to the ModelViewController (MVC)
paradigm, which was popularized as a formal
concept with the Smalltalk language - Also known as separating the presentation logic
from the business logic
5Model - View Separation, cont.
- The model embodies the abstract domain knowledge
of the application - The objects/classes that represent the real-world
items/issues that users are familiar with - Student, Professor, Course, Section, etc.
- Their interrelationships and interdependencies
- The view is the way in which we present this
knowledge to the user typically, although not
exclusively, via a graphical user interface - There can be many different views of the same
model, in the same or different applications
6Model - View Separation, cont.
- We are focusing on programming the model in
- this course
7Desktop Applications
- The fundamental approach to desktop GUI
programming in Java is to assemble graphical
building blocks -- buttons, text fields, lists,
menus, etc. -- known as components - Java provides two built in libraries/APIs -- the
Abstract Windowing Toolkit (AWT) and Swing --
which jointly define all of the necessary
components - We assemble components in specific ways to
provide the 'look', or presentation, that we
desire for an application - We then program their 'behind the scenes' logic
to enable them to do useful things - this is
known as event handling
8Components, cont.
- Users then interact with these components to
"drive" the underlying model objects -- in our
case, Person, BankAccount, CheckingAccount, and
SavingsAccount objects -- to achieve a particular
goal - Instantiate objects
- Establish links among them
- Invoke their methods
- Change their state (attribute values)
9Sample Banking App GUI
Click here, and two objects -- a Person object
representing the user and a BankAccount object
representing the account of interest are
instantiated
10The Downside ofDesktop App. Deployment
- Desktop applications are disseminated in
executable form (byte code, in the case of Java)
to the individual workstations on which they are
to run - CWE "WinInstalls"
- There are numerous "headaches" associated with
deploying application code in this fashion
11Desktop Apps., cont.
- Issue 1 there is potentially a lot of software
infrastructure that must exist on the client
machine in order for the application to run - JVM DLLs
- "Fat client"
- Will the client machine have enough "horsepower"?
- Debugging the installation/configuration of all
of this software can be a nightmare
12Desktop Apps., cont.
- Issue 2 there are risks as to whether or not
all users will get subsequent updates after the
application is deployed - Must keep track of everyone who is using a given
application - Must alert them to new releases
- Have to rely on the user's initiative to install
or download the new version - May lose track of some users
- A configuration management/support nightmare can
ensue!
13Web Deployment
- Web deployment is an alternative to physically
distributing executable code - Whenever a user wishes to use an application,
he/she accesses the URL of the site hosting the
application via his/her web browser - The application is delivered "just in time" to
that user's browser for his or her use at that
moment -- always guaranteed to be the newest
release - Analogy distributing/watching a videotape of
daily news vs. watching "live" CNN broadcast on TV
14Web Deployment, cont.
- No specialized infrastructure is, in theory,
required to distribute applications - Use the existing Internet/intranet infrastructure
and an already present web browser - Particularly important with public domain
applications - CM problems resolved
- Code is maintained centrally
- Only those who use the application receive the
latest version just in time ("demand pull") - Conversely, people who don't receive it by
definition didn't need/use it!
15Web Deployment, cont.
- Broader potential audience for an application
- People can accidentally discover an application
if it isn't access restricted - It's no surprise that large IT organizations have
migrated toward web deployment of applications
whenever feasible
16Typical Java/WebApplication Anatomy
- Comprised of
- Static HTML forms
- Servlets (a special type of Java class)
- JSPs (a special form of HTML page)
- Helper beans (i.e., our model classes
17Java/Web Appl., cont.
- We design the application's view as a collection
of static HTML pages and/or dynamic JSPs this
comprises the view
HTML
JSP
HTML
HTML
JSP
HTML
JSP
JSP
18Java/Web Appl., cont.
- We then use a servlet as the controller/ "traffic
cop" for the web application
HTML
JSP
HTML
HTML
JSP
HTML
JSP
JSP
19Java/Web Appl., cont.
- We kick off the process by displaying a
particular page (most likely, an HTML form) ...
HTML
JSP
HTML
HTML
JSP
HTML
JSP
JSP
20Java/Web Appl., cont.
- The servlet then processes the input from that
page and, based upon the information provided by
the user, decides which page to display next
HTML
JSP
HTML
HTML
JSP
HTML
JSP
JSP
21Java/Web Appl., cont.
HTML
JSP
HTML
HTML
JSP
HTML
JSP
JSP
22Java/Web Appl., cont.
HTML
JSP
HTML
HTML
JSP
HTML
JSP
JSP
23Java/Web Appl., cont.
- The application relies on helper beans (model
classes) to render behind-the-scenes business
logic
HTML
JSP
HTML
Person
HTML
JSP
Bank Acct.
HTML
JSP
JSP
24Java/Web Appl., cont.
- These beans may in turn use JDBC to connect to an
enterprise database
HTML
JSP
HTML
Person
DBMS
HTML
JSP
Bank Acct.
HTML
JSP
JSP
25Java/Web Appl., cont.
- Most industrial strength J2EE applications can
be built using only these component technologies - HTML Forms
- JavaServer Pages
- Servlets
- Helper Beans
- JDBC connectivity to a relational database
- running under control of a Web Server
26Java/Web Appl., cont.
- For high-volume J2EE applications
- 1,000s of concurrent users
- 24 x 7 uptime
- heavy processing load
- complex, cross-server multi-stage transactions
- Enterprise JavaBeans (EJBs) and Application
- Servers may also be required
27Model-View Separation, EJB Style
client using a browser
Web server
s
JSP
stub
Your application instantiates a stub object to
use as a bean ...
28Model-View Separation, EJB Style, cont.
EJB server
client using a browser
Web server
s
EJB
JSP
stub
DB server
whereas the real "bean" (EJB) lives on a
remote server somewhere.
29Model-View Separation, EJB Style, cont.
EJB server
client using a browser
Web server
s
EJB
JSP
stub
DB server
The stub knows how to use a naming service
JNDI server
30Model-View Separation, EJB Style, cont.
EJB server
client using a browser
Web server
s
EJB
RMI
JSP
stub
DB server
to establish a connection to its remote
counterpart.
JNDI server
31Model-View Separation, EJB Style, cont.
EJB server
client using a browser
Web server
s
EJB
RMI
JSP
stub
DB server
From that point on, the stub and EJB work in
tandem to provide your application with access to
model data/business logic.
32Relevance
- Programming the model first, and then writing a
command-line driven driver program to exercise
the model, is a useful approach for debugging our
model - By tackling the view as a separate step, we
ensure loose coupling between the model and the
view - Considering the view as part of the requirements
analysis (aka a Concept of Operations) is useful,
however, for flushing out domain classes - Too many beginning Java programmers approach this
in reverse order!
33Rounding out
- Ways to "rounding out" an industrial strength
application - Providing a graphical user front end
- Using the SWING API (for standalone applications
and Web-deployed applets) - Using HTML, JavaServer Pages (JSPs), and the
Servlet API for thin-client Web-deployed
applications - Providing object persistence
- Using file I/O
- Relational databases and the JDBC API
34Example
35Questions?