Home 软件方法论: 抛弃 boiler plate code . (没它不行,但是它又跟核心功能无关)
Post
Cancel

软件方法论: 抛弃 boiler plate code . (没它不行,但是它又跟核心功能无关)

想读一个文件:

read "some_file.txt" # 不懂编程, 和 编程了 10年+ 的人。

# 有一定编程基础/经验的人:

   BufferedReader br = new BufferedReader(new FileReader("file.txt"));
    try {
        StringBuilder sb = new StringBuilder();
        String line = br.readLine();

        while (line != null) {
            sb.append(line);
            sb.append(System.lineSeparator());
            line = br.readLine();
        }
        String everything = sb.toString();
    } finally {
        br.close();
    }
# 高级语言:
a = 1 + 2 + 3 + 4.....
# 汇编:
DATAS SEGMENT
     n   DW ?
     sum DW ?
     DISP DB 5 DUP('$')
     MSG0 DB 'N=','$'
     MSG1 DB 'SUM=','$'
DATAS ENDS
STACK SEGMENT PARA STACK 'STACK'
      DW 200 DUP (?)
STACK ENDS
CODES SEGMENT
     ASSUME CS:CODES,DS:DATAS,SS:STACK
     START:
            MOV AX,STACK
	    MOV SS,AX
	    MOV SP,400
            MOV AX,DATAS
boilder plate code: 在所有语言里都有, 在 ruby, coffeescript, (有可能还有CSS ? ) 里是最少的。
This post is licensed under CC BY 4.0 by the author.