The of Java design pattern -- composite pattern
1. What is combination mode?
Compose objects into tree structures to represent part-whole hierarchies.Composite lets clients treat individual objects and compositions of objects uniformly.
Composite Pattern: combine objects into a tree structure to represent the "part whole" hierarchy, so that users can use single objects and compos ...
Added by shivam0101 on Mon, 29 Nov 2021 03:23:27 +0200
Object Pool Pattern
This article is excerpted from "design patterns should be learned this way"1 definition of object pool modeObject Pool Pattern is a kind of creative design pattern. After objects are created and initialized in advance and put into the object pool, the object provider can use the existing objects to process requests, reducing the memor ...
Added by quadlo on Thu, 25 Nov 2021 22:32:40 +0200
The of Java design pattern -- Decorator Pattern
1. What is decorator mode?
Attach additional responsibilities to an object dynamically keeping the same interface.Decorators provide a flexible alternative to subclassing for extending functionality.
Decorator Pattern: dynamically add additional responsibilities to an object. In terms of increasing functions, decorator pattern is more fl ...
Added by Toonster on Wed, 24 Nov 2021 16:50:22 +0200
Single example of design pattern
What is singleton mode
Singleton Pattern is one of the simplest design patterns in Java. This type of design pattern is a creation pattern, which provides the best way to create objects. The singleton pattern involves a single class that is responsible for creating its own objects while ensuring that only a single object is created. This cl ...
Added by loki1664 on Wed, 24 Nov 2021 14:46:52 +0200
There's a new way to write MVP again. I think it's very good this time. Ali's internal information
Basemvpvview is the basic View layer interface:
public interface BaseMvpView {
void showError(String msg);
void complete();
void showProgressUI(boolean isShow);
}
You can see that some public interface methods are defined. In fact, this interface may not be required, but it is generally written for convenience.
BasePresenter ...
Added by k.soule on Wed, 24 Nov 2021 02:49:22 +0200
Java Singleton Mode
Singleton Design Mode
Singleton Pattern is one of the simplest design patterns in Java. This type of design pattern is creative and provides the best way to create objects.
This pattern involves a single class that is responsible for creating its own objects while ensuring that only a single object is created. This class provides a way to ...
Added by silvrfoxx on Tue, 23 Nov 2021 22:12:11 +0200
Design pattern learning - using go to implement the responsibility chain pattern
Responsibility chain model
definition
advantage
shortcoming
Scope of application
code implementation
Responsibility chain mode vs. decoration mode
reference resources
Responsibility chain model
definition
Chain of responsibility: multiple objects have the opportunity to process the request, so as to avoid the coupling relationship between ...
Added by ShashidharNP on Mon, 22 Nov 2021 22:58:49 +0200
Refactoring the player control bar using command mode
This article is excerpted from "design patterns should be learned this way"
1 UML class diagram of command pattern
The UML class diagram of the command pattern is shown in the following figure.
2 reconstruct the player control bar using command mode
If we develop a player, the player has playback function, drag progress bar function ...
Added by spyke01 on Mon, 22 Nov 2021 19:33:18 +0200
DiffUtils encountered Kotlin and drained the last drop of performance of local refresh of the view
preface:
RecyclerView, as the most commonly used development component in Android development, does not need to use DiffUtils for simple static pages. In order to improve the rendering performance of RecyclerView, the easiest thing to think of is to use the DiffUtils component. On the one hand, only a changed Item is refreshed; On the other ha ...
Added by AMV on Mon, 22 Nov 2021 11:22:31 +0200
When Android talks about generics, everyone is very Buddhist, [Daniel crazy teaching]
public void startTest() {
Tested<Test1th> test = new Tested<>();
test.set(new Test1th());
Test1th td = test.get();
}
Very simple. What if we need Tested to hold multiple objects? Look at chestnuts:
public class Tested<A, B> {
private A a;
private B b;
public void set(A a ...
Added by davidwhiteuk on Sun, 21 Nov 2021 04:11:17 +0200