Skip to main content
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs

Questions tagged [oop]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
0 answers

Not able to access interface methods from an abstract class instance

I'm trying to build an Apex classes structure where I have two (or more) entities that have something in common but at the same time have a different set of fields. In the example below it's gonna be ...
Ilya Matsuev's user avatar
0 votes
2 answers

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 ...
user2943892's user avatar
0 votes
1 answer

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 ...
Carryonplease's user avatar
0 votes
1 answer

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 ...
thinker's user avatar
  • 1,430
0 votes
1 answer

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 ...
Lafexlos's user avatar
  • 509
-1 votes
2 answers

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 ...
sdandamud1's user avatar
  • 2,705
1 vote
2 answers

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 ...
sdandamud1's user avatar
  • 2,705
1 vote
2 answers

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 ...
JQKAndrei's user avatar
1 vote
1 answer

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 ...
Brooks Johnson's user avatar
0 votes
1 answer

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 ...
Kruse in Salesforce's user avatar
35 votes
4 answers

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.
imajmdf's user avatar
  • 867
2 votes
0 answers

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 ...
Arnold's user avatar
  • 439
6 votes
1 answer

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--> ...
itsmebasti's user avatar
  • 6,457
0 votes
1 answer

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 ...
VPY's user avatar
  • 1,018
1 vote
2 answers

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 ...
PartOfTheOhana's user avatar
13 votes
3 answers

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 { ...
Vladyslav K's user avatar
  • 2,743