# Some # Random Thoughts # on # SWE of Alaya-NeW :construction_worker: Xiaolin Zhang @2024-07-30 :game_die: --- ## What is SWE? Software Engineering(SWE) \ is \ the \ ***easiest*** \ course to fall asleep in. <br /> [Youtube | Lectures for Sleep & Study](https://www.youtube.com/@SleepStudy/videos) ![image](https://hackmd.io/_uploads/Sk-vMSSYR.png =600x) <!-- <p> <img width="200pt" src="https://hackmd.io/_uploads/rkBTQBSFR.png" > <img width="200pt" src="https://hackmd.io/_uploads/B1_k4rHtA.png" > </p> --> --- ## What is SWE? <div style="display: flex; justify-content: space-between;"> <div style="flex: 1; padding-right: 10px;"> <!-- Markdown content goes here --> After years of working, \ SWE became the \ ***one of most valuable*** \ course for \ ***professional*** \ programmers. </div> <div style="flex: 1; padding-left: 10px;"> <!-- Image content goes here --> <img src="https://upload.wikimedia.org/wikipedia/en/f/fd/Mythical_man-month_%28book_cover%29.jpg" > </div> </div> --- ## Recently read books, I want to share with you, just before ## new journey of ***Alaya NeW 2.0*** <p> <img width="200pt" src="https://upload.wikimedia.org/wikipedia/en/f/fd/Mythical_man-month_%28book_cover%29.jpg" > <img width="200pt" src="https://hackmd.io/_uploads/rJfHJHHKA.png" > <img width="200pt" src="https://hackmd.io/_uploads/S1WA1BSYC.png" > </p> --- ## Who am I? - A software engineer, somehow ***biased*** - :heart: Emacs/Vim - :heart: Markdown/AsciiDoc/OrgMod - :heart: Linux/Unix/Open Source - :heart: Love ChatGPT, but made this talk ***by hand*** --- # WHY --- ## 那天,喝得有点多 ![image](https://hackmd.io/_uploads/S1IEbUHYA.png) --- ## 但是,我们立下一个正经的 **FLAG** ![image](https://hackmd.io/_uploads/SJM_xLrYC.png) --- ## What IS this talk <div style="display: flex; justify-content: space-between;"> <div style="flex: 1; padding-right: 10px;"> <!-- Markdown content goes here --> - 抛个砖 :arrow_forward: 引个玉 - Some biased ***advices*** for all - **Inspire** more people to share your thoughts </div> <div style="flex: 1; padding-left: 10px;"> <!-- Image content goes here --> <img width="400pt" src="https://upload.wikimedia.org/wikipedia/commons/0/01/Brick.jpg" > </div> </div> --- ## What is NOT <div style="display: flex; justify-content: space-between;"> <div style="flex: 1; padding-right: 10px;"> <!-- Markdown content goes here --> - Architectual Decision Making - Team roles and responsibilities Decision Making - Probably,a **hypnotic(催眠)** talk </div> <div style="flex: 1; padding-left: 10px;"> <!-- Image content goes here --> <img src="https://upload.wikimedia.org/wikipedia/commons/0/01/Brick.jpg" > </div> </div> --- ### SWE@Google: ``` - Thesis - What is Software Engineering? - Culture - How to Work Well on Teams - Knowledge Sharing - Engineering for Equity - How to Lead a Team - Leading at Scale - Measuring Engineering Productivity - Processes - Style Guides and Rules - Code Review - Documentation - Testing Overview - Unit Testing - Test Doubles - Larger Testing - Deprecation - Tools - Version Control and Branch Management - Code Search - Build Systems and Build Philosophy - Critique: Google's Code Review Tool - Static Analysis - Dependency Management - Large-Scale Changes - Continous Integration - Continous Delivery - Compute as a Service ``` --- ## What is Software Engeering? Within Google, we sometimes say: **“Software engineering is programming integrated over time.”** $$ Cost\ of\ Software(t) = \int_0^\infty cost({t}) \space dt\,. $$ --- ## From DevOps to DevSecOps ![image](https://hackmd.io/_uploads/S11klC1cR.png) --- {%youtube J73MELGF6u0 %} --- ## Defect Cost > Finding problems earlier in the developer workflow usually reduces costs. ![image](https://hackmd.io/_uploads/Hko4yh8KC.png) Defect: Bug / Security Problem / etc. --- ## Trade-offs and Costs - Financial costs (e.g., money) - Resource costs (e.g., CPU time) - Personnel costs (e.g., engineering effort) - Transaction costs (e.g., what does it cost to take action?) - Opportunity costs (e.g., what does it cost to not take action?) - Societal costs (e.g., what impact will this choice have on society at large?) --- ## Software engineering vs programming * Programming: producing code. * Software engineering extends that to include the **maintenance** of that code for its useful life span. --- Thanks :heart: , to be continue... ![idiom-rome-wasnt-built-in-a-day-on-large-postit-affixed-colosseum-rome-P6YW7M](https://hackmd.io/_uploads/HkT4DC1q0.jpg) --- Hyrum’s Law: With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody. --- > 其实地上本没有路,走的人多了,也便成了路 ![image](https://hackmd.io/_uploads/BklEEaIFC.png) --- ## Metrics --- ## Rules - Rules and guidance should aim to support resilience to time and scaling. - Know the data so that rules can be adjusted. - Not everything should be a rule. - Consistency is key. - Automate enforcement when possible. --- ## Code Review - Code review has many benefits, including ensuring code correctness, comprehension, and consistency across a codebase. - Always check your assumptions through someone else; optimize for the reader. - Provide the opportunity for critical feedback while remaining professional. - Code review is important for knowledge sharing throughout an organization. - Automation is critical for scaling the process. - The code review itself provides a historical record. --- ## Documentation > 当新人问我要文档时, > 我就是文档。 ![image](https://hackmd.io/_uploads/SJD_UpUY0.png =40%x) --- ## Documentation Is Like Code --- ## 信息的可靠程度 CSDN < tech blog = wexin article < tech books < official doc < source code --- ## Documentation Know Your Audience --- ## Documentation Types - Reference documentation, including code comments - Design documents - Tutorials - Conceptual documentation - Landing pages --- ## Example of Document of Requirement - Functional - What should the system do? - Non-Functional - How should the system behave? - Functionality, Usability, Reliability, Efficiency --- ## Documentation Philosophy - WHO - WHAT - WHEN - WHERE - WHY --- ## Documentation tldr - Documentation is hugely important over time and scale. - Documentation changes should leverage the existing developer workflow. - Keep documents focused on one purpose. - Write for your audience, not yourself. --- ## Testing ![image](https://hackmd.io/_uploads/BJ73Hp8tC.png =60%x) --- ## Testing tldr - Automated testing is foundational to enabling software to change. - For tests to scale, they must be automated. - A balanced test suite is necessary for maintaining healthy test coverage. - “If you liked it, you should have put a test on it.” - Changing the testing culture in organizations takes time. --- ## Unit Testing - Strive for unchanging tests. - Test via public APIs. - Test state, not interactions. - Make your tests complete and concise. - Test behaviors, not methods. - Structure tests to emphasize behaviors. - Name tests after the behavior being tested. - Don’t put logic in tests. - Write clear failure messages. - Follow DAMP over DRY when sharing code for tests. --- ## Test Double(Mocking) - A real implementation should be preferred over a test double. - A fake is often the ideal solution if a real implementation can’t be used in a test. - Overuse of stubbing leads to tests that are unclear and brittle. - Interaction testing should be avoided when possible: it leads to tests that are brittle because it exposes implementation details of the system under test. --- ## CI - A CI system decides what tests to use, and when. - CI systems become progressively more necessary as your codebase ages and grows in scale. - CI should optimize quicker, more reliable tests on presubmit and slower, less deterministic tests on post-submit. - Accessible, actionable feedback allows a CI system to become more efficient. --- ## CD - Velocity is a team sport: The optimal workflow for a large team that develops code collaboratively requires modularity of architecture and near-continuous integration. Evaluate changes in isolation: Flag guard any features to be able to isolate problems early. - Make reality your benchmark: Use a staged rollout to address device diversity and the breadth of the userbase. Release qualification in a synthetic environment that isn’t similar to the production environment can lead to late surprises. - Ship only what gets used: Monitor the cost and value of any feature in the wild to know whether it’s still relevant and delivering sufficient user value. - Shift left: Enable faster, more data-driven decision making earlier on all changes through CI and continuous deployment. - Faster is safer: Ship early and often and in small batches to reduce the risk of each release and to minimize time to market. --- <!-- Secure by Design --> ![image](https://hackmd.io/_uploads/Hkt1O2UYR.png) --- <style> code.blue { color: #337AB7 !important; } code.orange { color: #F7A004 !important; } </style> - <code class="orange">onMessage('event')</code>: Register event listener - <code class="blue">sendMessage('event')</code>: Trigger event --- # :bulb: --- - Dead simple API - Only cares about application logic --- # Thank you! :sheep: --- # References - https://github.com/qiangmzsx/Software-Engineering-at-Google --- # Test ```graphviz graph happiness { labelloc="t" label="Mind map of Happiness.\nTwopi radial graph." fontname="URW Chancery L, Apple Chancery, Comic Sans MS, cursive" layout=twopi; graph [ranksep=2]; edge [penwidth=5 color="#f0f0ff"] node [fontname="URW Chancery L, Apple Chancery, Comic Sans MS, cursive"] node [style="filled" penwidth=0 fillcolor="#f0f0ffA0" fontcolor=indigo] Happiness [fontsize=50 fontcolor=red URL="https://en.wikipedia.org/wiki/Category:Happiness"] node [fontsize=40] Happiness -- { Peace Love Soul Mind Life Health } Life [fontcolor=seagreen] Health [fontcolor=mediumvioletred] node [fontsize=25] Love [fontcolor=orchid URL="https://en.wikipedia.org/wiki/Category:Love"] Love -- { Giving People Beauty } Success [fontcolor=goldenrod] Life -- { Nature Wellbeing Success } Peace [URL="https://en.wikipedia.org/wiki/Category:Peace"] Peace -- { Connection Relationship Caring } Health -- { Body Recreation } Mind [URL="https://en.wikipedia.org/wiki/Category:Mind"] Mind -- { Cognition Consciousness Intelligence } Soul [URL="https://en.wikipedia.org/wiki/Soul"] Soul -- { Emotions Self Meditation } node [fontsize=""] Beauty -- { Esthetics Art } People -- { Family Partner Hug } Giving -- { Feelings Support } Self -- { Delight Joy Expression } Success -- { Creation Profit Win Career } Recreation -- { Leisure Sleep } Emotions [URL="https://en.wikipedia.org/wiki/Soul"] Emotions -- { Positiveness Tranquility } Self -- Emotions [weight=10 penwidth=1 style=dotted constraint=false] Body -- { Medicine Exercises Nutrition Water Heart } Wellbeing -- { Home Work Finance Clothes Transport } Relationship -- { Friends Community Society } Connection -- { Acceptance Forgiveness Gratitude Agreement } Caring -- { Respect Empathy Help } Consciousness -- { Awareness } Meditation -- { Contemplation Breath } Cognition -- { Imagination Perception Thinking Understanding Memory } Intelligence -- { Learning Experiment Education } Nature -- { Ocean Forest Pets Wildlife } c [label="© 2020-2022 Costa Shulyupin" fontsize=12 shape=plain style="" fontcolor=gray] } ``` <!-- --- ## SDLC ```graphviz digraph { compound=true rankdir=LR graph [ fontname="Source Sans Pro", fontsize=20 ]; node [ fontname="Source Sans Pro", fontsize=18]; edge [ fontname="Source Sans Pro", fontsize=12 ]; subgraph cluster1 { concentrate=true plan [label="Plan\n|hello\n|{haha|hoho}"] [shape=record] design [label="Design\n"] [shape=record] implement [label="Implement\n|Coding\n|Continuous Integration\n|Auto Testing"] [shape=record] test [label="Test"] [shape=box] deploy [label="Deploy"] [shape=box] maintain [label="Maintain"] [shape=box] plan -> design design -> implement implement -> test test -> deploy deploy -> maintain label="Software Development Life Cycle" } } ``` -->
{"title":"Software Engineering for Alaya-NeW","description":"View the slide with \"Slide Mode\".","contributors":"[{\"id\":\"a1ee51f7-f123-4007-b226-71827c93bcfc\",\"add\":19443,\"del\":4202}]"}
    169 views