Salesforce Interview Quetions

1) What are design patterns in salesforce ?
     Design patterns are predefined steps or rules that help solve common problems in a structured way. They improve code maintainability
     and scalability  code. There are various types of design patterns, such as creational, behavioral, and structural patterns. 
     While you don't need to know them all, familiarizing yourself with popular ones like.
1)  Singleton Design pattern
2)   Factory Pattern
3)  Abstract Factory
4)  Command Pattern
5)  Decorator 
6)  Trigger/Handler patterns can be beneficial.
    - Breaking up long sentences
    - Removing repetitive phrases
https://www.pantherschools.com/apex-design-patterns-series-part-1/

2) Future Vs queueable apex

FUTURE APEX QUEUEABLE APEX
It is annotation based so we can use the same apex class to write the future method. Syntax: @future    It is a class which implements’ queueable interface. Syntax: public class CLASS_NAME implements Queueable{}
We cannot monitor the jobs  We can monitor the jobs based on the job Id.
we cannot call a future from another future or batch apex. The limit on future method for single apex invocation is 50. We can chain the Queueable jobs and the stack depth in developer org is 5 and in enterprise edition you can chain 50 jobs.
1.Future method supports only primitive datatypes.
2.No Chaining Support
3. Limited Error Handling  

1.Queueable supports both primitive and non-primitive data types.
2.Supports Chaining
3. Enhanced Error Handling Ex: We can use Try catch blocks

https://www.merfantz.com/blog/what-is-the-difference-between-future-method-and-queueable-in-salesforce/

Future Method Example:

public class FutureExample {
@future
  public static void processFutureMethod(String accountId) {
     Account acc = [SELECT Id, Name FROM Account WHERE Id = :accountId];
         acc.Name = ‘Updated Name’;
         update acc;
   }
}

Queueable Apex Example:
public class QueueableExample implements Queueable {
private String accountId;
public QueueableExample(String accountId) {
this.accountId = accountId;
 }
public void execute(QueueableContext context)
   {
     Account acc = [SELECT Id, Name FROM Account WHERE Id = :accountId];
     acc.Name = ‘Updated Name’;
     update acc;
   }
 }

3)  Design Patterns in Lightning Web Components(LWC) ?
Table of Contents:
1.  Introduction: Design Patterns in Lightning Web Components(LWC)
2.  Singleton Pattern
3.  Observer Pattern
4.  Decorator Pattern
5.  Factory Pattern
6.  Making the Most of Design Patterns: Real-Life Examples
7.  Conclusion

4) How to avoid recursion in Trigger ? Recursion is the process of executing the same Trigger multiple times to update the record again and again due to automation. There may be chances we might hit the Salesforce Governor Limit due to Recursive Trigger. public class ContactTriggerHandler{ public static Boolean isFirstTime = true; } Trigger ContactTriggers on Contact (after update){ Set<String> accIdSet = new Set<String>(); if(ContactTriggerHandler.isFirstTime){ ContactTriggerHandler.isFirstTime = false; System.debug('---- Trigger run ---->'+Trigger.New.size() ); for(Contact conObj : Trigger.New){ if(conObj.name != 'Test') { accIdSet.add(conObj.accountId); } } // any code here } }

5) Enable Dynamic Dashboard ?

Manage Dynamic DashboardsChecked

View My Team's DashboardsChecked

Comments

Popular posts from this blog

My Trigger Scenario's

Configure types Of Products in CPQ and Revenue Cloud ?

Steps for Calculate Derived Pricing in RCA ?