MonolithFirst
- You shouldn’t start a new project with microservices, even if you’re sure your application will be big enough to make it worthwhile.
- This remind me “Pattern is discovered, not invented”
- It is difficult to refactor services with wrong bounded contexts.
- Better identify the boundaries by building monolith architecture
The Clean Architecture
Explain what is a clean architecture, I should move this to an individual review
Good architecture should
- Independent of Frameworks.
- Testable. The business rules can be tested without the UI, Database, Web Server, or any other external element.
- Independent of UI.
- Independent of Database. Your business rules are not bound to the database.
- Independent of any external agency. In fact your business rules simply don’t know anything at all about the outside world.
The Dependency Rule
- Source code dependencies can only point inwards.
- Nothing in an inner circle can know anything at all about something in an outer circle.
Entities
- Entities encapsulate Enterprise wide business rules
- They encapsulate the most general and high-level rules.
- They are the least likely to change when something external changes.
Use Cases
- Application specific business rules, use cases of the system
- Orchestrate the flow of data to and from the entities
- Expect that changes to the operation of the application will affect software in this layer
- Is this similar to services in DDD?
Interface Adapters
- A set of adapters
- Convert data format for use cases and entities to some external agency such as the Database or the Web.
- Implementation related code should be restricted here, such as framework and database code
- Convert data from external services to to the internal form used by the use cases and entities.
Frameworks and Drivers.
- Composed of frameworks and tools such as the Database, the Web Framework, etc.
- Most of them are glue code that communicates to the next circle inwards.
Crossing boundaries
- Apply dependency inversion principle
- No name in an outer circle can be mentioned by an inner circle
What data crosses the boundaries
- Don’t pass Entities or Database rows
- When we pass data across a boundary, it is always in the form that is most convenient for the inner circle.
13 Jan 2019
Better spend time to read the book “Clean architecture”
Sapper: Towards the ideal web app framework
Some requirements for a modern web app framework. As it is written by a framework creator, may be this article is opinionated.
Integrated Tests Are A Scam
Integration test嘅野太多,搞到好難main
- 要寫好多test先cover到唔同情況
- 因為要simulate入邊D unit嘅唔同狀態,入邊D unit又有唔同combination
- 改一個unit嘅code會影響好多test
- Note: integrated test != integration test
13 Jan 2019
感覺係system design嘅時候冇考慮到點樣test,同埋冇諗好test嘅責任。
How to Tell the Truth
有時講真話就好似自討苦吃,唔講又搞到唔可以上下一心,文中提出一個做法
- State the facts clearly and honestly — Don’t try to say that you needed to clean up performance issues or that the company is better off without the people that you so painstakingly hired. It is what it is and it’s important that everyone knows you know that.
- If you caused it, explain how such a bad thing could occur – What was the decision process that you used to expand the company faster than you should have? What did you learn that will prevent it from happening again?
- Explain why taking the action is essential to the larger mission and how important that mission is — A layoff, if done properly, is a new lease on life for the company and an action that was necessary to fulfill the prime directive and mission that everyone signed up for. As the leader, it’s your job to make sure that the company does not let those people lose their jobs for nothing. Something good needs to come out of it.
The LMAX Architecture
Talk about infrastucture of a financial company with 600M TPS(transaction per second). Seems too early for me to understand
- Event sourcing, functions have no side effect
- Events are stored in persistance storage
- so can reproduce state from events, event server is crash
- Ring buffer structure for event queue
- one writer, others are reader
- consumer always read behind the writer
- No locks are required
- If consumer lag behind, they can do a batch processing to catch up
一至千萬的藝術 — 如何養成支撐網路巨量交易的伺服器艦隊
講解infrastructure點樣逐步升級,而且係infra圖
- Database and web server on same machine
- Separate database and Web server
- One server for database, one server for web
- Add load balancer
- One load balancer
- Multiple web server
- One database (bottleneck)
- Add read replica
- web server read from read replica
- Web server access the single master only when write is required (bottleneck)
- Sharding
- Shard the database, so we can have multiple master
- NoSQL
Other performance tuning method not mentioned
- CDN
- Cache
- DNS load balance (when load balancer become the bottleneck)
以下無需重讀
5秒定律
數五秒之後再轉換想法。因為要先中斷本身嘅負面想法,大腦先可以接收新想法。
Good method for switching task when got stuck
Winning at Rock Paper Scissors
就算個system係公平,但係人嘅decision係irration,始終存在策略
Stragegy: play backward (Rock -> Scissor -> Paper)
How to Learn Advanced Concepts Fast
10 tips on learning advance topic fast.
- Find a reason to learn
- Keep motivated
- Start with the simplest explanations
- Open top 10 links on Google
- Skip if cannot understand
- Stay with that you interested
- Explain *** like I am five
- Open top 10 links on Google
- Create a set of small, achievable goals
- Set Deadlines
- Maintain a flow state
- Let your curiosity guide your learning path
- Spend 1/3 of your time researching & 2/3 doing
- Try to summarize thing you learnt by one sentences
- Take notes by hand
- Don’t multitask
- Maintain your Health