Tag Archives: Logic

De-mystifying & optimizing view state

HTTP is a stateless protocol.  Your Visualforce pages though may need to maintain state across multiple HTTP requests / postbacks.  Visualforce automatically does this for you with view state making your job as a developer easier.  Find out more about what is in view state, the new view state inspector in Summer '10 and best practices for optimizing view state for page performance in this article … Continue reading

Chatter and Event Driven Architecture (EDA)

One of the things that stuck me while watching the Chatter presentation and demo  was the asynchronous and event driven nature of the collaboration taking place.  As an example, any number of activities happening at your customer account – identification of a new opportunity, a project being completed, etc. can be treated as event that can be handled by the right people or system which in turn could trigger additional events and so on. 

Let us look at a few of the attributes of this style of interaction.

  • The entity(either a person or a system) triggering the event just broadcasts/publishes the event without any knowledge of who may be interested in that -

Quiz – how can you have 100% test coverage in Sandbox and 0% in production?

Answer – if your test suite is not self contained i.e. it depends on specific data in Sandbox.

I got a call from one of our customers today about not being able to deploy into their production org due to inadequate test coverage even though they were getting 100% coverage in their development sandbox.  Our support tracked it down to hard coded test methods.  If your test methods depend on specific data in an org and you move such a test method to a different org, it will fail.

Here is an example where the record Id is hardcoded…..

Governors are not evil…..

Every programming environment has a set of constructs, features and constraints.  These may vary but in every programming environment, the programmer has to consciously manage resources.  These resources could be memory, socket connections, file descriptors etc. – I remember coding in C++ where bad memory (heap) management could bring the entire program crashing.  Java provided better built in support for this aspect but the programmer still had to work within the constraints of the actual heap space available and ofcourse manage the other resources like socket connections, threads etc. 

How does all this relate to Force.com? Your Force.com program runs with all the other programs in a… Continue reading

Batch Apex – a powerful new functionality in Summer ’09

Among the many new goodies in Summer ’09 release is a powerful new feature to do batch processing on your database records.  Tasks that require processing of large data volumes without any active human intervention can take advantage of this feature.  As an example, consider the task of validating addresses in your contacts when you can potentially have millions of contact records.  A batch job would be ideal for this scenario since you can start the batch job, continue to work or even log off while the job continues to execute.

To use this functionality, you need to implement the Database.Batchable… Continue reading

Testing – it is more than code coverage….

As a Force.com developer, you are probably already aware that before you can deploy your code into production, you should have atleast 75% test coverage.  Though necessary (since the platform enforces this requirement), it is hardly sufficient to ensure that your code meets the requirements and expectations of the users.  I will briefly describe the different types of testing you should consider before rolling out a Force.com application.

Unit Testing – Unit testing is used to verify that each individual piece of code (trigger, a method of a class, custom controller code etc.) is behaving as expected.  Force.com provides… Continue reading

Critical Update – Workflow Rule and Roll-Up Summary Field Evaluations Update

In Spring '09 Release, we introduced the Critical Update Console to inform Salesforce Admins of periodically released updates that improve the performance, logic, and usability of Salesforce. Starting Monday April 6th, we'll be rolling out the Workflow Rule and Roll-Up Summary Field Evaluations Update.

What is Workflow Rule and Roll-Up Summary Field Evaluations Update?The Spring '09 Workflow Rule and Roll-Up Summary Field Evaluations Update affects the way Salesforce evaluates workflow rules and roll-up summary fields on objects with Apex triggers. The update improves the accuracy of your data and prevents the reevaluation of workflow rules in the event of a… Continue reading

Email to Case

I came across the following thread asking for Documentation on how to Implement Email Services to post to a Case. This feature is powerful and the benefits are great. With Email to Apex, you can instantly convert any inbound email and automatically create a Case record in your Salesforce org.

There is a page on Force.com Email Services that illustrates an Email to Task example. In the thread, I took this example and updated it to work with the Case object. Plus, I added some logic that creates the Case, even if the inbound email address does not exist as… Continue reading

Calling Apex Code from a Custom Button using a Visualforce Page

I came across this little gem while browsing the blog sphere. Scott Hemmeter from Arrowpointe wrote a great article on how you can use a Visualforce page to call an Apex Class from a Custom Button. There are plenty of reasons why this would be useful.

One use case that comes to mind is developing a Force.com app for Group and Professional Edition. Since GE and PE do not support the API, you cannot use the AJAX Toolkit to execute your Apex Code from a Custom Button. With this approach, you can!

He even includes a working example to try it… Continue reading