Skip to main content
New
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
274 views

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
510 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 ...
user2943892's user avatar
0 votes
1 answer
75 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 ...
Carryonplease's user avatar
0 votes
1 answer
127 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 ...
thinker's user avatar
  • 1,430
0 votes
1 answer
62 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 ...
Lafexlos's user avatar
  • 509
-1 votes
2 answers
502 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 ...
sdandamud1's user avatar
  • 2,705
1 vote
2 answers
4k 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 ...
sdandamud1's user avatar
  • 2,705
1 vote
2 answers
274 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 ...
JQKAndrei's user avatar
1 vote
1 answer
8k 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 ...
Brooks Johnson's user avatar
0 votes
1 answer
286 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 ...
Kruse in Salesforce's user avatar
35 votes
4 answers
37k 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.
imajmdf's user avatar
  • 867
2 votes
0 answers
80 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 ...
Arnold's user avatar
  • 439
6 votes
1 answer
239 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--> ...
itsmebasti's user avatar
  • 6,457
0 votes
1 answer
105 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 ...
VPY's user avatar
  • 1,018
1 vote
2 answers
445 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 ...
PartOfTheOhana's user avatar
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 { ...
Vladyslav K's user avatar
  • 2,743