Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Supercharging project health check

Supercharging project health check

go beyond the usual practices

Avatar for David Horvath

David Horvath

April 06, 2021

More Decks by David Horvath

Other Decks in Technology

Transcript

  1. Super charging project health check go beyond the usual practices

    David Horvath Lead iOS Developer @egyes Swifters meetup 2021 March
  2. issues ┘ Tons of things to check ┘ Lot of

    different approaches ┘ Require a lot of time (it’s never enough) ┘ Huge projects - Potentially overlooked problems
  3. goals ┘ Find the most crucial issues in the shortest

    time ┘ Be more efficient in gaining insights ┘ Efficiently identify the changes to the code which provide the most value
  4. useful when ┘ You have to do a project audit

    ┘ You join a new project ┘ You just want to get new insights into your current project ┘ You want to refactor or rewrite ∷ You can show these findings to your client/boss/lead
  5. process ┘ Checking git reports ∷ Interesting details about the

    project ∷ Gitlab / Github - GitStats(SourceForge)
  6. process ┘ Checking git reports ∷ Interesting details about the

    project ∷ Gitlab / Github - GitStats ┘ Checking project size
  7. process ┘ Checking git reports ∷ Interesting details about the

    project ∷ Gitlab / Github - GitStats ┘ Checking project size ∷ Cloc ┘ Open the project and build it ∷ High-level overview
  8. high- level overview ┘ File structure ┘ Naming conventions ┘

    Modularization ┘ Dependencies (spm, pod, carthage) ┘ UI (code / xib / storyboards) ┘ Architecture ┘ Compile time ┘ Xcode memory graph
  9. process ┘ Checking git reports ∷ Interesting details about the

    project ∷ Gitlab / Github - GitStats ┘ Checking project size ∷ Cloc ┘ Open the project and build it ∷ Highlevel overview ┘ Visualize class dependencies
  10. process ┘ Checking git reports ∷ Interesting details about the

    project ∷ Gitlab / Github - GitStats ┘ Checking project size ∷ Cloc ┘ Open the project and build it ∷ Highlevel overview ┘ Visualize class dependencies ∷ objc-dependency-visualizer ┘ Static code analysis ∷ Cyclomatic complexity ∷ Code duplication
  11. process ┘ Checking git reports ∷ Interesting details about the

    project ∷ Gitlab / Github - GitStats ┘ Checking project size ∷ Cloc ┘ Visualize class dependencies ∷ objc-dependency-visualizer ┘ Checking cyclomatic complexity ∷ Lizard ┘ Static code analysis ∷ Cyclomatic complexity ∷ Code duplication ∷ Lizard / CPD ┘ Checking dead code
  12. process ┘ Checking git reports ∷ Interesting details about the

    project ∷ Gitlab / Github - GitStats ┘ Checking project size ∷ Cloc ┘ Visualize class dependencies ∷ objc-dependency-visualizer ┘ Checking cyclomatic complexity ∷ Lizard ┘ Static code analysis ∷ Cyclomatic complexity ∷ Code duplication ∷ Lizard / CPD ┘ Checking dead code ∷ Periphery
  13. quick process summary ┘ We have a lot of information

    about the project already ∷ High-level overview ∷ Data about the project size and age ∷ List of complexities ∷ List of duplication ∷ Duplication rate ∷ List of unused codes ∷ Nice visualization of the class dependencies ┘ It only took a few hours
  14. problems ┘ We spend so much time looking at the

    current state of the code that we forget its history ┘ Its hard to understand large-scale complex systems by looking at a snapshot of the code ┘ We miss a lot of information
  15. version control systems ┘ We use it to keep track

    of the project history ┘ Rarely think about the insights we can get by mining data from it ┘ We can learn about the environment ┘ We can learn about how we work ┘ Predict which parts of the code have the most defects ┘ Find the code that matters most for maintenance ┘ Information is real power
  16. code maat ┘ Command line tool ┘ To mine and

    analyze data from version control systems ┘ It supports different version control systems ∷ git, svn, perforce, tfs, mercurial ┘ We can use it to detect hotspots ┘ We can use it to detect architectural problems ┘ And so much more
  17. Hotspots ┘ Hotspots are your guide to improvements and refactorings

    ┘ Research has shown that frequent changes to complex code generally indicate declining quality ┘ Over time our development focus shifts so the hotspots will also shift ┘ Hotspots can predict defects very well ┘ We can find them at the intersection of complexity and effort
  18. Coupling ┘ We can detect which files are changing together

    most of the time ┘ Detect architectural / design issues ┘ Explicit coupling ∷ What tend to change together (screen + vm) ┘ Temporal coupling ∷ This is what we are looking for ∷ Can be false positives (service + test) ∷ Can be serious design problem ∷ Can be copy-paste
  19. other features ┘ Complexity trends ∷ Evaluate growth patterns ∷

    Analyze complexity trends ┘ Discover organizational metrics ∷ Social problems ∷ Evaluate communication costs ∷ Build knowledge map ∷ Visualize knowledge loss ┘ Code chur ∷ Predict defects ∷ Discover process loss from code
  20. process summary ┘ High-level overview of the codebase ┘ List

    of complexities ┘ List of duplications ┘ List of unused codes ┘ List of hotspots ┘ List of problematic dependencies
  21. goals ┘ ✅ Find the most crucial issues in the

    shortest time ┘ ✅ Be more efficient in gaining insights ┘ ✅ Efficiently identify the changes to the code which provide the most value
  22. suggesti ons ┘ Run these analyses every few months ┘

    Can be part of CI/CD release process ┘ Talk the findings through with your team ┘ Read Adam Tornhill’s book to learn more: Your Code as a Crime Scene
  23. sum up ┘ With the right tools you can quickly

    and efficiently spot problems ┘ You can use your version control systems to have more information about your project ┘ By mining data from it, you can get a deeper understanding of your design / architectural problems ┘ With the right data you can back your refactoring/ rewrite proposals ┘ Focusing on the right things early you can save a lot of maintenance cost
  24. tools ┘ GitStats ∷ http://gitstats.sourceforge.net ┘ Cloc ∷ https://github.com/AlDanial/cloc ┘

    Lizard ∷ https://github.com/terryyin/lizard ┘ Periphery ∷ https://github.com/peripheryapp/periphery ┘ Objc-dependency-visualizer ∷ https://github.com/PaulTaykalo/objc-dependency-visualizer ┘ Swift-dependency-visualizer ∷ https://github.com/PrzemyslawCholewaDev/swift-dependency- visualizer ┘ Code maat ∷ https://github.com/adamtornhill/code-maat