ARTS是什么? Algorithm:每周至少做一个LeetCode的算法题 Review:阅读并点评至少一篇英文技术文章 Tip:学习至少一个技术技巧,总结和归纳日常工作中遇到的知识点 Share:分享一篇有观点和思考的技术文章
Algorithm
完成简易正则表达式的匹配。
/*** 正则表达式* @author ouyb01* @date 2021/12/3 9:51*/public class RegularExpression {private boolean matched = false;/*** 正则表达式*/private char[] pattern;/*** 正则表达式长度*/private int patternLength;public RegularExpression(char[] pattern, int patternLength) {this.pattern = pattern;this.patternLength = patternLength;}public boolean match(char[] text, int textLength) {matched = false;rematch(0 ,0, text, textLength);return matched;}/**** @param textCurrentIndex 待匹配串当前匹配的位置* @param patterCurrentIndex 表达式当前匹配的位置* @param text 待匹配串* @param textLength 待匹配串长度*/private void rematch(int textCurrentIndex, int patterCurrentIndex, char[] text, int textLength) {// 匹配成功, 终止递归if (matched) {return;}// 正则表达式匹配完了且文本串也匹配完了if (patterCurrentIndex == patternLength) {// 这里不能合并到上一个if, 不同情况要分开讨论if (textCurrentIndex == textLength){matched = true;}return;}// *号匹配任意字符if (pattern[patterCurrentIndex] == '*') {for (int i = 0; i <= textLength - textCurrentIndex; i++) {// 从当前位置+1开始匹配, 尝试各种长度的匹配结果rematch(textCurrentIndex + i, patterCurrentIndex + 1, text, textLength);}// ?匹配0个或1个字符} else if (pattern[patterCurrentIndex] == '?') {// 匹配串不动, 表达式串前移rematch(textCurrentIndex, patterCurrentIndex + 1, text, textLength);// 匹配串和表达式串都前移rematch(textCurrentIndex + 1, patterCurrentIndex + 1, text, textLength);// 纯字符串对比必须匹配} else if (textCurrentIndex < textLength && pattern[patterCurrentIndex] == text[textCurrentIndex]) {rematch(textCurrentIndex + 1, patterCurrentIndex + 1, text, textLength);}}
Review
Ways to create objects in Java with Builder and Factory
每次都通过new object然后set值的方式会显得代码又臭又长,而且这部分代码会影响到代码的可读性,分散读者的注意力。使用builder和工厂的方式使得new object更加简洁。
Tip
架构复杂度的来源:
- 高性能
- 高可用
- 可扩展性
- 低成本、安全和规模
以前只知道双高,现在看来其实架构师的职责就是根据目前的状况选择最合适的方案,架构师做的不是设计而是取舍。
Share
我做系统架构的一些原则
最近在看系统架构相关的文章,结合耗子叔的这些原则看,收获很大,中间的内容很多都是共通的,区别就是耗子叔的文章结合实际情况更多,更容易理解。[
](https://www.yuque.com/yigenranshaodexiongmao/fgx0oh/vz15x7)
Finish
预计完成时间:2022.01.10 ~ 2022.01.16
实际完成时间:2022.01.17
