Advanced OO Programming Methods: (Second Year of Study)
Advanced OO Programming Methods: (Second Year of Study)
Advanced OO Programming Methods: (Second Year of Study)
AMP - Course 1
OOP Design
Design Patterns UML Phases in the life-cycle of SP
GRASP
(General Responsibility Assignments Software Patterns)
AMP - Course 1 2
Some References
1. 2. 3. Eckel, B., Thinking in Java (3rd ed.), New York: Prentice Hall, 2002. Eckel, B., Thinking in Patterns with Java, MindView Inc, 2004. Gamma, E., Helm, R., Johnson, R., Vlissides, J., Design Patterns - Elements of Reusable Object-Oriented Software, Massachusets, Addison-Wesley, 1994. Larman, C.: Applying UML and Design Patterns: An Introduction to OO Analysis and Design, Berlin: Prentice Hall, 2000. Fowler, M., Patterns of Enterprise Application Architecture, Addison-Wesley, 2002. ***, The Java Tutorial, SUN Microsystems, Inc, 2004. http://java.sun.com/docs/books/tutorial/index.html UML Toolkit, H.E. Eriksson, M. Penker, Wiley &Sons
4. 5. 6. 7.
AMP - Course 1
Pure OOL
C++ hybrid object-oriented programming language
Pure approach to object-oriented programming (Alan Kay): ex. - Smalltalk Everything is an object. A program is a bunch of objects telling each other what to do by sending messages. Each object has its own memory made up of other objects. Every object has a type. All objects of a particular type can receive the same messages. (Substitutability)
JAVA Language
Why Java? Because it is
simple, object-oriented, distributed and dynamic, interpreted, robust, secure, architecture neutral, portable, high-performance, multithreaded
AMP - Course 1 5
AMP - Course 1
AMP - Course 1
AMP - Course 1
10
AMP - Course 1
11
AMP - Course 1
12
It communicates with other tiers by outputting results to the browser/client tier and all other tiers in the network.
Application tier (business logic, logic tier, domain tier, data access tier, or middle tier)
The logic tier is pulled out from the presentation tier and, as its own layer, it controls an applications functionality by performing detailed processing.
Data tier
This tier consists of database servers. Here information is stored and retrieved. This tier keeps data neutral and independent from application servers or business logic. Giving data its own tier also improves scalability and performance.
AMP - Course 1
13
Historical perspective
The three-tier architecture concept emerged in the 1990s from observations of distributed systems (e.g., web applications) where the client, middleware and data tiers ran on physically separate platforms.
AMP - Course 1
14
1. Plan and elaborate phase 2. Analyze phase 3. Design phase 4. Construct (implementation) phase
| | Build Phase |
Cycles
AMP - Course 1
16
AMP - Course 1
17
Artifacts:
Plan: schedule, resources, budget, Preliminary Investigation Report: motivation, alternatives,.. Requirements Specification: declarative statement of requirements Glossary: a dictionary of terms and any associated information Prototype: a prototype system created to aid understanding of the problem, high risk problems, and requirements. Use Cases: prose description of domain processes Use Cases Diagrams: illustration of all use cases and their relationships Draft Conceptual Model: a rough preliminary conceptual model as an aid in understanding the vocabulary of the domain
AMP - Course 1 18
AMP - Course 1
19
Category evident evident evident hidden hidden evident hidden hidden evident
20
Handle credit payments, capturing credit information evident from a card reader ar by manual entry, and authorizing payment with the stores credit authorization service via a modem connection. Handle check payments, and authorizing payment with the stores credit authorization service via a modem connection. Log credit payments to the accounts receivable system, since the credit authorization service owns the store the payment amount.
AMP - Course 1
R2.3
evident
R2.4
hidden
21
Use Cases
A use case = a narrative document that describes the sequence of events of an actor (an external agent) using a system to complete the process They illustrate and imply requirements. The UML Icon:
Buy Items
A use case is a relatively large end-to-end process description that typically includes many steps or transactions;
is it not normally an individual step or activity in a process.
AMP - Course 1 22
AMP - Course 1
23
System Response 3. Determines the item price and adds the item information to the running sale transaction. 5. Calculates and display the sale total.
AMP - Course 1
24
Cashier
Buy Items
Customer
SystemAdministrat or
Manage Users
Start Up
Manager
AMP - Course 1
25
Log In Cash Out Buy Items Refund Items Start Up Shut Down Add New Users
AMP - Course 1 26
Example Use cases: - Buy item - Add new users - Log in - Refund items - Start up - Shut down Priority High | | Medium | | Low |
AMP - Course 1
27
AMP - Course 1
28
UML(2)
UML(3)
AMP - Course 1
30
UML(4)
AMP - Course 1
31
UML(5)
AMP - Course 1
32
Author
Computer
Person
1..*
Owns Owned by
0..*
Car
Navigable Association
Person
Owns
0..*
Car
AMP - Course 1
33
Canvas
FigureId
0..*
Figure
Or-Association
0..* Insurance
Contract Insurance Company
0..* 1..*
Person
AMP - Course 1
Men
Woman
AMP - Course 1
35
Team
Contains
1..*
Player
Composition Aggregation
Window
TitleBar
*
AMP - Course 1
Menu
36
Person
Student
AMP - Course 1
37
Class B
AMP - Course 1
38
UML(6)
AMP - Course 1
39
Java features
AMP - Course 1
40
(For example, Java explicitly specifies the size of each of the primitive data types, as well as its arithmetic behavior. In C an int type can be 16, 32, or 64 bits long depending on the platform.)
AMP - Course 1
41
These features make it possible for a Java interpreter to download and run code from across the Internet (ex. Java applets)
AMP - Course 1 42
Simple
Java is a simple language
could be learned quickly the number of language constructs has been kept relatively small there are a lot of similarities with C++ A number of features available in C and C++ have been removed: No goto statement; instead there are labelled break and continue statements and exception handling. Java does not use header files and it eliminates the C preprocessor. No struct and union No operator overloading and multiple inheritance
Robust
Java is a strongly typed language extensive compile-time checking for type-mismatch problems.
Java is more strongly typed than C++. Java requires explicit method declarations; it does not support C-style implicit declarations the compiler can catch method invocation errors.
No pointers increases the robustness of Java programs by abolishing an entire class of pointer-related bugs. All accesses to arrays and strings are checked at run-time to ensure that they are in bounds, eliminating the possibility of overwriting memory and corrupting data. Casts of objects from one type to another are also checked at run-time to ensure that they are legal. Java's automatic garbage collection prevents memory leaks and other pernicious bugs related to memory allocation and de-allocation. Exception handling is another feature in Java that makes for more robust programs.
AMP - Course 1 44
Secure
Security is very important because of the distributed nature of Java. Java was designed with security in mind, and provides several layers of security controls: 1. At the lowest level, security goes hand-in-hand with robustness. 2. The Java interpreter performs on any untrusted code it loads a byte-code verification process . (These verification steps ensure that the code is well-formed--that it doesn't overflow or underflow the stack or contain illegal byte-codes, for example.) 3. The "sandbox model": untrusted code is placed in a "sandbox," where it can play safely, without doing any damage to the "real world," or full Java environment. (It is executed with some restrictions.) 4. By attaching a digital signature to Java code, the origin of that code can be established in a cryptographically secure and unforgeable way.
AMP - Course 1 45
Many Java interpreters now include "just in time" compilers that can translate Java byte-codes into machine code for a particular CPU at runtime. Java is a multithreaded language;
it provides support for multiple threads of execution that can handle different tasks.
AMP - Course 1
46
Internationalization
Internationalization is the process of designing an application so that it can be adapted to various languages and regions without engineering changes.
An internationalized program has the following characteristics: With the addition of localized data, the same executable can run worldwide. Textual elements, such as status messages and the GUI component labels, are not hardcoded in the program. Instead they are stored outside the source code and retrieved dynamically. Support for new languages does not require recompilation. Culturally-dependent data, such as dates and currencies, appear in formats that conform to the end user's region and language. It can be localized quickly.
AMP - Course 1 47
Unicode
Java characters, strings, and identifiers (e.g., variable, method, and class names) are composed of 16-bit Unicode characters. This makes Java programs relatively easy to internationalize for nonEnglish-speaking users. Since most operating environments do not support Unicode, Java uses a pre-processing phase to make sure that all of the characters of a program are in Unicode. Java defines escape sequences that allow all characters that can be represented in Unicode to be represented in other character encodings, such as ASCII or EBCDIC. Unicode defines the codes 0 through 127 to be consistent with ASCII.
char newline = '\n', apostrophe = '\", delete = '\377; char aleph='\u05D0, a = A, aa=\u0103;
AMP - Course 1
48