Git Product home page Git Product logo

df12-apex-enterprise-patterns's People

Contributors

afawcett avatar afawcettffdc avatar mattolde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

df12-apex-enterprise-patterns's Issues

Are Selector classes really unable to retrieve parent fields?

Having centralised SOQL Builders is of immensive use, but not being able to query parent fields limits its usage in enterprise apps very much

This doesn't even compile

    public List<Schema.SObjectField> getSObjectFieldList() {
        return new List<Schema.SObjectField> {
            ChildRecord__c.Name,
            ChildRecord__c.Parent__c,
            ChildRecord__c.Parent__r.GranParent__c
        };
}

This compiles but doesn't query the defined fields:

    public List<Schema.SObjectField> getSObjectFieldList() {
        return new List<Schema.SObjectField> {
            ChildRecord__c.Name,
            ChildRecord__c.Parent__r.Id,
            ChildRecord__c.Parent__r.GranParent__r.Id
        };
    }

Failed to pass security review due XSS and Sharing issues in this library

I am using the library in a product I just released for security review and I failed as they found:

Finding 03 โ€“ Possible SOQL Injection
Severity: High

Scanning File: ...\classes\fflib_SObjectSelector.cls
175 String soql = String.format('SELECT {0} FROM {1} WHERE {2} ORDER BY {3}', new List{
176 fieldList,
177 getSObjectName(),
178 whereClause,
179 getOrderBy()});

Finding 02 โ€“ Use of without sharing Keyword
Severity: Medium

Evidence:
Public Class:
Scanning File: D:...\classes\fflib_SObjectUnitOfWork.cls
1 public class fflib_SObjectUnitOfWork

Moving code from triggers to domain classes makes me use "without sharing"

In one of my old triggers I called a class that does some Chatter Follow magic. This code basically needs to run in systems mode to not run into "Implementation restriction: EntitySubscription only allows security evaluation for non-admin users when LIMIT is specified and at most 1000"

When I move this calling code to a SObjectDomain inheriting class I received the above error and just could get rid of it by adding a "without sharing".

Isn't this dangerous to do this for the whole Domain class when just a called method has problems with it?

You can find more code details in this StackExchange post (http://salesforce.stackexchange.com/questions/11425/implementation-restriction-entitysubscription-only-allows-security-evaluation-f)

I am looking forward to your opinion on this.

Best regards

Robert

Returning data from the service layer

I have a couple of questions about how data should be returned from the service layer.

First of all, would you anticipate returning domain objects from the service layer to visual force clients? This seems reasonable to me, but I didn't see any examples of returning data from the service layer in your demo code (other than returning a List of newly created IDs). I guess the visualforce page would be binding to the Records property?

Also, if you do return a Domain object it will have to have the same access modifier as the Service class which is "global" in your code. I ran into this limitation in my testing. I think that the service class is defined as global so that it will be accessible in API calls, but I'm considering making it public and using a Facade class to interact with the service for API interaction.

My second question is about related objects. For example, I have a Payment object that has a lookup reference to a Transaction object. I want to create a service layer function that returns a collection of payments including a few properties from the related Transaction object. (w/o creating formula fields on the payment). Can domain objects be extended to return fields not part of the SObject they wrap - either calculated values or values from related objects? Would it best to use some other type of wrapper class?

My knowledge and experience with Apex is still very limited, so I apologize if I'm not explaining things well. I appreciate any input you have on these questions.

Thanks,
Seth

Error with SObjectUnitOfWorkTest

Receiving the following error: System.AssertException: Assertion Failed: Overhead of using UnitOfWork has grown above 3000 statements.
Stack Trace: Class.fflib_SObjectUnitOfWorkTest.testUnitOfWorkOverhead: line 271, column 1

How do I start to troubleshoot this error?

How would SObjectDomain work for generic SObject with multiple RecordTypes?

Hy Andrew,

I have a sobject called Document and many record types. I would like to put common code into an abstract or virtual base class and record type specific things into subclasses. Regarding constructor rules in subclasses (no 0-arg constructor, ....)) I can't get this running.

Have you implemented such a structure? How did you circumvent those problems?

Best regards,

Robert

static use of OpportunitiesSelector methods

I have a quick question about the OpportunitiesService line 50. It looks like you're referencing OpportunitiesSelector.selectByIdWithProducts statically, but the methods (in the selector) appear to be defined as instance methods. In other places I see you instantiate selectors before using them.

I'm a total n00b so I may likely just be missing something.

Thanks,

Transferring collections to service layer for persistence

Hi, I'm trying to embrace "bulkification throughout" and am finding some challenges when writing add/save functions in my service layer. What's the best way to pass data collections from a Controller to the service layer?

For example, in this project we have the OpporunitiesService.applyDiscounts() method that accepts a set of opportunitiyIds and a discount percentage. If you wanted to have a different discount for each opportuntiy how would you arrange your input? A Map? What if you had both a discount percent and some other field that were both related to an opportunitiyid?

I looked into Transfer Objects a little bit, but wasn't 100% sure if that pattern would help here. For now, I've resorted to passing parallel lists from my Controller to my add/save functions in the ServiceLayer.

Thanks again!
Seth

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.