FS1360472174 / javaweb

java learning
8 stars 4 forks source link

代码规范 #81

Closed FS1360472174 closed 6 years ago

FS1360472174 commented 6 years ago

https://github.com/alibaba/p3c/blob/master/%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4Java%E5%BC%80%E5%8F%91%E6%89%8B%E5%86%8C%EF%BC%88%E7%BA%AA%E5%BF%B5%E7%89%88%EF%BC%89.pdf

FS1360472174 commented 6 years ago
  1. Integer这种

会有IntegerCache.cache,如果不在-128-127区间,会在堆上生成无用的数据, 所以建议使用equals方法

FS1360472174 commented 6 years ago

String str = "a,b,c,,"; 最后一个分隔符需要判断是否有内容

FS1360472174 commented 6 years ago

<? extends T>频繁向外 <? super T>频繁写入

FS1360472174 commented 6 years ago

ArrayList 循环中remove数据 Exception in thread "main" java.util.ConcurrentModificationException at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901) at java.util.ArrayList$Itr.next(ArrayList.java:851) at Test.main(Test.java:13)

FS1360472174 commented 6 years ago

写logger.isDebugEnable() { logger.debug(); }

是为了防止字符串拼接,但是又不能打印出日志

FS1360472174 commented 6 years ago

多层条件使用策略模式,状态模式重构

FS1360472174 commented 6 years ago

mysql

consts: 匹配一行 ref: 普通索引 range: 索引范围

count(*) 统计包括null的行

count(distinct col) 统计除Null以外 都是SQL92标准,与具体数据库无关

SELECT IF(IFNULL(SUM(g),0 SUM(g))

FS1360472174 commented 6 years ago

TCP协议time_wait时间默认240s, 高并发环境下,建议改小/etc/sysctl.conf net.ipv4.tcp_fin_timeout=30