写在前面
经过一段时间设计模式的学习,发现自己非常想写点东西并且把自己之前写过的代码整理出uml图,但是考虑本人实在不愿意搞一些图框拼来拼去(主要还是懒),在加上长期使用markdown进行写作,所以希望有一款类似于markdown的工具帮助我们完成uml图.
plantUML
这个工具是网上推荐量比较大的一个工具吧,抱着试一试的态度去学习使用,学习的方式是通过阅读官网的文档(文档真的很良心,而且学习难度不是很高)
工作方式
其实只要自己尝试的安装一次就知道大概明白他的工作原理和为什么画粗来的图比较丑(吐槽下java的GUI组件)
plantUML的优势以及与其他画图工具的对比
学习过程
这里先把学习的过程放出来吧,仅供大家参考
整个过程耗时大约2h
成果展示
直接把生成的图片贴上来吧
这里是使用到的源代码
@startuml
namespace controller #DDDDDD {
class TestController {
- QuestionServicen questionService;
+ Question getQuestion(@DBExchange,int questionId);
}
TestController <--> spring.aop.DBExchangeHandler : Spring AOP
}
namespace service #DDDDDD {
interface QuestionService {
+ {abstract} Question getMessage(int questionId);
}
class DbImpl {
+ Question getMessage(int questionId);
}
class RedisImpl {
+ Question getMessage(int questionId);
}
DbImpl .up.|> QuestionService
RedisImpl .up.|> QuestionService
}
namespace spring.bean #DDDDDD {
class StateControl {
- QuestionService questionService;
- RedisImpl redisImpl;
- DbImpl dbImpl;
+ StateControl(QuestionService questionService);
+ Question getMessage(int questionId);
}
StateControl --> service.QuestionService
StateControl --> service.RedisImpl
StateControl --> service.DbImpl
}
namespace spring.aop #DDDDDD {
class DBExchangeHandler {
- StateControl stateControl;
- void before(JoinePoint joinePoint,@DBExchange dBExchange);
}
DBExchangeHandler -down-> spring.bean.StateControl : get really status for QuestionService
}
annotation DBExchange
DBExchange ... controller.TestController : label annotation
controller.TestController *--> service.QuestionService
@enduml