# 2018-02-24 项目/教程中使用母语命名的"问题"

At both Siemens (German) and Ericsson (Swedish), I have seen programs written in C, and C++ where the only English words are the keywords. So if, new, else, for and the standard libraries like std::vector<>
Everything else was in German or Swedish.
...

enum 发薪日 {
周一, 周二, 周三, 周四, 周五, 周六, 周日;

private static final int 每班分钟数 = 8 * 60;

int 发薪(int 工作分钟数, int 每分钟薪水) {
int 底薪 = 工作分钟数 * 每分钟薪水;
int 加班费;
switch (this) {
case 周六:
case 周日: // 周末
加班费 = 底薪 / 2;
break;
default: // 周中
加班费 = 工作分钟数 <= 每班分钟数 ? 0 : (工作分钟数 - 每班分钟数) * 每分钟薪水 / 2;
}
return 底薪 + 加班费;
}
}


enum PayrollDay {
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;

private static final int MINS_PER_SHIFT = 8 * 60;

int pay(int minutesWorked, int payRate) {
int basePay = minutesWorked * payRate;
int overtimePay;
switch (this) {
case SATURDAY:
case SUNDAY: // Weekend
overtimePay = basePay / 2;
break;
default: // Weekday
overtimePay = minutesWorked <= MINS_PER_SHIFT ? 0 : (minutesWorked - MINS_PER_SHIFT) * payRate / 2;
}
return basePay + overtimePay;
}
}


if (car.speed() > 2 * SPEED_LIMIT)


String s = "bikini";


public enum Apple  { FUJI, PIPPIN, GRANNY_SMITH }
public enum Orange { NAVEL, TEMPLE, BLOOD }


    val firstArg = if (args.length > 0) args(0) else ""
firstArg match {
case "salt" => println("pepper")
case "chips" => println("salsa")
case "eggs" => println("bacon")
case _ => println("huh?")
}


    val 参数1 = if (参数.length > 0) 参数(0) else ""
参数1 match {
case "盐" => println("胡椒")
case "玉米薄片" => println("萨尔萨辣酱")
case "鸡蛋" => println("培根")
case _ => println("啥?")
}


    val 参数1 = if (参数.length > 0) 参数(0) else ""
参数1 match {
case "牛奶" => println("面包")
case "烧饼" => println("油条")
case "煎饼果子" => println("薄脆")
case _ => println("啥?")
}


posted @ 2019-03-07 16:28  吴烜  阅读(...)  评论(...编辑  收藏