Tuesday 17 September 2013

Governor limits

  Multitanent architecture :  To share multiple users in single environment across common and exclusive features.
Governor limits:
             Governor limits simply means the limited database calls that a developer/user do.
These governor limits are important because unlimited and free access to database many number of times from each time will slow down the database effectiveness.So,to preserve the database effectiveness, governor limits are important in multi-tenant environment
  GL are are run time limits enforced by the ARE to ensure that code does not misbehave. Because apex runs in multitenant environment,types of limits apex enforces resources like memory,data base resources,num of script stmts to avoid infinite loops and num of records being processed.
@future :
1.       In apex by default every method is synchronize. If we can convert synchronize to asynchronized we can use @future. User wont have to wait  for  processing.
2.       Using @future to get higher governor limits.
Ex:
    If we can write trigger for Account and the apex logic wants to update whenever record is updated the related contacts are updated, in this scenario apex trigger cant be invoked by single account update would not be able to update thounsands of records synchronously. If we can use @future that allows to retrieve upto 50,000 records on SOQL,10,000 records in DML asynchronously.
3.      If we can call third party webservice methods(i.e call outs) form within trigger,you will need to execute that call out asynchronously by defining the web service request and response handling in @future
4.      If we use @future in method,we cant pass the sObject as a argument.

Unit test:
    unit tests are compressed test methods and classes that verify wheather a particular piece of code working properly or not.
     If your code is going to be packaged and placed force.com App exchange,the test method must provide 75% code coverage, code coverage means deviding the executing lines of code, total number of lines of classes(include triggers), it cant include test method code.
Unit test methods take no arguments, commit no data to the database, send no emails, and are flagged with the testMethod keyword in the method definition.

Test methods cannot be used to test Web service callouts. Web service callouts are asynchronous, while unit tests are synchronous.

Hint :   test method cant write with in trigger,because of it cant called out side of test context.
 EX: public class myClass {
    static testMethod void myTest() {
       // Add test method logic using System.assert(), System.assertEquals()
       // and System.assertNotEquals() here.
     }
}
 import wizard :
1.       Import upto 50,000 rex
2.       Here we can perform insert
3.       We can operate only standard  Lead,account,contact,solution and all custom objects
4.       This process is perform at that point of time
5.       We cant export the data
6.       Here we can prevent Duplicates records
Data Loader :
       1.we can import upto 50 mil rec
       2. we can perform insert,update,delete,upsert,harddelete,export,exportall.
       3.based on external id we can perform those actions
       4. this process is batch  process.
       5.the default batch size is 200, we override these batch using Bulk API option upto 10000.
       6.we can insert data from specified record to end

Batch Apex:
scheduling :
global class scheduledsec implements Schedulable {
   
    global void execute(SchedulableContext sc) {
       List<Book__c> li=[select id from Book__c];
       delete li;
    }
}
Scheduling the above class

Work flow :  work flow is automated process rule, this rule to perform when record is created or edited to check the specific criteria.
Work flow actions  1.New task 2. Field update 3. Send email 4.outbound message
Time dependent Work flow :
             When record matches the sprcified criteria execute according to time trigger.
 Time dependent workflow does not follow the every time the record is created or edited
Approval process :  
            Approvals are complex business  process ,this rule to perform when a record approve or rejected to Hierarchal  role user to check the specied criteria.
Approval process steps :
1.      Initial submission Action
2.      Final approval Action
3.      Final rejection Action
4.      Recall Action
Aggregate function :
 List<AggregateResult> b  = [SELECT name, MAX(Price__c) FROM Book__c  GROUP BY name];
system.debug('hhhhhhhhhhhhhhh'+b[0]);













No comments:

Post a Comment