Lazy initialize object with Proxy Pattern
Sometimes, you want to lazy intialize an object such as websocket to make it’s only connected when needed, (virtual) proxy pattern can help.
Instead of initializing directly:
Using the Proxy:
Sometimes, you want to lazy intialize an object such as websocket to make it’s only connected when needed, (virtual) proxy pattern can help.
Instead of initializing directly:
Using the Proxy:
Understanding the basic differences between the 3 patterns.
Observer: the publisher must know and manage observers, observers will be attached to the specific publisher:
Pubsub: the publisher can publish an event without knowing who are the listeners, publisher and listeners communicate through the event channel:
Mediator: groups logic of domain that has indirect relationship between modules. We can use Pubsub
(not required, can use other patterns) to manage the workflow :
Git commands that I use everyday.
stage files:
git add .
git add <file1> <file2>
unstage files:
git reset
git reset <file1> <file2>
discard unstaged files:
all files: git checkout -f
specific files: git checkout -- <file1> <file2>
checkout:
git checkout -b <new-branch>
(-b for new branch only)
remove branch:
git branch -d <branch-name>
(-D for forcing delete branch)
rename branch:
git branch -m <old-branch-name> <new-branch-name>
commit with message:
git commit -m "title message" -m "description message"
commit and rewrite using last commit:
git commit --amend --no-edit
push new branch:
git push -u origin HEAD
push:
git push
(add --force
to completely overwrite the remote branch)
pull:
git pull
reset commit (rewrite history):
git reset HEAD~1
merge:
git merge <branch-name>
rebase:
git rebase <branch-name>
cherry pick commit:
git cherry-pick <commmit-id>
stash save:
git stash save
stash apply:
git stash apply
log:
git log
git log -p
git log --oneline
git log --graph