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 3
Classes, Objects, Inheritance, Abstract Class, Interface
Sr Technical Architect
Salesforce MVP
23 Salesforce Certifications
@JitendraZaa
Jitendra Zaa
Agenda
• What are Classes & objects
• Constructor and static blocks
• Access specifiers
• Static Methods
• Inheritance
• A...
Some House Rules
• Mute your mic
• Keep adding questions in Zoom Q&A Window
• No question is too small
• Questions will be...
Badges Leaderboard
Best Practices - 12 years in Coding
• Simplicity - easy to maintain and debug code in future
• aka KISS (Keep It Simple,St...
Class
• Class is blueprint or definition to create object
• It does not take any space in memory
• Consider it as guidelin...
Object
• Used to create custom data type
• It can contains variables or methods
• Objects are created using new keyword
• ...
Object Instantiation
Object creation includes three part
Rectangle rec = new Rectangle();
Rectangle - Declaration
new - In...
Access Specifier
Everything Public Private + Public
vs
Demo 1
Problem Definition
• Code to calculate Total Amount for number of products
• Code is written, tested and deployed
• Workin...
What to do ?
Should we add if else ?
What if it breaks existing code ?
How much effort would it take to test everything ag...
What If ?
Wouldn’t it would be great that I should not change any existing code,
as its tested and working fine in product...
Inheritance
Capability to create a new class which will contain functionality of
original class + Change existing function...
Demo 2
Problem Definition
• There are different rule to calculate pricing of product
• Allow client to implement these rules as i...
Abstract Classes
• Contains some fully implemented method and some methods left
unimplemented with abstract method.
• Any ...
Demo 3
Problem Definition
• You are in global team where developers are spanned over
countries. Lots of changes in team.
• How to...
Problem Definition
• How should Salesforce enforce you that below class must need to
have start(), execute() and finish() ...
Problem Definition
You have a CPQ product. How would you enable your customer to have
their own implementation of pricing ...
Interface
• Establishes contract that child class must follow
• Can only have method definitions
Demo 4
Static Methods / Variables
• Use method in class without instantiating / new keyword.
• Use static keyword to declare meth...
Demo 5
Recommended Books
Level 1- Apex Design Patterns
Level 2 - Advance Apex
Level 3 - Enterprise Architecture
Q&A
Thank You
Upcoming SlideShare
Loading in …5
×

of

Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 1 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 2 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 3 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 4 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 5 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 6 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 7 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 8 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 9 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 10 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 11 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 12 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 13 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 14 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 15 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 16 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 17 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 18 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 19 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 20 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 21 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 22 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 23 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 24 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 25 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 26 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 27 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 28 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 29 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 30 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 31 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 32 Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces Slide 33
Upcoming SlideShare
What to Upload to SlideShare
Next
Download to read offline and view in fullscreen.

2 Likes

Share

Download to read offline

Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces

Download to read offline

Path to code - Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces

  1. 1. Path to Code Begin Your Salesforce Coding Adventure
  2. 2. Episode 3 Classes, Objects, Inheritance, Abstract Class, Interface
  3. 3. Sr Technical Architect Salesforce MVP 23 Salesforce Certifications @JitendraZaa Jitendra Zaa
  4. 4. Agenda • What are Classes & objects • Constructor and static blocks • Access specifiers • Static Methods • Inheritance • Abstract Class • Interfaces • Recommended Books to become level 3 Rockstar #AwesomeDev • Q&A
  5. 5. Some House Rules • Mute your mic • Keep adding questions in Zoom Q&A Window • No question is too small • Questions will be answered at the end or on blog
  6. 6. Badges Leaderboard
  7. 7. Best Practices - 12 years in Coding • Simplicity - easy to maintain and debug code in future • aka KISS (Keep It Simple,Stupid) • Write code keeping change in mind • Functional Test Coverage is Angel • Methods - as small as possible (20 line principle) • DRY principle (Don’t Repeat Yourself)
  8. 8. Class • Class is blueprint or definition to create object • It does not take any space in memory • Consider it as guideline or contract detail
  9. 9. Object • Used to create custom data type • It can contains variables or methods • Objects are created using new keyword • Object can be created on basis of class
  10. 10. Object Instantiation Object creation includes three part Rectangle rec = new Rectangle(); Rectangle - Declaration new - Instantiation Constructor - Initialization
  11. 11. Access Specifier Everything Public Private + Public vs
  12. 12. Demo 1
  13. 13. Problem Definition • Code to calculate Total Amount for number of products • Code is written, tested and deployed • Working fine from last 4 weeks • Change requested by Client to give discount to some customers
  14. 14. What to do ? Should we add if else ? What if it breaks existing code ? How much effort would it take to test everything again ?
  15. 15. What If ? Wouldn’t it would be great that I should not change any existing code, as its tested and working fine in production ? If I can just add this new change without changing new code ?
  16. 16. Inheritance Capability to create a new class which will contain functionality of original class + Change existing functionality OR add some more without impacting existing code.
  17. 17. Demo 2
  18. 18. Problem Definition • There are different rule to calculate pricing of product • Allow client to implement these rules as its unknown • However, whatever the rule of pricing, during purchase it must update inventory • In scenarios where, Some functionality are known and some are not known, use abstract class.
  19. 19. Abstract Classes • Contains some fully implemented method and some methods left unimplemented with abstract method. • Any class containing one or more than one abstract method known as abstract class. • Abstract classes cannot be instantiated using keyword new. • In order to instantiate abstract class, it must be extended using child class.
  20. 20. Demo 3
  21. 21. Problem Definition • You are in global team where developers are spanned over countries. Lots of changes in team. • How to make sure that developer in your team working on some plugin are forced to create all necessary methods.
  22. 22. Problem Definition • How should Salesforce enforce you that below class must need to have start(), execute() and finish() methods ? Database.executeBatch(yourclass); Link here
  23. 23. Problem Definition You have a CPQ product. How would you enable your customer to have their own implementation of pricing but at same enforce them they must have method named calculatePricing(List<Opportunity) ?
  24. 24. Interface • Establishes contract that child class must follow • Can only have method definitions
  25. 25. Demo 4
  26. 26. Static Methods / Variables • Use method in class without instantiating / new keyword. • Use static keyword to declare method or variable • There is only one copy as compared to instantiated objects • static method can access only static variable. Example of coffee shop • Instance methods can access static but opposite is not true
  27. 27. Demo 5
  28. 28. Recommended Books
  29. 29. Level 1- Apex Design Patterns
  30. 30. Level 2 - Advance Apex
  31. 31. Level 3 - Enterprise Architecture
  32. 32. Q&A
  33. 33. Thank You
  • roushankumar125

    Jan. 25, 2019
  • SivaMiriyala

    Jan. 23, 2019

Path to code - Episode 3 – Classes, Inheritance, Abstract Class, and Interfaces

Views

Total views

3,787

On Slideshare

0

From embeds

0

Number of embeds

3,466

Actions

Downloads

37

Shares

0

Comments

0

Likes

2

×