Presentation is loading. Please wait.

Presentation is loading. Please wait.

Concepts in General / Web Programming

Similar presentations


Presentation on theme: "Concepts in General / Web Programming"— Presentation transcript:

1 Concepts in General / Web Programming
生物資訊程式語言應用 Part 1 Concepts in General / Web Programming

2 Principle of Programming
Interface with PC Compiler / Interpreter C++ Perl Assembler Machine Code English Japanese Chinese Machine Code

3

4 Data processor model You can think of a computer as a data processor.
Is it a specific-purpose machine or a general-purpose machine?

5 Programmable data processor model
A program is a set of instructions that tells the computer what to do with data. A program is a set of instructions written in a computer language. The output data depend on the combination of two factors: the input data and the program.

6 Programming Programs must be stored A sequence of instructions
Programs are stored in computer memory. A sequence of instructions Programs must be a sequence of instructions.

7 Example Integer division? x / y = q, remainder = r What if y==0?
It will not terminate! What does the Following Program compute? The problem?

8 Programming Language 組合語言 高階語言 必須先被翻譯成機器語言後才能被電腦接受,擔任這個翻譯工作的程式叫做組譯
高階語言為程序導向語言,是專為各種應用程式而設計的語言,一個敘述就可以代表數個組合語言中的指令 C, C++, Fortran

9 Programming Language Compiler (編譯器) Interpreter (直譯器)
它會將高階語言所寫的原始程式(Source Program)轉成目的程式(Object Program)再交由電腦執行。 Interpreter (直譯器) 它將高階語言的每一敘述逐一翻譯成機器語言後直接執行,並不會產生目的程式。 原始程式 直譯器 編譯器 目的程式 執行

10 Basic語言 採用直譯器的方式,可以順利地在微電腦中運作,因而隨著微電腦的發展,BASIC語言也不斷成長。

11 Pascal語言 它是一種結構良好的程式語言,具有動態性的資料型態、遞迴性副程式功能、具有集合型態、及區域性結構等特性。

12 C語言 可以直接操控資料的每個位元。 其擁有高階語言的特性,也能產生近乎組合語言的程式碼,因此被廣泛地用來發展系統軟體或作業系統 。

13 C++ 基於C所擴充的物件導向程式語言 在類別中,可定義資料(Data member)和行為(Function member)
可以指定使用範圍為公開的(Public),或是私自的(Private) 範例:

14 JAVA 美國Sun公司於1995年發表 具備有物件導向的特性 提供了跨平台的功能 範例:

15 Levels of Abstractions

16 Why So Many Languages? Application domains have distinctive (and conflicting) needs Examples: Scientific Computing: high performance Business: report generation Artificial intelligence: symbolic computation Systems programming: low-level access Real-time systems: timing constraints Special purpose languages

17 History

18 Web Programming

19 World Wide Web WWW comprises software (Web server and browser) and data (Web sites) Client Side JavaScript VBScript DHTML Java Applets Server Side CGI ASP Java Servlets HTML, XML, ...

20 Client-Side Scripting versus Server-Side Scripting
Client-side scripts Validate user input Reduce requests needed to be passed to server Access browser Enhance Web pages with DHTML, ActiveX controls, and applets Limitations: browser dependency, viewable Server-side scripts Executed on server Generate custom response for clients Wide range of programmatic capabilities File access Access to server-side software that extends server functionality ISAPI (IIS), modules (Apache)

21 Programming Concepts

22 Fundamental Concepts Variables and data types Data structure
Assignment and operators Control Comments

23 Variables and data types
Integer Real (floating-point) Character Boolean FORTRAN INTEGER a, b REAL c, d BYTE e, f LOGICAL g, h Pascal a, b: integer; c, d: real; e, f: char; g, h: boolean; C/C++ (Java) int a, b; float c, d; char e, f; bool g, h;

24 資料型態 用以表示一個應用系統中要處理的對象 常見的資料型態 資料型態決定:
數字:整數(int)、長整數(long int)、浮點數(float)、雙精準數(double) 文字:字元(char)、字串(string) 資料型態決定: 所需空間 可表示的數值或資料範圍(參見下頁) 有意義的運算

25 C的資料型態

26 Data structure Homogeneous array Heterogeneous array
FORTRAN INTEGER a(6,3) Pascal a: array[0..5,0..2] of integer; C/C++ int a[5][2]; C/C++ struct{ char Name[25]; int Age; float SkillRating; } Employee;

27 Assignment and operators
APL a <- b + c; Ada, Pascal a := b + c; C/C++ (Java) a = b + c; Operator precedence Operator overloading

28 Control Old-fashion: goto Not recommended in modern programming
20 print “passed.” goto 70 40 if (grade < 60) goto 60 goto 20 60 print “failed.” 70 stop if (grade < 60) then print “failed.” else print “passed.”

29 Control structures

30 Control structures (contd.)

31 Comments C/C++, Java a = b + c; // This is an end-of-line comment /*
block comment */ a = b + c; /** This is a documentation comment */ a = b + c;

32 Calling a procedure

33 Terminology

34 Terminology (contd.) Procedure’s header Local vs. global variables
Formal vs. actual parameters Passing parameters Call by value (passed by value) Call by reference (passed by reference) Call by address: variant of call-by-reference.

35 Call by value procedure Demo(Formal) Formal  Formal + 1;
Demo (Actual);

36 Call by reference procedure Demo(Formal) Formal  Formal + 1;
Demo (Actual); C/C++ void Demo(int& Formal) Formal = Formal + 1;

37 Functions vs. procedures
A program unit similar to a procedure unit except that a value is transferred back to the calling program unit as “the value of the function.”

38 The translation process
Lexical analyzer: identifying tokens. Parser: identifying syntax & semantics.

39 Code generation Coercion: implicit conversion between data types
Strongly typed: no coercion, data types have to agree with each other. Code optimization x = y + z; w = x + z; w = y + (z << 1);

40 OOP Object Class Instance variables & Methods (member functions)
Active program unit containing both data and procedures Class A template from which objects are constructed An object is an instance of the class. Instance variables & Methods (member functions) Constructors Special method used to initialize a new object when it is first constructed. Destructors vs. garbage collection

41 A class sample Instance variable methods

42 Encapsulation Encapsulation
A way of restricting access to the internal components of an object Private versus public Class A { private int m1(); public int m2() { int x = m1(); return (x+1);} }; A a; a.m2();

43 Polymorphism Polymorphism
Allows method calls to be interpreted by the object that receives the call Circle circle; Rectangle rect; circle.draw(); rect.draw(); Circle(); Rectangle();

44 Inheritance Inheritance
Allows new classes to be defined in terms of previously defined classes. Class Base; Class Circle : Base; Class Rectangle : Base; Base *base; Circle circle; Rectangle rect; base = &circle; base -> draw(); base = &rect;


Download ppt "Concepts in General / Web Programming"

Similar presentations


Ads by Google