mrlonelyjtr's blog

写BUG的程序猿


  • Home

  • Categories

  • Archives

  • Tags

  • Search

【图解设计模式】Interpreter模式

Posted on 2019-08-31 | In Design Pattern
要解决的问题会被用非常简单的“迷你语言”表述出来,用Java语言编写一个负责“翻译”的程序。这样,当需要解决的问题发生变化时,不需要修改Java语言程序,只需要修改迷你语言程序即可应对。 迷你语言迷你语言的用途是控制无线玩具车。 前进1米(go) 右转(right) 左转(left) 重复(re ...
Read more »

【图解设计模式】Command模式

Posted on 2019-08-30 | In Design Pattern
用对象表示“命令”来保存命令历史记录和重复执行命令。 示例一个画图软件,用户拖动鼠标时程序会绘制出红色圆点,点击clear按钮后会清除所有的圆点。 类图 时序图 Command接口12345package command;public interface Command { publ ...
Read more »

[LintCode] Problem 639 - Word Abbreviation

Posted on 2019-08-29 | In Algorithm , LintCode
Given an array of n distinct non-empty strings, you need to generate minimal possible abbreviations for every word following rules below. Begin with ...
Read more »

[LintCode] Problem 634 - Word Squares

Posted on 2019-08-29 | In Algorithm , LintCode
Given a set of words without duplicates, find all word squares you can build from them. A sequence of words forms a valid word square if the kth row a ...
Read more »

【图解设计模式】总结

Posted on 2019-08-29 | In Design Pattern
Iterator模式一个一个遍历 Adapter模式加个“适配器”以便于复用 Template Method模式将具体处理交给子类 Factory Method模式将实例的生成交给子类 Singleton模式只有一个实例 Prototype模式通过复制生成实例 Builder模式组装复杂 ...
Read more »

【图解设计模式】Proxy模式

Posted on 2019-08-29 | In Design Pattern
当不一定需要本人亲自进行工作时,就可以寻找代理人去完成工作。当代理人遇到无法自己解决的事情时就会去找本人解决该问题。 示例一个带名字的打印机。 类图 时序图 Printer类123456789101112131415161718192021222324252627282930313233343536 ...
Read more »

[LintCode] Problem 888 - Valid Word Square

Posted on 2019-08-28 | In Algorithm , LintCode
Given a sequence of words, check whether it forms a valid word square. A sequence of words forms a valid word square if the k^th row and column read t ...
Read more »

[LintCode] Problem 637 - Valid Word Abbreviation

Posted on 2019-08-28 | In Algorithm , LintCode
Given a non-empty string word and an abbreviation abbr, return whether the string matches with the given abbreviation. A string such as “word” contain ...
Read more »

【图解设计模式】Flyweight模式

Posted on 2019-08-28 | In Design Pattern
通过尽量共享实例来避免new出实例。 示例将许多普通字符组合成为“大型字符”。 类图 BigChar类1234567891011121314151617181920212223242526272829303132import java.io.BufferedReader;import java.io ...
Read more »

【图解设计模式】State模式

Posted on 2019-08-27 | In Design Pattern
用类来表示状态。 示例一个警戒状态每小时会改变一次的报警系统。 类图 时序图 State接口123456public interface State { public abstract void doClock(Context context, int hour); pub ...
Read more »
1…151617…78
mrlonelyjtr

mrlonelyjtr

间歇性踌躇满志,持续性混吃等死

780 posts
18 categories
18 tags
Github
© 2020 mrlonelyjtr
Powered by Hexo
Theme - NexT.Pisces