The rise of JavaScript and it’s impact on software architecture

MVC and it’s siblings have been around for a while and developers are comfortable bathing in the warm light of their maturity and wide-spread advocation. However, a few years ago developers started doing more of their coding client-side and as a natural consequence the lines between M, V and C became blurred leaving many of us cold and uncomfortable when trying to explain where the architectural puzzle pieces belong.

I’m sure you’ve had a similar experience. Anyone who’s used jQuery, for example, has been in the uncomfortable situation where controller code now exists within view and even worse these two are tightly coupled by virtue of jQuery selectors. To make matters more complicated if you’ve ever used class-names for application state or .data() then you’re model, view and controller are now more tightly bound than the figures in a Kamasutra carving.

This is not a new problem but the solution(s) are quite new to me and so I thought I’d share my experiences.

jQuery is Great. But…

Read more

Salesforce: JavaScript Remoting and Managed Packages

I love the crap out of JavaScript Remoting, but came across a small bug when wrapping up the code in a managed package. As many of you know when you create a managed package it prepends your code with a unique name to prevent code conflicting e.g. a page controller called “MyController” becomes “MyPackage.MyController” where “MyPackage” is the prefix you’ve chosen for your managed package. The bug I’ve found is caused by the fact that the prefix isn’t applied to the JavaScript that calls your Apex Remoting methods i.e you might have an Apex method called “myMethod” which is called like so outside of a managed package environment: [code language=”javascript”] MyController.myMethod(parameters, function(result, event) { callback(result); }, {escape: false}); [/code] Once you package up your code however this call will no longer work, and if you look in the debugging console of your browser you’ll find an error something like: “MyController …

Read more

Salesforce: JavaScript Remoting – a different way of thinking

  JavaScript Remoting for Apex operates in a very different paradigm from what you might be used to i.e. Visualforce pages have controllers and the two interact through action methods – where this might be a full form submission or some neat AJAX functionality. Remoting also calls controller methods but there is a gaping maw in terms of how the two work under the hood. I’ve seen a few great articles on the syntax and example usage of JavaScript Remoting for Apex but when I started using it I came across a number domain differences that weren’t documented anywhere. Hopefully my list here will help you in the learning process. The best way to describe the new way of thinking is to examine the features set in contrast to “normal” Apex and Visualforce. How JavaScript Remoting Differs Pass parameters naturally i.e. the call matches the method signature syntactically instead of …

Read more

Salesforce: Dynamically determining the field type of a dynamically determined sObject

Call me crazy but I need to do this from time to time, and every time I do I can’t remember how I did it before! So I then trudge through the API and the Apex docs until I find the answer and that’s no mean feat in this specific case. Well, no more my friends because I’m putting it right here on this very blog! In short the code below will return (as a String) the type of field that we’re working with. Neither the name of the object or the name of the field need to be known in advance.

jQuery Org Chart – a plugin for visualising data in a tree-like structure

jQuery OrgChart is a plugin that allows you to render structures with nested elements in an easy-to-read tree structure. To build the tree all you need is to make a single line call to the plugin and supply the HTML element ID for a nested unordered list element that is representative of the data you’d like to display. Features include: Expected Markup & Example Usage All documentation can be found on GitHub. Demo You can view a demo of this here. Source code The source code with an example is available here.

Salesforce: Different percentage unit test code coverage in different environments

Many people are finding that their tests are reporting different degrees of test-coverage in different environments. There are a few things to check if you are getting inconsistent results but there’s a new bug in the wild. Before you assume you have the bug make sure that you’ve: ‘Run All Tests’ in each environment. This will tell you a few things viz. Perhaps there are tests failing that are bringing coverage in that environment down. There are some tests that only fail when run in the browser e.g. MIXED_DML_EXCEPTION will not rear it’s head through the IDE. Click the ‘Compile all classes’ link above the Setup > Develop > Apex Classes view. I’m not sure when this lil’ bugger first appeared but it’s darn useful. Essentially it makes sure that all the dependencies in your code are fulfilled e.g. if page A uses controller B that in turn refers to utility class …

Read more

Salesforce: Stop email being sent on user creation or password reset or …

I’ve had to do this a few times but infrequently enough for me to forget how to do it each time. Forgetting things isn’t usually an issue because of our Google Overlords and their mighty The Google but it’s quite a journey down the rabbit hole to find this specific information. The reasons it’s tricky to find is because the setting that controls whether an email is sent to the user on creation is not directly associated with users but with DML. Long story short you need to set a particular Database.DMLOption e.g. [code language=”java”] User u = new User(); // Add some details here … // Set the DML options Database.DMLOptions dlo = new Database.DMLOptions(); dlo.EmailHeader.triggerUserEmail = false; Database.insert(u,dlo); [/code] Hopefully this information will now be easier to find next time I forget 🙂

A gem to help you document your Rails ActiveRecord model

I’ve been using the “annotate” gem for a while and it’s simple whilst incredibly useful. Essentially once run it documents each resource in your database within the appropriate file. Here’s how to get it working. Step 1 Install the gem. There are a few ways to do this but I usually include the following line in my Gemfile: [code language=”ruby”] gem ‘annotate’ [/code] Then run “bundle install” from the command line. Step 2 Generate the schema annotations by running: [code language=”bash”] annotate [/code] in the root of your rails project directory and it will inject the schema details for each “table” into the respective “model.rb” file e.g. “user.rb” might contain: [code language=”ruby”] # == Schema Information # # Table name: users # # id :integer not null, primary key # screen_name :string(255) # name :string(255) # created_at :datetime # updated_at :datetime # [/code]

Knowledge Tree for Salesforce User Roles

Many moons ago @ratherGeeky was searching for an AppExchange app that would neatly display user roles so that she could be the best admin she could be. I had a poke around and there were a few nice apps out there but nothing with a simple, neat display of user roles. Since then CloudSpokes was created, and a competition to that effect was released using the concept and tools that I was going to use (@jeffdonthemic smells like turnips btw). The outcome of the competition was a few very cool apps, but nothing that was package-ready so I pressed ahead anyway. I’m happy to announce that you can now get Knowledge Tree for Roles on the AppExchange for free. It’s definitely a point solution, very specific in the problem it’s trying to solve but I think it does that well. I have a roadmap for the product and will [ever …

Read more

Across the Pond with Shannon Hale

Shannon is Senior Product Manager for Declarative Apps at Salesforce.com

@abhinavguptas and I were curious as to the identity of the creator of the SetupScripter, which is now incorporated into the salesforce.com Org setup menu. I dug around a bit and managed to uncover her real identity – community please meet Shannon Hale, Shannon Hale this is the community. She didn’t just stop with that wonderful piece of UX but has moved onto bigger and better things, but I’ll let her tell you about those.

If you’d like to learn more about the genius that is Shannon or just have a chat with her you can get her on twitter at @shannonsans or @bathtubdreamer. You can also check out her online presence at shannonsansserif.com and bathtubdreamer.com.

Onto the Q&A!

Who is Shannon Hale? How did you get into software development and UX design?

I started out as a writer, but in a different field — I wrote and edited for some independent Canadian music and culture magazines. I started technical writing to help pay the bills, and from there wandered through a series of tech positions: technical training, systems analysis and design, and software development. In 2001 I became obsessed with why a product I was coding was difficult to use, and began to independently study interaction design and user experience.

When I’m not being a complete geek — which I am even at home, I always have personal and volunteer web projects going on — I’m sewing, knitting, or binding books. I’m one of those people who always needs to be doing something with their hands.