设计模式概览

318人浏览 / 7人评论

设计模式的六大原则

  • 单一职责原则:一个类只做一件事儿
  • 开闭原则:对扩展开发, 对修改关闭。
  • 里氏替换原则:继承时子类完全实现基类方法
  • 依赖倒转原则:面向接口变成
  • 接口隔离原则:使用接口进行功能拆分
  • 迪米特原则:不和陌生人说话

设计模式分类

  • 创建型
    • 单例模式
      • 懒汉式
      • 饿汉式
      • double-check locking
      • 静态内部类
      • 枚举
    • 工厂模式
      • 抽象工厂模式 工厂的工厂模式
      • Spring的bean工厂
    • 建造者模式
      • 类中域较多,切可分组
      • 构建不可变对象
    • 原型模式
      • 提供模板,然后进行克隆
  • 结构型
    • 适配器模式
      • 用于兼容多种接口,平时较少使用
    • 桥接模式
      • 一个中间类,多个实现类。中间类中包含实现类,并调用实现类的具体方法,较少使用
    • 过滤器模式
      • 通过逻辑运算解耦过滤操作, 但条件过滤器,过滤条件逻辑过滤器,较少使用
    • 装饰器模式
      • 用于扩展原类功能,切面类可以理解成装饰器的一种使用。常用
    • 外观模式
      • 当某种业务较为复杂的时候,用于隐藏功能的复杂性,对外提供简单接口。service层可以理解成mapper层的外观模式。常用。
    • 享元模式
      • 缓存, 就是重复使用已经创建的对象,这个在我们系统中经常使用,比如单值代码等。常用。
    • 代理模式
      • 静态代理
      • 动态代理
        • jdk动态代理
        • cglib代理
      • Spring的bean代理
  • 行为型
    • 责任链模式
      • 重点是next
      • 最经典的使用场景是javaee中的filter
      • Java8中的Stream也是责任链的一种使用场景
    • 命令模式
      • 线程池, 每个线程就是要给命令
    • 解释器模式
      • 这种看的较多的是mybatis中的Example
    • 迭代器模式
      • List、Set都用到了这个模式,Iterator
    • 中介者模式
      • Context就是中介者, 所有的类均是与Context进行交互
      • 貌似有一个模式就叫Context模式
    • 备忘录模式
      • 就是保存对象的域,用于在遇到的时候恢复对象状态。这种模式用的较少
    • 观察者模式
      • 观察者对象中包含一个或多个接收信息的对象,在需要监听的属性的地方添加观察,当该属性变化的时候通知对应的接收对象。这个地方,观察者有点像一个消息队列。接收生产者生产的消息,推送导消费者
    • 状态模式
      • Context和State组成的一个设计模式,由State确定Context的状态。
    • 策略模式
      • 一个问题的多种实现,或者多种不同的解法
      • 比如,我们需要根据不同的法院对接不同的执行系统,只需要预先定义好规则,然后然后传入法院编号,就可以自行获取。
    • 模板模式
      • 定义模板方法
        • Servlet就是一种模板模式的使用,定义好doGet、doPost等方法实现
    • 访问者模式
      • 策略模式的一种反方向实现, 较为少用

全部评论

2020-11-17 18:17:16.0
Good day, My name is Eric and unlike a lot of emails you might get, I wanted to instead provide you with a word of encouragement – Congratulations What for? Part of my job is to check out websites and the work you’ve done with iuuxx.com definitely stands out. It’s clear you took building a website seriously and made a real investment of time and resources into making it top quality. There is, however, a catch… more accurately, a question… So when someone like me happens to find your site – maybe at the top of the search results (nice job BTW) or just through a random link, how do you know? More importantly, how do you make a connection with that person? Studies show that 7 out of 10 visitors don’t stick around – they’re there one second and then gone with the wind. Here’s a way to create INSTANT engagement that you may not have known about… Talk With Web Visitor is a software widget that’s works on your site, ready to capture any visitor’s Name, Email address and Phone Number. It lets you know INSTANTLY that they’re interested – so that you can talk to that lead while they’re literally checking out iuuxx.com. CLICK HERE http://www.talkwithwebvisitors.com to try out a Live Demo with Talk With Web Visitor now to see exactly how it works. It could be a game-changer for your business – and it gets even better… once you’ve captured their phone number, with our new SMS Text With Lead feature, you can automatically start a text (SMS) conversation – immediately (and there’s literally a 100X difference between contacting someone within 5 minutes versus 30 minutes.) Plus then, even if you don’t close a deal right away, you can connect later on with text messages for new offers, content links, even just follow up notes to build a relationship. Everything I’ve just described is simple, easy, and effective. CLICK HERE http://www.talkwithwebvisitors.com to discover what Talk With Web Visitor can do for your business. You could be converting up to 100X more leads today! Eric PS: Talk With Web Visitor offers a FREE 14 days trial – and it even includes International Long Distance Calling. You have customers waiting to talk with you right now… don’t keep them waiting. CLICK HERE http://www.talkwithwebvisitors.com to try Talk With Web Visitor now. If you'd like to unsubscribe click here http://talkwithwebvisitors.com/unsubscribe.aspx?d=iuuxx.com
2020-11-16 05:04:31.0
Hey there, I just found your site, quick question… My name’s Eric, I found iuuxx.com after doing a quick search – you showed up near the top of the rankings, so whatever you’re doing for SEO, looks like it’s working well. So here’s my question – what happens AFTER someone lands on your site? Anything? Research tells us at least 70% of the people who find your site, after a quick once-over, they disappear… forever. That means that all the work and effort you put into getting them to show up, goes down the tubes. Why would you want all that good work – and the great site you’ve built – go to waste? Because the odds are they’ll just skip over calling or even grabbing their phone, leaving you high and dry. But here’s a thought… what if you could make it super-simple for someone to raise their hand, say, “okay, let’s talk” without requiring them to even pull their cell phone from their pocket? You can – thanks to revolutionary new software that can literally make that first call happen NOW. Talk With Web Visitor is a software widget that sits on your site, ready and waiting to capture any visitor’s Name, Email address and Phone Number. It lets you know IMMEDIATELY – so that you can talk to that lead while they’re still there at your site. You know, strike when the iron’s hot! CLICK HERE http://www.talkwithcustomer.com to try out a Live Demo with Talk With Web Visitor now to see exactly how it works. When targeting leads, you HAVE to act fast – the difference between contacting someone within 5 minutes versus 30 minutes later is huge – like 100 times better! That’s why you should check out our new SMS Text With Lead feature as well… once you’ve captured the phone number of the website visitor, you can automatically kick off a text message (SMS) conversation with them. Imagine how powerful this could be – even if they don’t take you up on your offer immediately, you can stay in touch with them using text messages to make new offers, provide links to great content, and build your credibility. Just this alone could be a game changer to make your website even more effective. Strike when the iron’s hot! CLICK HERE http://www.talkwithcustomer.com to learn more about everything Talk With Web Visitor can do for your business – you’ll be amazed. Thanks and keep up the great work! Eric PS: Talk With Web Visitor offers a FREE 14 days trial – you could be converting up to 100x more leads immediately! It even includes International Long Distance Calling. Stop wasting money chasing eyeballs that don’t turn into paying customers. CLICK HERE http://www.talkwithcustomer.com to try Talk With Web Visitor now. If you'd like to unsubscribe click here http://talkwithcustomer.com/unsubscribe.aspx?d=iuuxx.com
2020-11-10 21:41:58.0
RE: iuuxx.com / 忧兮 WEBSITE SOLUTIONS This notification RUNS OUT ON: Nov 10, 2020 We have not obtained a payment from you. We have actually attempted to contact you however were incapable to reach you. Please Check Out: https://webnoticesys.com/?web=iuuxx.com For details and to make a discretionary settlement for service. Thank you. 11102020084150345435345
2020-11-07 11:23:17.0
Cool website! My name’s Eric, and I just found your site - iuuxx.com - while surfing the net. You showed up at the top of the search results, so I checked you out. Looks like what you’re doing is pretty cool. But if you don’t mind me asking – after someone like me stumbles across iuuxx.com, what usually happens? Is your site generating leads for your business? I’m guessing some, but I also bet you’d like more… studies show that 7 out 10 who land on a site wind up leaving without a trace. Not good. Here’s a thought – what if there was an easy way for every visitor to “raise their hand” to get a phone call from you INSTANTLY… the second they hit your site and said, “call me now.” You can – Talk With Web Visitor is a software widget that’s works on your site, ready to capture any visitor’s Name, Email address and Phone Number. It lets you know IMMEDIATELY – so that you can talk to that lead while they’re literally looking over your site. CLICK HERE http://www.talkwithcustomer.com to try out a Live Demo with Talk With Web Visitor now to see exactly how it works. Time is money when it comes to connecting with leads – the difference between contacting someone within 5 minutes versus 30 minutes later can be huge – like 100 times better! That’s why we built out our new SMS Text With Lead feature… because once you’ve captured the visitor’s phone number, you can automatically start a text message (SMS) conversation. Think about the possibilities – even if you don’t close a deal then and there, you can follow up with text messages for new offers, content links, even just “how you doing?” notes to build a relationship. Wouldn’t that be cool? CLICK HERE http://www.talkwithcustomer.com to discover what Talk With Web Visitor can do for your business. You could be converting up to 100X more leads today! Eric PS: Talk With Web Visitor offers a FREE 14 days trial – and it even includes International Long Distance Calling. You have customers waiting to talk with you right now… don’t keep them waiting. CLICK HERE http://www.talkwithcustomer.com to try Talk With Web Visitor now. If you'd like to unsubscribe click here http://talkwithcustomer.com/unsubscribe.aspx?d=iuuxx.com
2020-10-12 14:14:12.0
ATT: iuuxx.com / 忧兮 WEBSITE SERVICES This notice EXPIRES ON: Oct 12, 2020 We have not received a settlement from you. We've attempted to call you however were not able to contact you. Kindly Check Out: https://bit.ly/2IfCkYt . For details as well as to process a optional settlement for services. 10122020021411.
2020-09-30 08:26:57.0
My name’s Eric and I just found your site iuuxx.com. It’s got a lot going for it, but here’s an idea to make it even MORE effective. Talk With Web Visitor – CLICK HERE http://www.talkwithwebvisitors.com for a live demo now. Talk With Web Visitor is a software widget that’s works on your site, ready to capture any visitor’s Name, Email address and Phone Number. It signals you the moment they let you know they’re interested – so that you can talk to that lead while they’re literally looking over your site. And once you’ve captured their phone number, with our new SMS Text With Lead feature, you can automatically start a text (SMS) conversation… and if they don’t take you up on your offer then, you can follow up with text messages for new offers, content links, even just “how you doing?” notes to build a relationship. CLICK HERE http://www.talkwithwebvisitors.com to discover what Talk With Web Visitor can do for your business. The difference between contacting someone within 5 minutes versus a half-hour means you could be converting up to 100X more leads today! Eric PS: Studies show that 70% of a site’s visitors disappear and are gone forever after just a moment. Don’t keep losing them. Talk With Web Visitor offers a FREE 14 days trial – and it even includes International Long Distance Calling. You have customers waiting to talk with you right now… don’t keep them waiting. CLICK HERE http://www.talkwithwebvisitors.com to try Talk With Web Visitor now. If you'd like to unsubscribe click here http://talkwithwebvisitors.com/unsubscribe.aspx?d=iuuxx.com
2020-08-25 01:24:51.0
My name’s Eric and I just found your site iuuxx.com. It’s got a lot going for it, but here’s an idea to make it even MORE effective. Talk With Web Visitor – CLICK HERE http://www.talkwithwebvisitors.com for a live demo now. Talk With Web Visitor is a software widget that’s works on your site, ready to capture any visitor’s Name, Email address and Phone Number. It signals you the moment they let you know they’re interested – so that you can talk to that lead while they’re literally looking over your site. And once you’ve captured their phone number, with our new SMS Text With Lead feature, you can automatically start a text (SMS) conversation… and if they don’t take you up on your offer then, you can follow up with text messages for new offers, content links, even just “how you doing?” notes to build a relationship. CLICK HERE http://www.talkwithwebvisitors.com to discover what Talk With Web Visitor can do for your business. The difference between contacting someone within 5 minutes versus a half-hour means you could be converting up to 100X more leads today! Eric PS: Studies show that 70% of a site’s visitors disappear and are gone forever after just a moment. Don’t keep losing them. Talk With Web Visitor offers a FREE 14 days trial – and it even includes International Long Distance Calling. You have customers waiting to talk with you right now… don’t keep them waiting. CLICK HERE http://www.talkwithwebvisitors.com to try Talk With Web Visitor now. If you'd like to unsubscribe click here http://talkwithwebvisitors.com/unsubscribe.aspx?d=iuuxx.com