An interview was asked about ArrayMap, the principle and source code analysis in detail

1, Foreword In SparseArray detailed explanation and source code analysis, we are familiar with the basic usage, characteristics and implementation principle of SparseArray. There is also an equally important data structure ArrayMap in the toolkit of the Android SDK. Its purpose is to replace HashMap when the amount of data is small, such as hu ...

Posted by signer on Wed, 19 Jan 2022 07:47:22 +0100

Design mode - appearance mode (facade mode)

Appearance mode: also known as "facade mode", it belongs to structural design mode. It is one of the relatively simple, common and widely used design modes. The main purpose is to simplify client requests by providing delegate calls to methods in existing systems definition If the external wants to communicate with the internal, it ...

Posted by jason257 on Wed, 19 Jan 2022 05:47:50 +0100

The scope function in Kotlin is enough

This article mainly shares the usage and differences of Kotlin's scope functions let, run, with, apply and also. During the execution of scope function, a temporary scope is formed through lambda expression, which can reduce the number of some logic codes. Context object: this or it this run, with, and apply reference context objects wi ...

Posted by BenS on Wed, 19 Jan 2022 01:50:47 +0100

Here comes the squid game. Now let's start. Let's see what level you've passed.

Here comes the squid game. Now let's start. Let's see what level you've passed. Without the aid of IDE, see whether your human flesh compiler can compile the correct results. Scala-like functions fun hello() = { println("Hello, World") } hello() a). Does not compile b). Prints "Hello, World" c). Nothing d). Something el ...

Posted by TRUSTINWEB on Tue, 18 Jan 2022 14:36:33 +0100

On JavaScript Design Pattern

Preliminary study on design mode Singleton mode Variables are defined internally and judged by closures. If they do not exist, new variables are generated Strategy mode Consistent with the principle of single responsibilityAdd or reduce strategies without major changes to the original codeThere are many ways to deal with the same ...

Posted by karldenton on Tue, 18 Jan 2022 13:15:47 +0100

Mode 23: (single row mode)

catalogue Singleton design pattern Introduction to single example design mode Eight ways of single case design mode Hungry Han formula (static constant) Hungry Chinese (static code block) Lazy (thread unsafe) Lazy (thread safety, synchronization method) Lazy (thread safe, synchronous code block) Static inner class enumeration Source ...

Posted by mellowman on Tue, 18 Jan 2022 01:54:51 +0100

[design mode from introduction to mastery] 19 interpreter mode

Note source: Shang Silicon Valley Java design pattern (illustration + framework source code analysis) Interpreter mode 1. Four arithmetic problems Four operations are realized through the interpreter mode, such as calculating the value of a + b - c. specific requirements 1) First enter the form of the expression, such as a + b + c - d + e. t ...

Posted by marque on Mon, 17 Jan 2022 20:39:05 +0100

[design mode from introduction to mastery] 21 - strategy mode

Note source: Shang Silicon Valley Java design pattern (illustration + framework source code analysis) Strategy mode 1. Duck problem Prepare the duck project, and the specific requirements are as follows: 1) There are ducks (such as wild ducks, Peking ducks, water ducks, etc. ducks have various behaviors, such as barking, flying, etc.) 2) Dis ...

Posted by txmedic03 on Mon, 17 Jan 2022 18:25:21 +0100

Learning design patterns: creating design patterns

1, Singleton mode 1. Applicable scenarios Only 1 object is required for the project 2. Advantages and disadvantages &Advantages: (1) Reduce memory expenses. For frequently used objects, they are always created and destroyed, which takes up a lot of memory (2) Reduce the performance overhead. When the generation of an object requires mo ...

Posted by Ju-Pao on Mon, 17 Jan 2022 09:19:24 +0100

Enumeration of ingenious alternatives to if - else

Scenario: when some data needs to be received and processed in our project, because they come from different channels (such as Alibaba and Tencent), different channels need different processing methods. Let's write a common Demo to realize the scenario. 1. First, build an abstract class of basic rules, GeneralChannelRule, and define an abstrac ...

Posted by popcop on Mon, 17 Jan 2022 06:32:32 +0100