Successfully reported this slideshow.

Managing Complexity in Salesforce, David Felkel

0

Share

1 of 41
1 of 41

Managing Complexity in Salesforce, David Felkel

0

Share

Download to read offline

Description

Complexity kills – Simplicity is robust. There is a strong correlation between the size of an org and its complexity. The more complex your org becomes, the harder it is to maintain and the costlier your development endeavours become. But where does complexity come from and how can it be avoided?

Transcript

  1. 1. 1 #CD22 Managing Complexity Keep your software under control! 27.05.2022 1
  2. 2. 2 #CD22 David Felkel Founder of helpful bits Software Architect Programming since 1997 Salesforce since 2016 https://helpfulbits.com 27.05.2022
  3. 3. 3 #CD22 Part 1- About Complexity 27.05.2022
  4. 4. 4 #CD22 Complexity kills • Budget • Quality • Engineers‘ Motivation • Extensibility • Customer Support 27.05.2022
  5. 5. 5 #CD22 Complex software is like a jungle 27.05.2022
  6. 6. 6 #CD22 Simple software is a garden 27.05.2022
  7. 7. 7 #CD22 What is complexity in software? A problem of state 27.05.2022 n The number of Latin squares of order n 1 1 2 2 3 12 4 576 5 161,280 6 812,851,200 7 61,479,419,904,000 8 108,776,032,459,082,956,800 9 5,524,751,496,156,892,842,531,225,600 10 9,982,437,658,213,039,871,725,064,756,920,320,000 11 776,966,836,171,770,144,107,444,346,734,230,682,311,065,600,000 1 2 3 2 3 1 3 1 2
  8. 8. 8 #CD22 Where is the relation to software? • Combinatorial explosions occur a lot in software • Branches in Program Flow • Possibles states of data increase with every new field • Now suppose you‘ve got 4 picklists with 10 values each: • 10.000 possible states of data • Have you got 10.000 unit tests for that? No? Shame on you, sloppy programmer! 27.05.2022
  9. 9. 9 #CD22 Or a global variable for that matter … Congrats, you can now multiply all already possible states of your whole program! You will win the award for the most stateful program! And you better pray the next maintenance developer does not know where you live! I suggest you leave the country! 27.05.2022
  10. 10. 10 #CD22 What is complexity in software? A problem of cognitive load 27.05.2022
  11. 11. 11 #CD22 Where is the relation to software? • The same things are named differently • The same thing is being done differently • Different things have the same name • There‘s simply too much of the same thing in different flavors • Communication Problems 27.05.2022
  12. 12. 12 #CD22 What is complexity in software? A problem of features • People buy feature-rich software • People want powerful software to fuel their processes 27.05.2022
  13. 13. 13 #CD22 What is complexity in software? A problem of premature optimization “The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil (or at least most of it) in programming” (Donald Knuth, 1974) Yet, we are often forced to do so in Salesforce. It worsens the problem. 27.05.2022
  14. 14. 14 #CD22 The solution: KISS – Keep IT simple and stupid • Complex code is bad code • Simple code is good code • Simple code is not easy to write, it‘s easier to write complex code • Simple code with better modularization has less state than complex code and makes you think less. 27.05.2022
  15. 15. 15 #CD22 We‘ve known this since the 70s • Structured Programming promoted by Djikstra 27.05.2022 How do we convince people that in programming, simplicity and clarity – in short: what mathematicians call „elegance“ – are not a dispensable luxury, but a crucial matter that decides between success and failure?
  16. 16. 16 #CD22 What is simple and maintainable code? 27.05.2022
  17. 17. 17 #CD22 And how do we achieve less complexity? • Boundaries! • Divide & Conquer! Everywhere! • Modularization! • Encapsulation! • True Object Orientation! • Readable and clean code! • Be close to your domain, no unecessary abstractions! • Stupid code! 27.05.2022
  18. 18. 18 #CD22 27.05.2022
  19. 19. 19 #CD22 Part 2 – Practical solutions to complexity problems 27.05.2022
  20. 20. 20 #CD22 Fundamentals • Establish Coding Conventions • They teach your eyes and your mental parser • Code will make you think less • You can prevent errors with proper conventions 27.05.2022
  21. 21. 21 #CD22 Fundamentals • Establish a ubiqitous language • Enable your business people and your programmers to understand each other! • Any business term should have a precise meaning and only that meaning • These terms should be found in the code 27.05.2022
  22. 22. 22 #CD22 Fundamentals • Clean Code • Vast topic – I recommend Uncle Bob‘s book ‚Clean Code‘ • Don‘t make the maintenance programmer think • Don‘t duplicate code • Don‘t have methods more than a few lines and don‘t have more than 3 Arguments • Etc. etc. 27.05.2022 Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”—Martin Fowler
  23. 23. 23 #CD22 Fundamentals – clean code 27.05.2022
  24. 24. 24 #CD22 Fundamentals – clean code 27.05.2022
  25. 25. 25 #CD22 Fundamentals – clean code 27.05.2022 There are only two hard things in Computer Science: cache invalidation and naming things. Phil Karlton
  26. 26. 26 #CD22 Fundamentals • S ingle Responsibility Principle • O pen Closed Principle • L iskov Substitution Principle • I nterface Segregation Principle • D ependency Inversion Principle https://en.wikipedia.org/wiki/SOLID 27.05.2022
  27. 27. 27 #CD22 Fundamentals 27.05.2022
  28. 28. 28 #CD22 Fundamentals • Use proper tools for the job • 1st Rule is: DON‘T USE EVERYTHING IN YOUR SALESFORCE TOOLKIT • 2nd Rule is: DON‘T USE EVERYTHING IN YOUR SALESFORCE TOOLKIT • 3rd Rule is: Understand the tools you use • Flows and Processes are hard to debug, yet accessible for non programmers • Good combinations: • Pure Apex and LWC for complex domains • LWC with flows for lots of step by step processes and wizards • No Apex at all and just flows for simple domains 27.05.2022
  29. 29. 29 #CD22 Fundamentals • Key Success factor: • Requirements Engineering: Know what you are up to, because the client most likely won‘t pay for refactorings. • Team Setup: Know your teams skills. • Have the guts to say „no“ to the client • If in doubt, use Apex and LWC, avoid Workflows and Processes. A Flow here and there probably doesn‘t hurt. • Workflows and processes are harder to debug and, together with rollup summaries, cause triggers to fire a 2nd time, counting against your limits. 27.05.2022
  30. 30. 30 #CD22 Part 3 – Architecture primer 27.05.2022
  31. 31. 31 #CD22 Architecture Fundamentals • The Layer Architecture (aka n-Tier architecture) • Clear separation between Persistence, Business Logic and UI 27.05.2022 Only call down, never call up!
  32. 32. 32 #CD22 Architecture Fundamentals • There‘s fflib: https://github.com/apex-enterprise-patterns/fflib-apex-common https://trailhead.salesforce.com/en/content/learn/modules/apex_patterns_d sl • I consider it too heavy weight but you might like it. • Architecture is more a pattern than a library, you can roll your own. 27.05.2022
  33. 33. 33 #CD22 Architecture Fundamentals – Business Logic • API Layer • Well defined API for a Business Domain • Encapsulates the actions your business really does • Properly published via Facade Pattern • Done properly, you won‘t have to bulkify (or at least loop) much anymore • Can avoid „Trigger cascades“ if done right 27.05.2022
  34. 34. 34 #CD22 Architecture Fundamentals – Data Access • The lazy Repository (aka Kazlovich Repository) • Is initialized with all IDs necessary • Only fetches records or relations when actually accessed • Uses mainly one big query to fetch as much data as possible in a single database call • Great in avoiding complexity and limits! 27.05.2022
  35. 35. 35 #CD22 Architecture Fundamentals – Presentation • LWC or Visual Force • Avoid Aura for its complexity and lack of readability is its meat and bones • Don‘t write business logic in your code, rather call Backend methods • The UI should only care about presentation logic and not much about the business process, apart from visualizing it! • No Javascript business logic algorithms! • Patterns used in other technologies: MVC, MVVM, MVP 27.05.2022
  36. 36. 36 #CD22 Architecture Fundamentals – DDD • Define module boundaries in your requirements 27.05.2022 Done right, any domain will fit into a salesforce Package and not depend on others
  37. 37. 37 #CD22 Why is this so important? • Proper architecture means proper divide and conquer • Proper divide and conquer = less complexity • Proper decoupling = less complexity and even more flexibility • Properly architected, well defined interfaces and decoupled modules emerge naturally 27.05.2022
  38. 38. 38 #CD22 Summary • How does this solve Salesforce problems technically? • You can avoid limits • You can even avoid the need for bulkification • Your code is more clean and concise • Your code is easier to maintain, more flexible • Your code is more easily extensible • Your code is easier to deploy 27.05.2022
  39. 39. 39 #CD22 Summary • How does this solve Salesforce problems organizationally? • Quick changes • Less bugs • Multiproject Management • Clear separation of organizational responsibilities • But: It‘s not easy getting there. Proper conventions and guidelines have to be created. Any building block must confirm to your standards. 27.05.2022
  40. 40. 40 #CD22 27.05.2022
  41. 41. 41 #CD22 27.05.2022 Thank you! #CD22

Description

Complexity kills – Simplicity is robust. There is a strong correlation between the size of an org and its complexity. The more complex your org becomes, the harder it is to maintain and the costlier your development endeavours become. But where does complexity come from and how can it be avoided?

Transcript

  1. 1. 1 #CD22 Managing Complexity Keep your software under control! 27.05.2022 1
  2. 2. 2 #CD22 David Felkel Founder of helpful bits Software Architect Programming since 1997 Salesforce since 2016 https://helpfulbits.com 27.05.2022
  3. 3. 3 #CD22 Part 1- About Complexity 27.05.2022
  4. 4. 4 #CD22 Complexity kills • Budget • Quality • Engineers‘ Motivation • Extensibility • Customer Support 27.05.2022
  5. 5. 5 #CD22 Complex software is like a jungle 27.05.2022
  6. 6. 6 #CD22 Simple software is a garden 27.05.2022
  7. 7. 7 #CD22 What is complexity in software? A problem of state 27.05.2022 n The number of Latin squares of order n 1 1 2 2 3 12 4 576 5 161,280 6 812,851,200 7 61,479,419,904,000 8 108,776,032,459,082,956,800 9 5,524,751,496,156,892,842,531,225,600 10 9,982,437,658,213,039,871,725,064,756,920,320,000 11 776,966,836,171,770,144,107,444,346,734,230,682,311,065,600,000 1 2 3 2 3 1 3 1 2
  8. 8. 8 #CD22 Where is the relation to software? • Combinatorial explosions occur a lot in software • Branches in Program Flow • Possibles states of data increase with every new field • Now suppose you‘ve got 4 picklists with 10 values each: • 10.000 possible states of data • Have you got 10.000 unit tests for that? No? Shame on you, sloppy programmer! 27.05.2022
  9. 9. 9 #CD22 Or a global variable for that matter … Congrats, you can now multiply all already possible states of your whole program! You will win the award for the most stateful program! And you better pray the next maintenance developer does not know where you live! I suggest you leave the country! 27.05.2022
  10. 10. 10 #CD22 What is complexity in software? A problem of cognitive load 27.05.2022
  11. 11. 11 #CD22 Where is the relation to software? • The same things are named differently • The same thing is being done differently • Different things have the same name • There‘s simply too much of the same thing in different flavors • Communication Problems 27.05.2022
  12. 12. 12 #CD22 What is complexity in software? A problem of features • People buy feature-rich software • People want powerful software to fuel their processes 27.05.2022
  13. 13. 13 #CD22 What is complexity in software? A problem of premature optimization “The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil (or at least most of it) in programming” (Donald Knuth, 1974) Yet, we are often forced to do so in Salesforce. It worsens the problem. 27.05.2022
  14. 14. 14 #CD22 The solution: KISS – Keep IT simple and stupid • Complex code is bad code • Simple code is good code • Simple code is not easy to write, it‘s easier to write complex code • Simple code with better modularization has less state than complex code and makes you think less. 27.05.2022
  15. 15. 15 #CD22 We‘ve known this since the 70s • Structured Programming promoted by Djikstra 27.05.2022 How do we convince people that in programming, simplicity and clarity – in short: what mathematicians call „elegance“ – are not a dispensable luxury, but a crucial matter that decides between success and failure?
  16. 16. 16 #CD22 What is simple and maintainable code? 27.05.2022
  17. 17. 17 #CD22 And how do we achieve less complexity? • Boundaries! • Divide & Conquer! Everywhere! • Modularization! • Encapsulation! • True Object Orientation! • Readable and clean code! • Be close to your domain, no unecessary abstractions! • Stupid code! 27.05.2022
  18. 18. 18 #CD22 27.05.2022
  19. 19. 19 #CD22 Part 2 – Practical solutions to complexity problems 27.05.2022
  20. 20. 20 #CD22 Fundamentals • Establish Coding Conventions • They teach your eyes and your mental parser • Code will make you think less • You can prevent errors with proper conventions 27.05.2022
  21. 21. 21 #CD22 Fundamentals • Establish a ubiqitous language • Enable your business people and your programmers to understand each other! • Any business term should have a precise meaning and only that meaning • These terms should be found in the code 27.05.2022
  22. 22. 22 #CD22 Fundamentals • Clean Code • Vast topic – I recommend Uncle Bob‘s book ‚Clean Code‘ • Don‘t make the maintenance programmer think • Don‘t duplicate code • Don‘t have methods more than a few lines and don‘t have more than 3 Arguments • Etc. etc. 27.05.2022 Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”—Martin Fowler
  23. 23. 23 #CD22 Fundamentals – clean code 27.05.2022
  24. 24. 24 #CD22 Fundamentals – clean code 27.05.2022
  25. 25. 25 #CD22 Fundamentals – clean code 27.05.2022 There are only two hard things in Computer Science: cache invalidation and naming things. Phil Karlton
  26. 26. 26 #CD22 Fundamentals • S ingle Responsibility Principle • O pen Closed Principle • L iskov Substitution Principle • I nterface Segregation Principle • D ependency Inversion Principle https://en.wikipedia.org/wiki/SOLID 27.05.2022
  27. 27. 27 #CD22 Fundamentals 27.05.2022
  28. 28. 28 #CD22 Fundamentals • Use proper tools for the job • 1st Rule is: DON‘T USE EVERYTHING IN YOUR SALESFORCE TOOLKIT • 2nd Rule is: DON‘T USE EVERYTHING IN YOUR SALESFORCE TOOLKIT • 3rd Rule is: Understand the tools you use • Flows and Processes are hard to debug, yet accessible for non programmers • Good combinations: • Pure Apex and LWC for complex domains • LWC with flows for lots of step by step processes and wizards • No Apex at all and just flows for simple domains 27.05.2022
  29. 29. 29 #CD22 Fundamentals • Key Success factor: • Requirements Engineering: Know what you are up to, because the client most likely won‘t pay for refactorings. • Team Setup: Know your teams skills. • Have the guts to say „no“ to the client • If in doubt, use Apex and LWC, avoid Workflows and Processes. A Flow here and there probably doesn‘t hurt. • Workflows and processes are harder to debug and, together with rollup summaries, cause triggers to fire a 2nd time, counting against your limits. 27.05.2022
  30. 30. 30 #CD22 Part 3 – Architecture primer 27.05.2022
  31. 31. 31 #CD22 Architecture Fundamentals • The Layer Architecture (aka n-Tier architecture) • Clear separation between Persistence, Business Logic and UI 27.05.2022 Only call down, never call up!
  32. 32. 32 #CD22 Architecture Fundamentals • There‘s fflib: https://github.com/apex-enterprise-patterns/fflib-apex-common https://trailhead.salesforce.com/en/content/learn/modules/apex_patterns_d sl • I consider it too heavy weight but you might like it. • Architecture is more a pattern than a library, you can roll your own. 27.05.2022
  33. 33. 33 #CD22 Architecture Fundamentals – Business Logic • API Layer • Well defined API for a Business Domain • Encapsulates the actions your business really does • Properly published via Facade Pattern • Done properly, you won‘t have to bulkify (or at least loop) much anymore • Can avoid „Trigger cascades“ if done right 27.05.2022
  34. 34. 34 #CD22 Architecture Fundamentals – Data Access • The lazy Repository (aka Kazlovich Repository) • Is initialized with all IDs necessary • Only fetches records or relations when actually accessed • Uses mainly one big query to fetch as much data as possible in a single database call • Great in avoiding complexity and limits! 27.05.2022
  35. 35. 35 #CD22 Architecture Fundamentals – Presentation • LWC or Visual Force • Avoid Aura for its complexity and lack of readability is its meat and bones • Don‘t write business logic in your code, rather call Backend methods • The UI should only care about presentation logic and not much about the business process, apart from visualizing it! • No Javascript business logic algorithms! • Patterns used in other technologies: MVC, MVVM, MVP 27.05.2022
  36. 36. 36 #CD22 Architecture Fundamentals – DDD • Define module boundaries in your requirements 27.05.2022 Done right, any domain will fit into a salesforce Package and not depend on others
  37. 37. 37 #CD22 Why is this so important? • Proper architecture means proper divide and conquer • Proper divide and conquer = less complexity • Proper decoupling = less complexity and even more flexibility • Properly architected, well defined interfaces and decoupled modules emerge naturally 27.05.2022
  38. 38. 38 #CD22 Summary • How does this solve Salesforce problems technically? • You can avoid limits • You can even avoid the need for bulkification • Your code is more clean and concise • Your code is easier to maintain, more flexible • Your code is more easily extensible • Your code is easier to deploy 27.05.2022
  39. 39. 39 #CD22 Summary • How does this solve Salesforce problems organizationally? • Quick changes • Less bugs • Multiproject Management • Clear separation of organizational responsibilities • But: It‘s not easy getting there. Proper conventions and guidelines have to be created. Any building block must confirm to your standards. 27.05.2022
  40. 40. 40 #CD22 27.05.2022
  41. 41. 41 #CD22 27.05.2022 Thank you! #CD22

More Related Content

More from CzechDreamin

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

×