First of all your code doesn't compile now. That explains a lot.
Secondly, in my opinion messing with polymorphism in static classes (wholly static as you said) is not a good design at all. I don't see any good reason (although there might be some) driven by design needs to do try to access static method with super
. But question is still interesting, so let's move on.
Third thing is, you use super
keyword to reference private member. It shouldn't be possible at all. Private is private. If it compiled somehow, that was certainly a bug.
Answering to point 1:
As I said, I can't see any reason to inherit from static class. Actually It's not even an inheritance, you can access public members of any other static class anyway like listed below. Moreover, it's not permitted now - when I tried to compile your code (and many of it's variations :) I get the Variable does not exist: this
error from line -1 (valuable clue!). Not surprisingly, the code like this works fine, and it doesn't grant any access to other private members:
public virtual class Fact_BaseFactory
{
public static void populateFieldNameToTypeMap(String objectName) { ... }
}
public class Fact_Account extends Fact_BaseFactory
{
static
{
Fact_BaseFactory.populateFieldNameToTypeMap('Account');
}
}
According to second question:
A)
This idea seems to be the way to go, I would just create some public method In the helper class and reuse the code within your factories. Not sure what you mean with violating DRY here.
B)
Composition instead of inheritance is good design in general based on my experience and it's also recommended by Head First "Design Patterns" book. I would stick to the A anyway, but it's a good question to ask on codereview.stackexchange.com
When a trigger executes each invocation may have up to 200 records. So, if 200 or more app__c
records were updated in a single transaction the following loop would run 200 times for the first invocation of the trigger.
if (Trigger.isAfter){
For (app__c dac: Trigger.new){
App_keygenrt.sendRequest(dac.App_Key__c,dac.Name);
}
}
That's 200 asynchronous calls being made to your future method, that will each result in a single callout.
Instead, build up a collection of all the requests that need to be made and pass it off in a single call to the future method.
Now the problems becomes passing the data the the HTTP Callout. In the ideal world the web service would be modified to work on multiple records at once.
If that isn't possible, you will need to work within the Callout Limits and Limitations.
Best Answer
If you want your inner class to access outer class instance variables then in the constructor for the inner class, include an argument that is a reference to the outer class instance.
The outer class invokes the inner class constructor passing
this
as that argument.The example is artificial but illustrates how
this
can be used to give the Inner Class access to anything the Outer Class instance can reference.