跳到主要內容

發表文章

Gradle(1) -- 介紹

歷史介紹 當我們發展軟體過程由需求訪談、編寫程式、編譯、測試、打包,發佈,我們希望可以自動化將這些重複繁雜的步驟,這些工具幫我們完成自動化任務,可以稱為建構語言。建構語言必須由make腳本開始說起,在早期C語言,當專案發展到一定的大小,會漸漸出現瓶頸,這時make工具的誕生解決的這些大專案的問題,主要他解決的一個專案的編譯規則,定義哪些文件需要編譯、哪先不需要編譯等等。在Java程式語言Ant編譯工具想必很多人不陌生,在2000年所誕生,主要是使用XML去定義編譯編譯規則,但是發展一段時間,會發現他無法檢查系統模組相依性。這時為了解決相依問題才發展Ivy來輔助Ant編譯工具。Maven也是常耳聞的編譯工具之一,主要的優點透過一定的約定形式去撰寫編譯規則,但是缺點是當專案太大會使您的pom.xml過於忙亂,而無法正常工作。 專案自動化優點      (1) 防止人為錯誤      (2) 更容易建構專案      (3) 維持軟體品質 Gradle誕生原因 Gradle主要結合Ant和Maven的優點而誕生,主要有下列的優點 (1) 使用動態語言(Domain Specific Language,DSL)代替靜態語言,支援Groovy語言。 (2) 可以準確的編譯每個程式 (3) 解決編譯時的相依問題,富有彈性 (4) 支援多個專案建製,可以解決各專案之間的相依性 (5) gradle支援Ant和Maven的腳本 Gradle 安裝 (1) Gradle安裝需要的套件      A. Java JDK 6.0以上 :   http://www.oracle.com/technetwork/java/javase/downloads/index.html      B. Gradle安裝檔: http://gradle.org/gradle-download/ (2) Gradle安裝套件      A. gradle-[version]-all.zip : 包含原始檔,執行檔...

Python Study (8) – Function

Introduction Function is a Python’s basic structure. Function often is used to reuse code. you can repeat task that define a function for code reuse. Function Advantage  (1) Maximizing code reuse and minimizing redundancy      In developing software,  don't repeat yourself is a a principle . We use function to achieve the goal in Python.A section code is adopted many times or offer other to use. We need to package to a function and offer many time for reuse . (2) Procedural decomposition A flow program is combined from Function component  (1) def Syntax def name(arg1, arg2….) :     statements … Example def add(a, b):            print(a+b) >>>add(1,2) 3 (2) return Syntax def name(arg1, arg2….) :     statements … return result Example def add(a, b): return a+b >>>print(add(1,2)) 3 (3) lambda      lambda is...

Python Study (7) – Statements

Introduction Programming statements are used to expresse action or assign a variable in program.Each statement  has own syntax and purpose. We can combine these statements to achieve specific purpose. Assignment Statements Assingment statement is used to set reference of object or value stored in monery address by a variable name. (1) normal assignment : fruit = “apple” (2) sequence assignment:  a,b = 'Jack', 'John' (3) List assignment : (4) Augmented assignment:      >>>a =1      >>>a+=1 (5) Sequence assignment Sequence one to one >>>seq = [1, 2, 3, 4] >>> a,b,c,d = seq >>> a,b = seq  #seq have 4 elements, but assignemnt elements just have 2 Traceback (most recent call last):   File "<pyshell#9>", line 1, in <module>     a,b = seq ValueError: too many values to unpack (expected 2) >>> a,b,c,d = seq >>>a 1 Sequence one and rest...

Python Study (4)– Dynamic type

Introduction In many programs, You need to declare data type to tell compiler, but  you don’t do it  in Python. It are determined automatically at runtime.   >>> a = “hellow ”    # without delcaring data type            Assigning variable  1. Create an object 2. Create an variable 3. Create reference variable to object Example : The example create a variable and named “a”, then assign enough space to the object. the variable link to the object as reference. >>> a = “hellow ”                Example: The float object is value 1.2 and tell python the object is a float-point-number at first assignment. >>> a =  1.2          # first assign >>> a =  2             # second reassign...

Python Study (5)– String Type

Introduce to string type  ASCII is a sample form of Unicode text, but many text may be not non-English-text source.File working in two modes are  text and bytes ,We need to understand differnt of String of object type in Python3.X and Python 2.X.  Python3.X :     (1) str           : handle text of Unicode form     (2) bytes       : handle binary data     (3) bytearray : handle mutable variant of bytes Python2.x:    (1) str           :  handle 8-bits text and binary data    (2) unicode    :  hanlde Unicode text    (3) bytearray  : handle mutable variant of bytes. ( support 2.6 or later) 1.String Basics  Everything is string.String can be used to represent informations of all kinds(e.g. profile, song…), these informations can be encoded a...

JAVA 字串格式化

應 用 時 機  在日常生活中,常看到文字的格式為日期、時間、貨幣或是特定格式輸出等等,在Java中可以使用formatter來自訂字串的格式。我們可以分為這五種轉換形態 1. 常規 : 一般文字格式 2. 字元 : 顯示字元的型態,char、byte、short 3. 日期/時間 : 用來輸出date、time、calendar等等 4. 百分比: 輸出百分比型態,以百分比表示 ”%” 5. 換行符號: 換行符號(\n) 6. 數字: 用來可以輸出數字 1.常 規 格 式 化  格式符號 說明 - 最小寬度內左對齊,不可0使用 # 用在8進位與16進位的表式 + 空白 正號加空格,負號加- 0 不足填零補足 , 每三位數字,加上, ( 參數為負,以括號把數字刮起來 以下實例可以指定輸出的對象,這種特殊格式以%index$來做指定,下列範例是將a和b對調顯示 p ublic static void main(String[] args) {       //宣告變數       int a = 10 ;       int b = 20 ;       int c = 30 ;             System.out.printf("%d %d %d \n",a,b,c);   //正常顯示             //使用format物件       Formatter format = new Formatter() ;       System.out.println(format.format("%2$d %1$d %3$d", a, b, c))...