Saturday, 20 July 2013

Fun With Maps In Apex

Maps are my favorite collection types .The Reason why its very essential to use Maps in apex  classes or triggers is it makes life simple for writing bulkified apex class or trigger .

Read more on Maps in below article from salesforce

http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections_maps.htm
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_map.htm

Apex we all know runs on an multitenant  architecture .The resources are shared and hence we have governor limits in apex .The advantages of proper usage of maps will help  to  reduce script statements,No of queries for a single context of class or trigger execution,avoiding query on a single object twice .

As a fresher to salesforce  we are unaware of various techniques that we can employ to reduce the script statements and reduce heap size of collection like Lists,Maps and Sets.

You can read some nice articles in developerforce and get familiar with some of common techniques which developers have discovered to deal with no of script statements and heap size issues

My favorite  recipes are as follows

http://developer.force.com/cookbook/recipe/using-sobject-constructors-to-save-script-statements
http://developer.force.com/cookbook/recipe/initialising-maps-from-queries

If you have been coding in apex from long time you might  have come across common use case that you need to aggregate collection of child records grouped by ParentId.

Something like say i will query on Contact Object and i am retrieving all contacts and I need a collection Map of Parent Id (AccountId) as Key and the collection of contacts related to AccountId .In short in apex language terms Map<AccountId,List<Contacts>>

Here is the code that i have included as an example on how to form the collection of Map<Id,List<Contact>>



Hope you enjoyed the technique .Happy coding !Let me know the feedback on the Post.

Thursday, 4 July 2013

Tips On Passing Advanced Developer Salesforce Certification Programming Assignment

As promised as per my previous blog i am sharing my experience on how to clear the advanced developer programming assignment and essay exams to obtain the Advanced Developer Certification.

One of the basic things i would like to mention is ,this you will not have it  overnight as the demand for the course is very high and there are limited slots available in each quarter .One has to be very sharp to quickly register for the exam on the dates mentioned in the certification.salesforce.com. Small negligence  will cause you to wait for another 2 to 3 months .

The assignments are distributed nearly after a month once you have registered .So this gives ample amount of time to revise your apex and visualforce skills.

Once the assignments are distributed you will have nearly a month time to complete your assignment and i would suggest reading the whole pdf that comes with assignment more than thrice atleast to make sure you understand the logical requirements and the hidden aspects of the assignments .

Usually a month time is enough for this but one has to make sure they spend atleast one weekend (Assuming your office timings are hectic and you have lot of work to cover on weekdays)

While doing assignment remember few key points 

1)Follow best practices while designing your trigger and visualforce controllers .Some of the reference links for the wiki articles that helped me  are below 

http://wiki.developerforce.com/page/The_Path_to_Advanced_Developer_Certification

http://wiki.developerforce.com/page/Apex_Code_Best_Practices

http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods

http://wiki.developerforce.com/page/Apex_Code_Best_Practices

http://wiki.developerforce.com/page/Enforcing_CRUD_and_FLS


2)Testing is the most important aspect that is looked when your assignments are evaluated .Make sure you have adequate test methods with proper asserts 

3)Your application will also be evaluated as per security guideline's so make sure you understand the best practices for writing a secure code 


What does an Essay Examination consists of ?

Essay exams are just to evaluate that you have yourself designed the application and written the code .A Simple descriptive questions will be thrown that you should be good if you yourself have written the code .

To understand more on this i would suggest you to read the below article which is one of the best articles written so far on this subject


Hope you enjoyed this short read and its informational.Let me know your feedback on this article .

Introducing Lightning Base Components

Lightning Base Components are great addition to the platform and in fact revolutionary .One of the concerns around lightning component ...