Design principle of design pattern

Seven design principles Single responsibility A single responsibility is that each method is responsible for one thing. Reduce the coupling and encapsulate the method. public class Test2 { public static String loadFile(String fileName) throws IOException { // FileReader reader = new FileReader("D:\Bilysen Java\idea\java ...

Posted by LeeReed on Sat, 18 Sep 2021 00:33:53 -0700

php visitor pattern implementation

summary Visitor pattern: represents an operation that acts on elements in an object structure. It allows you to define new operations on elements without changing their classes. This paper takes the motorcycle manufacturer as an example. Due to market competition and long-term development, we hope that the company can have the ability of moto ...

Posted by mmarif4u on Fri, 17 Sep 2021 19:09:52 -0700

Intermediary model of design model

Smart home project The family can only include all kinds of equipment: alarm clock, coffee machine, TV, curtains, etc.When the host wants to watch TV, various devices can work together to automatically complete the preparation for watching TV. For example: the alarm clock rings - > the coffee machine starts making coffee - > the curtains ...

Posted by xmarcusx on Fri, 17 Sep 2021 16:50:55 -0700

Design mode: decorator mode

In the future, I will update some documents on the introduction, application and principle of design patterns. If you think it's useful to yourself, pay attention. introduction The examples in this article are as simple as possible to avoid a lot of useless code in some examples when I usually check the data, which makes people feel unab ...

Posted by bw on Wed, 15 Sep 2021 15:49:29 -0700

Bridging mode of design mode

Basic introduction Bridging mode means that the implementation and abstraction are placed in two different class levels, so that the two levels can be changed independentlyIt is a structural design modeBased on the minimum design principle of classes, different classes assume different responsibilities by using encapsulation, aggregation and i ...

Posted by ksimpkins on Tue, 14 Sep 2021 21:05:41 -0700

Observer mode of design mode

In the real world, many objects do not exist independently, and a change in the behavior of one of them may lead to a change in the behavior of one or more other objects. For example, when the price of a commodity rises, some businesses are happy and consumers are sad. Also, when we drive to an intersection, we stop at a red light and go ...

Posted by findapollo on Tue, 14 Sep 2021 09:41:22 -0700

Visitor model -- the generation gap between young and middle-aged people

Introduction Xiaoshuai is 25 years old and Lao Wang is 35 years old. One day, Xiaoshuai and Lao Wang discussed the increasingly obvious difference between young and middle-aged people. Xiao Shuai listed several scenarios. At the same time, Xiao Shuai, as the representative of young people, and Lao Wang, as the representative of middle-age ...

Posted by Stanza on Sun, 12 Sep 2021 20:39:11 -0700

Paint of advanced UI (filter, color channel, matrix operation)

preface In previous classes, we have learned about the whole android program in detail, from Startup to painting. From this, we have involved the Canvas drawing board and our Paint control color style brush. Then we will not explain in detail in the previous basic chapter. Those API s have been published in the previous basic chapter, I also a ...

Posted by CantonWeb on Wed, 08 Sep 2021 15:00:26 -0700

The way of software design pattern -- iterator pattern

  In software design, we often need to access the elements of aggregate objects. Because the traversal method may change. Therefore, the access method cannot be written directly in the aggregate object, because it will violate the "opening and closing principle". Keep it simple. The beginning is, think about it   Java   ...

Posted by jaxdevil on Tue, 07 Sep 2021 15:40:08 -0700

Java foundation - single case (hungry man, lazy man), how programmers deal with the middle-aged crisis

3. Timer (Master) * Timer class:timer public class Demo5_Timer { /** * @param args * timer * @throws InterruptedException */ public static void main(String[] args) throws InterruptedException { Timer t = new Timer(); t.schedule(new MyTimerTask(), new Date(114,9,15,10,54,20),3000); wh ...

Posted by frenchy373 on Mon, 06 Sep 2021 22:17:27 -0700