Questions tagged [oop]
The oop tag has no usage guidance.
15
questions
0
votes
2
answers
90
views
How Singleton pattern with Early Initialization vs Lazy Loading in Apex differs?
I was going through the articles on the Singleton pattern in apex and came up with an example that describes Early Initialization vs Lazy Loading in the Singleton pattern.
Early Initialization:
public ...
0
votes
1
answer
31
views
Should I be using a better OOP pattern (DI, Factory?) for this API callout with a big wrapper class
I'm trying to up my OOP game and utilize good patterns where I can. Recently I wrote some classes that essentially take a custom object (a quote) and build a very long/complex api request body using a ...
0
votes
1
answer
61
views
Why do developers set 'this' to a variable (e.g. 'self' or 'that')?
When I inherit another developers code base I will often see something declaration like the following:
I have seen this most frequently used in LWCs. But I'm not sure what the purpose is and given the ...
0
votes
1
answer
56
views
Break single responsibility to save a soql call [closed]
We are making a rest API call to the external DB. In simplified terms, it looks like below (the payload might not be in the correct json format here but normally it is).
public class ...
-1
votes
2
answers
396
views
Apex coding structure (What is a static initializer?) [closed]
Static code initializer.
is there any best practice use case for strictly need to be use static initializer?
public without sharing class parentcls {
static List<classA__c> classAlist;
static ...
1
vote
2
answers
2k
views
how to call constructor class method by calling constructor
i want to load wrapper class with one shot, but I couldn't able. may be still my oops skills are weak. i feel we can write much better way
public class WrapperA{
public Id sobjerecid;
public ...
1
vote
2
answers
191
views
Is there any way to add Interfaces to SObjects?
I have a problem where we have two SObjects with similar fields and we often convert one to the other. On top of that we have two classes that represent each of the SObjects as a DTO and another DTO ...
0
votes
1
answer
6k
views
Override specified on a non-overriding method
I am trying to play around with creating a base Trigger handler class that each trigger type can extend. I wanted to pass the trigger types into the base class as a member variable and then be able to ...
0
votes
1
answer
235
views
How to set attribute.Metadata field in .callServer with Javascript Var?
I tried to get the description of the title correct. If you think there might be a better one that describes better the scenario, please suggest!
In lightning components, I have a cpq_Configure ...
29
votes
4
answers
28k
views
What's the difference between Abstract class and Virtual Class
Hi I'm just confused on how to to use Abstract class and Virtual. Can't seem to find any difference between them and what are some scenarios where in it's applicable to use abstract or virtual.
2
votes
0
answers
73
views
Using Abstract and Interface Class - Building application in Salesforce
I have been intrigued by using design patterns, Object oriented concepts when programming. I do not have much hands on with using these concepts when programming salesforce. I do have a theoretical ...
6
votes
1
answer
233
views
Dynamic Polymorphic Lightning Components
I have a Parent component rendering child components. I want this to happen dynamically, meaning that I can pass in a child component definition and fill it with data afterwards.
<!--c:child-->
...
0
votes
1
answer
99
views
Trailhead : Variable Scope Issue (Compiler Error)
This is my class
global class ProjectCalloutService1 {
String OppId;
@InvocableMethod
public static void postOpportunityToPMS(List<Id> oids)
{
OppId = oids[0];
}
global class ...
1
vote
2
answers
417
views
Can Apex properties take input- An encapsulation question?
Say I have a proprerty, and I want to pass in an input to it in the setter, can I do that?
This snippet below is well encapsulated java code. but it's a bit verbose.
private Decimal weight;
public ...
13
votes
3
answers
1k
views
OOP best practices - use object fields dynamically
Let's say I am working with bicycles and I need to group them by different criterias.
class Bicycle {
String brand { get; set; }
Date purchaseDate { get; set; }
}
class GroupedBicycles {
...