Skip to content

Instantly share code, notes, and snippets.

View wendyltan's full-sized avatar
🎯
Focusing

Wendyltanpcy wendyltan

🎯
Focusing
View GitHub Profile
@wendyltan
wendyltan / refactor.md
Last active June 21, 2018 16:35
What is Refactor and how we do it?

Refactoring

What is Refactoring?

The external behavior of the system does not change while the internal structure of the system is improved.

Sometimes called "Improving the design after it has been written" or "Improving the design of existing code",the purpose is to make software easier to understand and modify

  • Benefits
  • Code size reduced after refactoring
@wendyltan
wendyltan / Java-Innerclass.md
Created June 15, 2018 11:02
What is Inner class in Java?

Inner Class in Java

Defining a class inside another class is called 'Inner Class' in Java.There are four types of inner Class: Type:

  • Member Inner Class
  • Partial Inner Class
  • Anonymous Inner Class
  • Static Inner Class

Member Inner Class

@wendyltan
wendyltan / Java-Lock.md
Last active June 12, 2018 02:13
Why is Lock better than synchronized?

Why is Lock better?

The limit of synchronized and the benefit of Lock

Synchronized block will only release the lock when:

  • Thread executed the block and release the lock.
  • Thread has an exception and JVM auto release the lock.
  • Thread turn into WAITING state while using wait(),it will release the lock.
@wendyltan
wendyltan / Java-IO.md
Last active June 11, 2018 09:10
What are all these I/O classes?

Java-I/O

I want to talk about Java-I/O in this gist,so I will try to be as detailed as I can.I don't really understand how each I/O class works until I learned them systematically.

Category

  • I/O
    • NodeStream
      • Character
  • Reader -- FileReader
@wendyltan
wendyltan / Sleep-Wait.md
Created June 6, 2018 13:03
Sleep And Wait,difference and when to use?

sleep,wait and notify

What's the difference between sleep and wait?

Just see this table:

sleep wait
belong to class Thread belong to class Object
will not release object lock will release object lock
@wendyltan
wendyltan / Java-Generics.md
Last active June 11, 2018 13:27
Generic stuff in Java...

About some Generic type knowledge in Java

Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods, or with a single class declaration, a set of related types, respectively.

Generics also provide compile-time type safety that allows programmers to catch invalid types at compile time.

Now I'm going to use a piece of code to list out basic concepts:

/**
@wendyltan
wendyltan / Design-techniques.md
Last active July 2, 2018 10:49
Two design techniques

Two design techniques

Use Commonality and Variability Analysis

The so-called 'CVA'

Attempts to identify:

  • commonalities(generic concepts)
  • variations(concrete implementations)
@wendyltan
wendyltan / Java-Callback.md
Last active November 23, 2020 16:15
Java-Callback

How to understand callback mechanism?

We can always see many callback functions in Java,but how does that actually work?

We know that there is five step to simulate a callback process:

  • Class A implements Callback interface. /The interface has abstract function operate()/
  • Class A has a member Class B's instance /b/
  • Class B has a method using callback /Callback instance as parameter/doSth(Callback callback)/
@wendyltan
wendyltan / pro&con_java.md
Created June 2, 2018 07:52
Producer and Consumer

Five ways to implement Producer and Consumer problem in Java

The ways I found out while reviewing interview note

wait() and notify()

Simply using wait and notify,with syncronized blocks

public class Test1 {
    private static Integer count = 0;
@wendyltan
wendyltan / Design-pattern review.md
Last active July 10, 2018 23:29
Design pattern

Design Pattern

Type

  • Behavioral patterns:manage variation
  • Structural patterns:integrate existing code into new design
  • Creational patterns:create object,operational code gets buried behind

Facade

>Wrap up all the interface