Adapter mode

I. Introduction of models 1.1 definition Convert the interface of a class into another interface that the customer wants. So that those classes that cannot work together due to incompatible interfaces can work together. The adapter mode is divided into class structure mode and object structure mode. The former has a higher degree of coupling ...

Posted by Bike Racer on Sun, 13 Feb 2022 15:19:49 +0100

Design mode_ 03 six design principles

Design mode_ 03 six design principles Opening and closing principle It is open to extensions and closed to modifications. Implemented through interfaces and abstract classes. Code implementation: class Abstract_father { public: virtual void func() = 0; }; class son1 : Abstract_father { public: void func() { cout << "son1" < ...

Posted by hey_suburbia on Sun, 13 Feb 2022 09:29:43 +0100

Interface isolation principle -- give an example to illustrate the interface isolation principle in Java design pattern

Before introducing the principle of interface isolation, let's take a look at the first example in the following example - counterexample 1, Examples 1. Counterexample (1) Class diagram description Because the class diagram is relatively clear, let's look at the class diagram first As you can see, DogPlays Java and CatPlays Java impl ...

Posted by areid on Sat, 12 Feb 2022 12:50:56 +0100

Kotlin grammar manual

Kotlin grammar manual (I) When using kotlin, because the mastery is not reliable enough, it is still a habit of Java programming, which wastes the language features, convenience and indirectness provided by kotlin. When reading some Android open source libraries, it is difficult to read because many of them are written by kotlin syntax, and it ...

Posted by advancedfuture on Sat, 12 Feb 2022 07:26:33 +0100

Demitt's law realizes "high cohesion and loose coupling"

What is "high cohesion and loose coupling"?How to realize "high cohesion and loose coupling" by using Demeter's law?What code design is clearly contrary to Dimitri's law? How to reconstruct this? What is "high cohesion and loose coupling"? "High cohesion and loose coupling" is a very important design ide ...

Posted by thewooleymammoth on Fri, 11 Feb 2022 05:05:34 +0100

Comprehensive analysis of Android screen adaptation of advanced UI

preface We have finished the basic drawing of android. Now, the following two content points are the issue of event distribution, which is related to screen adaptation. In this article, we mainly come to various screen adaptation problems in android 1. Screen adaptation concept With the increase of devices supporting Android system (mobile p ...

Posted by robertaccettura on Fri, 11 Feb 2022 04:46:08 +0100

Design mode-06 builder mode

Basic introduction Separate the construction and representation of a complex object, so that the same construction process can create different representations It separates the construction of components (in the charge of Builder) and assembly (in the charge of Director), so that complex objects can be constructed. This pattern is applicable ...

Posted by 8mycsh on Fri, 11 Feb 2022 04:21:51 +0100

android development classic actual combat! Remember to regard each interview as experience accumulation, I will collect it for respect first

With the development of the Internet, the public has more understanding of the profession of programmer. In addition to high salary, there is too much pressure, black and white reversal, irregular work and rest and so on, which are also things that a programmer must experience. Most programmers are quiet and steady. If they have any question ...

Posted by CyberShot on Fri, 11 Feb 2022 00:28:09 +0100

Completely play with singleton mode

Hungry Chinese style: class is initialized when loading. There is no problem of concurrent access and there will be a waste of resourcesLazy type: delay loading and instantiate the object only when it is used. There is a problem of concurrent access and high resource utilizationDouble detection lock: the synchronized keyword is used to ...

Posted by Ruski on Thu, 10 Feb 2022 21:29:08 +0100

Design pattern: Builder Pattern

Design mode preface 1, Builder model 1. Definitions Separate the construction of a complex object from its representation, so that the same construction process can create different representations 2. Main functions When users do not know the construction process and details of objects, they can directly create complex o ...

Posted by prasad_deba on Thu, 10 Feb 2022 19:26:54 +0100