Immutability in React and Redux

https://overreacted.io/zh-hans/a-complete-guide-to-useeffect/ 1. Invariance and side effects 1. Unchanging: Continuously create new values to replace old values 2. Invariance rules: (1) A pure function must always return the same value when given the same input (2) Pure functions cannot have any side effects 3. Side effects: modifying things outside the scope of the direct function Change/modify […]

Design principle: Immutability immutability and the Synchronization method for mutable variables

Immutability in design patterns means that the state of an object cannot be changed after it is created. This is a programming idea and design principle. In some cases, using immutable objects can bring a number of benefits: Simplify code make things very simple: Immutable objects don’t change their state after creation, so there is […]

Two characteristics of JavaStream data processing: delayed execution and immutability

When I was writing business in the company recently, I suddenly couldn’t remember how to write the accumulation in Stream? Helpless, I can only program for Google. After spending my precious three minutes, I learned it, it is very simple. Since I used JDK8, Stream is my most commonly used feature, and it is used […]

The immutability of the JUC concurrent programming sharing model (6)

6.1 Problems with date conversion SimpleDateFormat is not thread-safe @Slf4j public class SimpleDateFormatTest {<!– –> public static void main(String[] args) {<!– –> SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd”); for (int i = 0; i < 10; i ++ ) {<!– –> new Thread(() -> {<!– –> try {<!– –> log.debug(“{}”, sdf.parse(“1951-04-21”)); } catch (Exception e) {<!– […]