Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Path to Code
Begin Your Salesforce Coding Adventure
Episode 21
Design Pattern - Part 1
Jitendra Zaa
Salesforce MVP
Sr Technical Architect
23x Certified
@Jitendra Zaa
Speaker
Agenda
• SOLID
• Design Principles
• What are design Patterns
• Who are Gang Of Four
• GoF Patterns
• Creational Pattern
•...
Some House Rules
• Please mute your mic
• Keep adding questions in Zoom Q&A Window
• No question is too small
• Questions ...
SOLID Design Principles
Open Closed Principle
Class should be Open for extension but Closed for Modification.
Example
Create a Program to accept Circle and Square Object and return Sum of
their Area.
Example
Run Code
Change in Requirement
Add Support for Rectangle Also. What
would you do ?
Add one more If else? That would be
breaking Ope...
Solution
Add Interface so that all Shape
should follow that interface, new
Class will become
Single Responsibility Principle
A class should have one and only one reason to change that means
only one job.
Example
Question
AreaCalculator class calculates area and returns result of sum of area
of all Shapes.
How to add functionality if...
Answer
Incorrect
Explanation
Its breaking Single Responsibility Principle. AreaCalculator should only
change if formula related to Area cha...
Liskov Substitution Principle
If class B is a child of class A, then A can be replaced by B, without
changing anything in ...
Interface Segregation Principle
This states that do not force a child class to depend on a method that is
not used for the...
Interface Segregation Principle
Dependency Inversion Principle
This states that modules should not depend on each other directly and
should depend via an ...
What are Design Patterns ?
Each Pattern describes
1. A problem which occurs again and again
2. A core of the Solution
3. C...
Design Patterns Does not
Provide Actual Implementation Details
Example - Roof Patterns in Construction
Who are Gang of Fours
Book written in 1994 consist of 23 Design
patterns by
1. Erich Gamma
2. Richard Helm
3. Ralph Johnso...
Gang of Four Patterns
Creational Patterns Structural Behavioral
1. Abstract Factory 6. Adapter 13. Chain of responsibility...
Reference
• Apex Design Patterns
• SOLID Principle
Q&A
Next Episode 22
Design Pattern - 2
Thanks
Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1
You’ve finished this document.
Download and read it offline.
Upcoming SlideShare
What to Upload to SlideShare
Next
Upcoming SlideShare
What to Upload to SlideShare
Next
Download to read offline and view in fullscreen.

1

Share

Episode 21 - Design Pattern 1

Download to read offline

Part 1 of Apex Design Patterns in Salesforce

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Episode 21 - Design Pattern 1

  1. 1. Path to Code Begin Your Salesforce Coding Adventure
  2. 2. Episode 21 Design Pattern - Part 1
  3. 3. Jitendra Zaa Salesforce MVP Sr Technical Architect 23x Certified @Jitendra Zaa Speaker
  4. 4. Agenda • SOLID • Design Principles • What are design Patterns • Who are Gang Of Four • GoF Patterns • Creational Pattern • Example
  5. 5. Some House Rules • Please mute your mic • Keep adding questions in Zoom Q&A Window • No question is too small • Questions will be answered in last 15 mins
  6. 6. SOLID Design Principles
  7. 7. Open Closed Principle Class should be Open for extension but Closed for Modification.
  8. 8. Example Create a Program to accept Circle and Square Object and return Sum of their Area.
  9. 9. Example
  10. 10. Run Code
  11. 11. Change in Requirement Add Support for Rectangle Also. What would you do ? Add one more If else? That would be breaking Open Closed Principle. Class should be closed to modification but open to Extension.
  12. 12. Solution Add Interface so that all Shape should follow that interface, new Class will become
  13. 13. Single Responsibility Principle A class should have one and only one reason to change that means only one job.
  14. 14. Example
  15. 15. Question AreaCalculator class calculates area and returns result of sum of area of all Shapes. How to add functionality if we want to get area result as JSON or HTML ?
  16. 16. Answer Incorrect
  17. 17. Explanation Its breaking Single Responsibility Principle. AreaCalculator should only change if formula related to Area changes
  18. 18. Liskov Substitution Principle If class B is a child of class A, then A can be replaced by B, without changing anything in a program. In other words, the LSP principle states that you should not encounter unexpected results if child (derived) classes are used instead of parent classes.
  19. 19. Interface Segregation Principle This states that do not force a child class to depend on a method that is not used for them. This principle suggests that you break interfaces into smaller ones so that a client can only implement an interface that is of interest.
  20. 20. Interface Segregation Principle
  21. 21. Dependency Inversion Principle This states that modules should not depend on each other directly and should depend via an interface (abstraction).
  22. 22. What are Design Patterns ? Each Pattern describes 1. A problem which occurs again and again 2. A core of the Solution 3. Consequences of Solution
  23. 23. Design Patterns Does not Provide Actual Implementation Details
  24. 24. Example - Roof Patterns in Construction
  25. 25. Who are Gang of Fours Book written in 1994 consist of 23 Design patterns by 1. Erich Gamma 2. Richard Helm 3. Ralph Johnson 4. John Vlissides
  26. 26. Gang of Four Patterns Creational Patterns Structural Behavioral 1. Abstract Factory 6. Adapter 13. Chain of responsibility 2. Builder 7. Bridge 14. Command 3. Factory Method 8. Composite 15. Intercepter 4. Prototype 9. Decorator 16. Iterator 5. Singleton 10. Facade 17. Mediator 11. Fly Weight 18. Memento 12. Proxy 19. Observer 20. State 21. Strategy 22. Template Method 23. Visitor
  27. 27. Reference • Apex Design Patterns • SOLID Principle
  28. 28. Q&A
  29. 29. Next Episode 22 Design Pattern - 2
  30. 30. Thanks
  • ssuserff11bb

    Dec. 14, 2019

Part 1 of Apex Design Patterns in Salesforce

Views

Total views

10,593

On Slideshare

0

From embeds

0

Number of embeds

10,325

Actions

Downloads

22

Shares

0

Comments

0

Likes

1

×