Bài giảng Phát triển phần mềm phân tán - Bài 1: Introduction - Vũ Thị Hương Giang

21-Oct-16  
Objectives  
•
Upon completion of this lesson, students will be  
able to  
LESSON I. Introduction  
–
–
–
–
Recall the basics of programming  
Approach the object-oriented paradigm  
Understand the Java background  
Vu Thi Huong Giang  
Install and use some basic tools for Java programming  
SoICT (School of Information and  
Communication Technology)  
HUST (Hanoi University of Science  
and Technology)  
Content  
I. Programming  
•
•
•
Programming  
Object-oriented paradigm  
Java background  
• Given a problem, how to:  
–
Design an algorithm for solving it  
–
Implement this algorithm as a computer program  
Needs of programming languages and paradigms  
Language: express the algorithm to a machine  
–
Process of programming using Java technology  
•
–
Java technology  
–
Declarative language (I): what to do, what to store  
Non declarative language (II): how to do, how to store  
•
Basic tools for Java programming  
–
WSDL  
Fortran  
I
BPEL  
II  
C/C++  
Java  
HTML  
….  
Cobol  
Basic  
PASCAL  
SQL  
Assembly  
PROLOG  
Machine code  
….  
I. Programming  
I. Programming  
•
Given a problem, how to:  
• Given a problem, how to:  
–
Design an algorithm for solving it  
–
Design an algorithm for solving it  
–
Implement this algorithm as a computer program  
–
Implement this algorithm as a computer program  
Needs of programming languages and paradigms  
Needs of programming languages and paradigms  
•
Paradigm: comprise a set of concepts that are  
used as patterns for programming  
Each language realizes  
one or more paradigms  
Each paradigm consists  
of a set of concepts  
Languages  
Paradigms  
Concepts  
Imperative  
Functional  
Logical  
Imperative  
Functional  
Logical  
First do this and next do that  
WSDL  
BPEL  
Fortran  
Class  
Object  
Method  
Evaluate an expression and use the resulting  
value for something  
C/C++  
Java  
HTML  
Cobol  
….  
Answer  
a question via search for a solution  
PASCAL  
SQL  
Send messages between objects to simulate  
Basic  
Object-oriented  
….  
Object-oriented  
….  
the temporal evolution of  
phenomena  
a
set of real world  
Assembly  
PROLOG  
….  
Machine code  
….  
1
21-Oct-16  
Object-oriented modeling  
•
•
Object in the real world are related to  
us and each other.  
They can be modeled as software  
objects  
II. OBJECT-ORIENTED  
PARADIGM  
Car  
Tom  
House  
Reality  
Flower  
Object-oriented modeling  
Model  
House lives  
1. Concepts  
2. Principles  
Car  
drives  
in  
gets  
Flower  
Tom  
Object  
Class  
•
Object in the real world is represented by:  
•
A class specifies the common  
attributes and methods of many  
–
Attributes: information about theirs states  
individual objects all of the same kind.  
–
Methods: their behaviors related to theirs states.  
•
Example  
•
Class is used as the blueprint to create  
objects  
Object  
State  
Behavior  
- Move forward  
- Speedometer: How fast is it  
moving?  
- Stop  
- Odometer: How many miles has - Reverse  
it driven?  
- ….  
- ….  
- Author: Who is the author?  
- Pages number: How many  
pages does it contain ?  
-…  
- Buy  
- Borrow  
- Count the number of  
pages….  
Example: class is  
used as the blueprint  
to create objects  
Example  
•
Objects of the real  
work that are  
unclassified  
•
•
•
Organisms  
Mammals  
Humans  
Pine tree  
Gum tree  
Pine tree  
Gum tree  
Shere Khan the tiger  
Jumbo the elephant  
Daisy the cow  
Bugs bunny  
Jane  
John  
Big Al  
12  
2
21-Oct-16  
Example: class is  
used as the blueprint  
to create objects  
2. Principles  
•
Organisms  
•
•
•
•
•
Abstraction: Hide details  
Encapsulation: Keep changes local  
Modularity: Control the information flows  
Hierarchy: Order abstractions  
Inheritance: Reuse codes  
Pine tree  
Gum tree  
•
Mammals  
•
Dangerous  
mammals  
1. History  
•
When and by whom?  
• Why Java ?  
III. JAVA BACKGROUND  
–
was created in 1991 by  
James Gosling, Patrick  
Naughton, Chris Warth,  
Ed Frank and Mike  
Sheridan of Sun  
–
–
–
Widely used.  
Widely available.  
Embraces full set of  
modern abstractions.  
–
Variety of automatic  
checks for mistakes in  
programs.  
Microsystems.  
•
Which motivation ?  
– Need of a language,  
which is independent  
from platforms and  
which could be  
embedded in various  
electronic devices such  
as interactive TVs.  
1. History  
2. Process of programming using Java technology  
3. Java technology  
2. Process of programming using Java  
technology  
a. Java as programming  
language  
•
Platform independent and object-  
oriented programming language  
Run (anywhere)  
Write (once)  
Compile  
Java source files  
Java bytecode files  
Program output  
•
Able to create all kinds of applications  
that can be created by any  
Text  
editor  
Java  
ompiler  
ava Virtual  
Machine  
conventional programming language.  
MyProg.java  
API  
Platform  
Programming  
language  
Java  
(application, development and  
deployment environment)  
JVM + Java API  
Java Virtual Machine  
Hardware-based platform  
3
21-Oct-16  
b. Java as platform: JVM + API  
Development environment  
•
•
JVM: interpretation for the Java bytecode,  
ported onto various hardware-based  
platforms.  
•
•
•
•
Compiler  
javac.exe  
java.exe  
jdb.exe  
Java API: collection of packages of classes and  
Interpreter  
Debugger  
interfaces providing useful functionalities  
These components work as  
–
–
Development environment  
Application environment and deployment  
environment  
Document  
Generator  
javadoc.exe  
of Java applications  
MyProg.java  
API  
•
•
Archiver  
jar.exe  
rt.jar  
Java Virtual Machine  
Class Library  
Hardware-based platform  
Application and deployment  
environments  
Classification of Java platform  
•
•
Java SE (Java Platform, Standard Edition)  
Aims at the development of a usual business application.  
•
Java programs run on any machine  
where the Java runtime environment  
(JRE) is installed.  
–
Java EE (Java Platform, Enterprise Edition) and  
GlassFish  
•
2 main deployment environments:  
–
Aims at the development of a decentralized application in a  
multistory layer in Internet/Intranet.  
–
The JRE supplied by the Java Software  
Development Kit (JDK 7)  
•
Java ME (Java Platform, Micro Edition)  
Aims at the development of an embedded application such  
as the cellular phone, the portable terminal, and the  
microchip, etc.  
–
–
The Java technology interpreter and  
runtime environment supplied by  
commercial web browsers.  
•
•
JavaCard  
–
Aims at the development of smart card applications.  
Etc.  
1. Java SE + text editor + console  
•
Java platform standard edition  
IV. BASIC TOOLS FOR  
JAVA PROGRAMMING  
–
Download the Java SE Development Kit 7 (JDK) at:  
–
Don’t forget to update the PATH / CLASSPATH  
environment variables  
•
•
Text editor: Notepad, Notepad++, Wordpad, etc.  
Console: for typing Java command line and  
getting results.  
1. Java SE + text editor + console  
2. IDE (Eclipse)  
4
21-Oct-16  
Exercise: first Java program using text  
editor + console  
Exercise: first Java program using text  
editor + console  
•
•
•
Compile this file by javac command  
> dir  
SayHello.java  
> javac SayHello.java  
Verify if a .class file is produced or not  
> dir  
SayHello.java  
SayHello.class  
Run the class file using java command  
> java SayHello  
Chao!  
•
Use your text editor (e.g Notepad) to create this  
code and save it in the file named SayHello.java  
public class SayHello {  
// The program starts here  
public static void main (String[] args) {  
// print "Chao!" on the screen  
System.out.println ("Chao!");  
}
}
2. Eclipse (Juno 4.2)  
Screen composition of Eclipse  
•
•
Open source Java IDE  
Features:  
compile  
and run  
–
Extension of functions through plug-ins  
–
Enhanced development assistance functions: Code  
assistance, automatic build function, refactoring,  
debugger, etc.  
Perspective  
•
Basics:  
–
Workbench: desktop development environment, each  
Editor  
contains one or more Perspectives  
–
Perspectives: Contain views and editors, menus and tool  
bars  
Console  
Lab: Create – Compile – Run a Java  
Program with Eclipse  
Creating a simple application  
•
Select File -> New -> Java Project ->. Fill in the Project  
Name as javaproject  
•
Starting screen  
–
Under Contents, select Create new project in workspace  
–
Under Project Layout , choose Create separate source and output  
folders  
–
Click Finish  
•
Create a SayHello class by selecting File -> New -> Class.  
This will bring up a New Java Class window.  
–
–
–
–
–
Fill in javaproject /src as Source folder.  
Fill in firstpackage as Package.  
Use SayHello as the Name.  
Select public static void main ... .  
Click Finish.  
5
21-Oct-16  
Creating a simple application  
Edit the code  
•
Delete the comment lines and insert a line so  
that the main method looks like this:  
public static void main(String[] args) {  
// Print Chao! on the screen  
System.out.println ("Chao!");  
}
Compile and Run  
Quiz  
•
•
Right click on SayHello and choose Run As ->  
Java Application  
A Save and Launch window may pop up.  
1. Java program is termed “Write once, run  
everywhere”. Explain.  
2. Give an example of class and objects in the real  
world.  
3. Write a program named MyFavouriteBook to  
display the information about the book you love  
(title, author, language) and why you love it.  
–
If it does, select Always save resources before launching  
(so this does not pop up again) and click OK.  
•
You should see the output in the Console window  
at the bottom of the screen.  
4. Using javac and java command to compile and  
run it  
5. Using Eclipse to create a project FirstLecture,  
them compile and run it.  
Solution  
Quiz 3-4: Solution  
public class MyFavouriteBook  
{
Quiz 1  
Quiz 2  
public static void main(String[] args)  
{
•
A Java program can be  
written on any device, for  
example a PC.  
Then, it is compiled into a  
standard byte code and be  
expected to run on any  
device such as cell phone,  
mainframe without any  
adjustments, if these  
•
Consider your marker pen.  
System.out.println("My favourite book");  
System.out.println("Title: Pride and Prejudice");  
System.out.println("Author: Jane Austen");  
System.out.println("Language: English");  
Each marker pen contains  
the same components, so  
we can say that each  
marker pen was  
manufactured from the  
same blueprint.  
Your marker pen (a specific  
pen object) is an instance of  
a class of objects known as  
marker pens. You can easily  
describe the state and  
•
System.out.println("Why do  
I love it ? I don't know.");  
}
}
•
devices are equipped with a  
Java virtual machine (JVM)  
behavior of a marker pen.  
6
21-Oct-16  
Quiz 5: Solution  
Review  
•
Programming  
Language  
–
–
Paradigm  
•
Object-oriented paradigm  
–
–
–
Object: state + behavior  
Class: blueprint for creating objects  
Principles: abstraction, encapsulation, hierarchy,  
modularity, inheritance  
•
•
Java background:  
–
Language: Java  
–
Platform: JVM + API  
Basic tools for Java programming  
–
Platform +Text editor + console  
–
Platform + IDE  
7
pdf 7 trang Thùy Anh 23580 Free
Bạn đang xem tài liệu "Bài giảng Phát triển phần mềm phân tán - Bài 1: Introduction - Vũ Thị Hương Giang", để tải tài liệu gốc về máy hãy click vào nút Download ở trên

File đính kèm:

  • pdfbai_giang_phat_trien_phan_mem_phan_tan_bai_1_introduction_vu.pdf