Skip to main content

New Salesforce Book - Apex Design Patterns


I'm really excited to share that today my book (co-written with Jitendra Zaa) has been published. Here are some personal insights

A little history
This particular topic was always in my head and coming from .Net background and having worked with lots of design patterns in MS development world. I first successfully used Factory design pattern with Apex in 2009, when all my team was scratching their head and (cursing me badly) for "overtly complicating" the code architecture. They were happy with creating 20-30 different VF pages, which I emphasized needs to be designed with the help of 4-5 VF pages, VF components and factory method pattern. Well, we were able to complete the whole stuff in time and deliver it flawlessly. It was then and similar instances later that I realized that a larger faction of Salesforce developers (back then) had very less knowledge about design patterns and code architecture. There was a huge gap.

Over the years a lot of bloggers have shared so much valuable content that the gap has almost diminished now. It was during conversation between Jitendra and myself that we realized that we should address this area and try to share some more details.

About the Book (also included in book)
The first and obvious challenge we faced was the presence of lots of highly informative and relevant blogs and books out there addressing design patterns. Largely, the information is out there. But, we realized that most of the content is primarily Java centric and it is very hard for a non-seasoned Java programmer to understand the nomenclature of design patterns. Furthermore, most of the example scenarios are also very alien to Salesforce development.

So, we created content keeping Salesforce developers in mind. The content was supposed to be very easy to understand and the all scenarios were to be Salesforce related. We spent so many hours debating on minute things, to ensure that any reader reading this book will be able to grasp and hold on to the knowledge (it's the latter part which has been the biggest challenge with design patterns).

Writing Experience
Well, all I can say is that it was not easy. All these months (around 7-8) we were in constant pressure to stick to timelines. So, we divided some patterns amongst ourselves. Then came Dreamforce '15 and we got really occupied with it. After Dreamforce '15, we completed first draft of all chapters and shared. All this while we both were working in silos and interacting on need basis.

BAAM!! came the review, and let's just say it was not that bad (as I expected) and not that good either (I very well expected that). So, we sat down together and realized that we got to dedicate lot of quality time together on this, if we have to deliver this. So, we did. We spent lots of nights and weekends on phone calls (2-7 hrs in a day) and reviewed each and every sentence. It'll not be wrong to say that we almost re-wrote entire content again.

At the end it was definitely a very tough journey. But, as they say "No Pain, No Gain". However, painful it was to write and review content at 3AM in morning, it given immense satisfaction to learn that I was able to contribute towards greater purpose of sharing knowledge amongst community.

Sincere thanks to Jitendra(co-author) for his dedication and support. Thanks to John(reviewer) for his impeccable reviews. I'm sure he would have recovered well after reviewing our first draft (pun intended).

I really hope that every reader will be able to understand and adapt to the usage of more and more design patterns or rather structured code architecture. Feel free to share your comments with Jitendra and myself.


Popular posts from this blog

Quick Tips: Salesforce default Images

Well, I'm sure a lot of you still rely on using out of the box salesforce images for displaying quick icons within formula fields or even using them within your Visualforce pages. Lately, I realized that a lot of earlier resources are no longer accessible, so I tried to quickly extract all images from Salesforce CSS files and provide a quick reference here. Please note, I've referenced all images from SF servers directly, so if anything changes, the image should stop rendering here. As these images are completely controlled by Salesforce, and in case they change anything, it might lead to image not being accessible. Image path Image /img/samples/flag_green.gif /img/samples/flag_green.gif /img/samples/flag_red.gif /img/samples/color_red.gif /img/samples/color_yellow.gif /img/samples/color_green.gif /img/samples/light_green.gif /img/samples/light_yellow.gif /img/samples/light_red.gif /img/samples/stars_100.gif /img/samples/stars_200.gif /img/samples/stars_300.

Lightning: Generate PDF from Lightning components with in-memory data

I'm sure as everyone is diving into lightning components development, they are getting acquainted with the nuances of the Lightning components framework. As well as, its current limitations. Being a new framework, this is bound to happen. Although we have our users still using salesforce classic, we have started using lightning components framework our primary development platform and Visualforce is considered primarily for rendering lightning components within Classic Service console. Recently, while re-architecting a critical module, we encountered a problem wherein we needed to generate PDF from lightning components. Now, being Javascript intensive framework, it has limited room for such features (may be included in future roadmap). As of now, there is no native feature within the lightning framework to do so (at least I didn't find anything). Common Scenario - Create Visualforce page to retrieve data and generate PDF For scenarios where the data exist within Sa

Lightning: Generate PDF within Lightning Experience with Salesforce Data

Some time back I posted a solution to generate PDF from Lightning components using in-memory data. Post url: It was developed for a specific scenario, wherein we need to generate PDF where: User interface is Salesforce classic Initiated via Lightning Component Data doesn't exist within Salesforce and is completely in-memory As complex and tricky this situation was, we did end up finding a stable and equally tricky solution. However, I realize that there are still lack of solutions (or maybe my search skills are downgrading) to generate and automatically download PDF document from Lightning Experience, without using any lightning components, wherein data exists within Salesforce. You can use the earlier solution in that case, but it will be an overkill. There are various solutions available to generate PDF from javascript. But, I still think the plain old method of converting HTML to PDF (via