Do you know how to write the code that survives the test of time

“You have to be burning with an idea, or a problem, or a wrong that you want to right. If you’re not passionate enough from the start, you’ll never stick it out.” — Steve Jobs

Just like the paintings of Jackson Pollock, a Salesforce Developer is an abstract concept. Therefore, it is prudent for me to confirm the audience for this post. To put it very simply, if you write code, this is for you. If you do clicks and not code, this article will mean nothing to you.

With that out of the way, let's dig in. Salesforce is one of the hottest skills on the market and more and more people are moving towards the technology. It is wonderful to see new batch of developers, engineers getting into salesforce. In the last six months, I came across two instances, the first one, they had a lot of redundant code and the system was sluggish, slow and governor limits were flying off the charts. The second one had given up. They spun a brand new environment and we redoing the whole thing.

Both the instances is not a healthy scope for a project and if you have to reinvest into the whole thing every few years, you are doing something wrong. So if you are a developer who have just started writing code, you should follow this list.

1. Don't create too many relationships

The customer wants reports about a primary contact associated with an account. Let me go and quickly create a lookup on account to the contact. DON'T. (very specific example!). The more lookups and master-details you create, the more convoluted your organisation will become. At some point, your objects will be so entangled that finding where the main record (or master record) in Salesforce resides will be a challenge. We live in a multi-tenant architecture, having too many relationships to the same object will completely fork your implementation.

I'll refer to these blog posts for more information,
The world is flat- design principles for data modeling

Image result for triggers in salesforce"

2. Don't just write triggers, think!

Triggers are the original sin on Salesforce. The little bits of code, mostly harmless, that majority of time gives you the too many SOQL, or too many DML or the most coveted, heap space allocation.
If you are going to write the first trigger in your organisation, you have to think about the one after that and the one after that and so on.
Why? Because triggers will always trigger other triggers and those triggers will trigger more triggers. Read that again.
Over the period of time, triggers increase the technical debt and it is useful if you can set up some design principles before-hand.
There are many trigger design patterns in the community, you can choose one.

Image result for code comments funny"

3. Your code should have comments

This is more worrying trend that I have observed recently. Code that does not have comment is a garbage code. Your code should start with a proper class header, describing why in the godforsaken world have you decided to write the class. What is its purpose and why is it useful.
Many developers fail to do this, assuming, they will be there if things go wrong. But remember time is not kind to people who do not change. Humans will move on. Code remains. And the next developer that looks at your code that lacked comments will belch at it.

4. Always find time to learn new things

Salesforce is a evolving technology. They have conquered the market by evolving faster than their competition. Salesforce keeps adding new things and improving its interface. As a developer, you have to learn them all- the clouds, the configuration. You cannot just stick to the code because that's what you do. There will always be a better way to solve a problem. And you have to learn about it.

5. Always improve your problem solving skills 

Good developers stick to what they know. Good engineers solve problems better. A few years ago, we had ajax controls on visualforce. One of them was actionfunction. You declare an action function and you can then call that in any Java code

<!-- Page: -->
<apex:page controller="exampleCon">
<!-- Define the JavaScript function sayHello-->
<apex:actionFunction name="sayHello" action="{!sayHello}" rerender="out" status="myStatus"/>
<apex:outputPanel id="out">
<apex:outputText value="Hello "/>
<apex:actionStatus startText="requesting..." id="myStatus">
<apex:facet name="stop">{!username}</apex:facet>
<!-- Call the sayHello JavaScript function using a script element-->
<p><apex:outputText value="Clicked? {!state}" id="showstate" /></p>
<!-- Add the onclick event listener to a panel. When clicked, the panel triggers
the methodOneInJavascript actionFunction with a param -->
<apex:outputPanel onclick="methodOneInJavascript('Yes!')" styleClass="btn">
Click Me
<apex:actionFunction action="{!methodOne}" name="methodOneInJavascript" rerender="showstate">
<apex:param name="firstParam" assignTo="{!state}" value="" />

This method was considered the best method, until visualforce remoting came in picture. Now actionfunction is heavy, submits a form and is not realtime.

<script type="text/javascript">

    Visualforce.remoting.timeout = 120000; // Set timeout at page level

    function getRemoteAccount() {
        var accountName = document.getElementById('acctSearch').value;

        // This remoting call will use the page's timeout value

    function handleResult(result, event) { ... }

In Salesforce there are always multiple ways of doing a particular thing. The difference between an ordinary programmer and the engineer is the ability to find the best possible fit. And when you do that your code will scale and survive the test of time.

6. Be hacker first

Hacker is a term that has got a negative connotation. I can hear the hair on the arms of many information security officers raise in goosebumps as you read this. But hear me out. This does mean you try to figure out a way to break the system (or if you do, be nice to tell the system admin how to plug it), or you typing on loud music in some horrible cubic text that they did in swordfish.
Hacker is someone who is relentless in finding solutions. Don't let technology defeat you. Lightning, Apex. Java or any other language that gets thrown in your path, figure out a way to work with it. Have seen so many developers get defeated with Javascript!
Don't let that be you.

So there you have, my tips to let your code survive the test of time... What do you think about it? What is your best tip to write the best code ever? 

Let me know.


Chatbots: The future of customer service?

I have been spending a lot of time trying to remodel and train a chatbot, trying to make it as human as possible.
The model is not without flaws, event though I have collected a lot of intents from Amazon. This was the presentation I gave on the topic at the London DUG.

And to see the chatbot follow this link:

Note: Order number: 00001- 00011
Scenario: Your order is lost or you have not yet received your order.


Video: Top ten tips on how not to ruin Salesforce implementation

Another presentation for the London Salesforce Developer Group using mobile app. 

When it comes to Salesforce development, we all know what it takes to deliver stuff. Having a certified professional helps you gain a knowledgeable partner but what about the things such as common sense?  We all know how to deliver things on client requirements but what about things that are not mentioned by the client. We will be discussing in details things that will enhance the user experience, focus on tips to read your customers mind and have a bit of perspective on the user experience.


[Novel] Ragnarok- The book

Ragnarok is a work of fiction released in 2015. The story is a science fiction with a cynical satirical look at the modern civilization and satire. It is a thought exercise of what will happen when ultimate power is within the grasp of human beings. The book released in August 2015 by Half Baked Beans publishers. Cover Reveal |  Synopsis |  Buying Links | Teaser |  Meet the Characters |  Download Preview | Facebook  | Twitter 

Cover Reveal

Ragnarok- Synopsis

A patient, with no memory of his past, is admitted in a hospital by a world-famous psychiatrist. A sinister, secret society comprising of scientists and inventors have an agenda to stop the patient form getting his memory back. They will stop at nothing. As a doctor, she has to outwit some of the smartest men on the planet to save her helpless patient and at the same time, find out who he really is. Who is this patient? Why are such powerful men after his life? What does his memory hold? The answer to these questions lie buried deep in time, even before the birth of first human. One android will travel back in time to the end of Mesozoic era, where the last dinosaurs breathes his final breath to find out who he is. Will she be able to complete her quest in the past? Will the psychiatrist be able to protect her patient from the mad scientist in the present? Can they together be able to safeguard the future? The distinction between the past, present and future is only a stubbornly persistent illusion.- Albert Einstein Get ready for adventure of epic proportions through space and time. - Ragnarok


Meet the Main Characters