Technistas

Matthew D. Laudato writes about software and technology

Practical Salesforce Programming

with 3 comments

As most of my readers know, I like to write about work-related items – a webinar I’m hosting, a review of an article that is relevant to my day-to-day work in the software business, or some such thing. But every now and then I need to remind myself of what got me into this business in the first place – a sheer love of figuring out how to program something.

Last week, the something was Salesforce.com, the leading customer relations management software product on the web. We use Salesforce at the company I work for (OpenMake Software, Inc.) to help track how we communicate with customers and prospects. One of the cool things that Salesforce lets you do is to send out an email to a large list – no, not spam, but legitimate communications to people who have agreed to hear from you. As anyone who has tried to send out a mass mailing knows, all email lists are dirty – meaning, there are addresses on the list that are no longer valid and that result in a bounced email. So my task was to figure out a way to programatically set the email ‘opt out’ bit on the associated record in Salesforce.

Salesforce has an excellent web services API that gives you complete access to the underlying data model. I decided to tackle the problem using my favorite Swiss-army bazooka, Perl, along with a Perl module that I found on the internet called ‘Salesforce’. Once I installed the Salesforce module, the code was pretty easy to write.

The program assumes that you have a text file that contains a list of the email addresses that have bounced, separated by a newline character. Here’s the code:

use Salesforce;
use Getopt::Long;

# Gather command line parms
my ($user, $password, $bounceFileName, $update);
my $result = GetOptions ("user=s" => \$user,
			"password=s" => \$password,
			"bounceFileName=s" => \$bounceFileName,
			"update" => \$update);

# Set up the SOAP service and login
my $service = new Salesforce::SforceService();
my $sf = $service->get_port_binding('Soap');
my $login_ok = $sf->login('username' => $user, 'password' => $password);
die "Bad login" unless $login_ok;
print "Login OK";

# Loop through the bounce file and process each bounced email address
open (BOUNCE, $bounceFileName) || die "Can't open file: $bounceFileName";
while (<BOUNCE>) {

	# Get the lead from SF
	chomp($_);
	my $leadEmail = $_;
	print "\nProcessing lead email: $leadEmail ";
	my $result = $sf->query('query' => "select id, hasoptedoutofemail from
                                             lead where email='$leadEmail'",
                                             'limit' => '1');
	my $leadID = $result->result->{'records'}->{'Id'}[0];
	my $hasOptedOut = $result->result->{'records'}->{'HasOptedOutOfEmail'};
	print "Lead id is: $leadID. Opt out status is: $hasOptedOut\n";

	if ($update) {
		my $lead = $result->result->{'records'};
		$lead->{'Id'} = "$leadID";
		$lead->{'HasOptedOutOfEmail'} = 'true';

		my $updateresult = $sf->update(%$lead);
		my $updreshash = $updateresult->result;
		print "Update status: $updreshash->{success}\n";
	}
}
close (BOUNCE);

1;

 

As you can see, the code is pretty simple. In the initial block, we use the standard getopt functionality to get the name of the bounce file, along with the Salesforce userid and password. One comment about the password, you need to append your Salesforce security token to your standard Salesforce password – this is a standard technique in Salesforce and in many other cloud computing environments. We also set an ‘update’ flag – if it is set, we will not only query the database for the existence of a bounced email record, but we will also attempt to update the opt out bit.

The next block sets up the Salesforce SOAP service and binds to it. Once this is done, you are ready to make queries and update the Salesforce database. Salesforce uses the SOQL query language to interact with its database. In the code, we first open up and then iterate over the bounce file. Each time through the loop, we perform a query to pull the record associated with the bounced email address from the Salesforce database. If the update flag is set, we then prepare the record (as a Perl hash) for update and use the ‘update’ method to push the change to Salesforce.

I found working with the Salesforce API to be fairly straightforward. The only hard part was figuring out the exact format of the records that come back from Salesforce – in some earlier versions of the code, I just used Data::Dumper to peek inside the SOAP envelopes to determine the structure. All in all, it was a few hours of learning the API and the data formats, with the end result being a functional and useful piece of code.

Hope this helps, and happy coding!

– Matt

Written by Matthew D. Laudato

December 9, 2009 at 3:43 pm

Speedy Java builds slow down productivity

with 2 comments

I never cease to be amazed at how software development management ignores the build problem. In a recent article in SDTimes, Alex Handy reports on a survey undertaken by RedMonk that found Java developers spend nearly 8 minutes per hour doing software builds. In round numbers, that’s an hour a day, 5 hours a week, and for a typical 48 week year, nearly 30 work days every year. Let me repeat that. Your Java developers, who are presumably paid $80-120k per year, are spending 30 days per year staring at their screens waiting for builds. If we take the middle of this range, this is a productivity loss of over $12,000 per year per developer. For a small 5-10 person team, you could hire an extra developer just with the savings from improving your build process.

The article goes on to say that Java developers “have learned to build smaller portions of their projects at a time, or to compile small pieces of code and inject them into running applications”. I’m trying to think of two worse practices in professional software development. If you build a smaller portion of your project, you risk having unsatisfied dependencies, and thus wasting time when your runtime fails to operate properly. Similarly, injecting code into a running application is dangerous even in a test environment for similar reasons – you haven’t spent any time understanding the dependencies, and therefore are at risk of dependency-related failures.

As my readers know, I work for a software company (OpenMake Software) that sells a software build and workflow automation product. We have tens of thousands of Java developers using our product through our Eclipse plugin, which gives you true incremental builds that take dependencies into account. You can build, test and do a test deploy all from within Eclipse, and not have to resort to trickery such as injecting partial code into your test server. Since the cost of Meister (which I am not at liberty to publish here) is significantly less per developer than the annual productivity loss calculated above, it makes sense for development managers to move their Java developers away from the wild west of desktop builds, and consider a formal build system. Anything less and you’re ignoring one of your primary missions as a manager: controlling the development process.

Happy Building!

– Matt

Written by Matthew D. Laudato

December 3, 2009 at 8:27 pm

Integrating OpenMake Meister with Archiva

with one comment

Archiva (http://archiva.apache.org) is an open source repository manager that lets users access binary and other objects for use during software builds and deploys. Its functionality is similar in many ways to traditional version control systems, and OpenMake Meister (http://www.openmakesoftware.com) integrates with it as such. There are three ways to integrate with Archiva using Meister.

1.       Via the file system. Archiva stores objects transparently in a structured way on the file system. To include the contents of an Archiva repository, create an entry in a Meister Dependency Directory with an appropriate name, that contains a path to the repository location. For example, the default archiva installation includes JUnit 3.8.1. Creating a Dependency directory with the name ‘JUNIT381’ and the value ‘C:\tools\archiva-1.2.2\data\repositories\internal\junit\junit\3.8.1’ will enable Meister to include any libraries found in this directory as part of Meister builds. I don’t really recommend this method, since someday the transparency of the files may change in Archiva. But it works in a quick and dirty way.

2.       Through a webdav client. The native interface to Archiva is WebDAV (see http://www.ietf.org/rfc/rfc2518.txt for the WebDAV RFC). A Meister activity can be easily created to execute a command line GET operation against the Archiva repository. For example, if you use the BitKinex file transfer client, you can retrieve junit-3.8.1.jar by using a Meister activity that runs the following command:

URL=http://localhost:8080/archiva/repository/internal/junit/junit/3.8.1/junit-3.8.1.jar
bitkinex.exe cp /noinfo /force $(URL) c:\temp

This retrieves the file and copies it to c:\temp, where it can be used as part of a build. This is probably the best solution. When building, you really want a local copy of the files, at the very least for audit purposes, and there are plenty of WebDAV clients out there.

3.       Mapping a web drive. Most operating systems support mapping a network drive to a web location. For example, on Windows, you can add access to the JUnit 3.8.1 repository by mapping a drive in DOS as:

net use Z: “http://localhost/archiva/repository/internal/junit/junit/3.8.1”

Once this is complete, you can access the files in the repository simply by referencing drive Z: in a Meister Dependency Directory. One restriction, on Windows XP your repository must be running on port 80, as Windows does not support web drives on any other port. This is also a pretty good method, but it eats up drive letters fairly quickly if you have many libraries that you want to uniquely map.

I’ve tried all three methods in my build lab, and while I don’t think I would use Archiva in a production environment (my bias is towards actual SCM systems or a managed file system for storing 3rd party build dependencies), it definitely ‘worked’ and was fairly easy to integrate with.

Happy Building!

– Matt

Written by Matthew D. Laudato

November 12, 2009 at 3:12 am

A Tale of Four Builds

with 2 comments

After a long break from blogging, I’m back. I’d like to invite all my viewers to a webinar that I’m hosting on Wednesday October 21, 2pm EST. The webinar is titled ‘A Tale of Four Builds’. In it I take a single piece of code and build it using four different build technologies. This survey of build methodologies moves from manual, error-prone processes to highly controlled and repeatable processes. If you’re a software engineer, development manager or build and tools manager, this webinar will help you sort out the pros and cons of the various build technologies that are common in today’s software environment.

Hope to see you there. To register, go to: https://www1.gotomeeting.com/register/554771256

Written by Matthew D. Laudato

October 16, 2009 at 1:09 pm

SBWA – Scrum By Walking Around

with one comment

If you’ve been in the software business long enough, you’ve probably seen just about every methodology. Waterfall, RAD, OOP and Agile, just to name a few, have all been at the forefront of methodology circles, each briefly having its place as ‘the’ methodology, the One Right Way of doing software development. As different as these methods may be, they all have one thing in common: without execution by talented engineers, none are worth the paper they are printed on. Which brings me to the topic of this post. If you’ve settled on one of the agile methodologies and are using scrum to manage your engineering projects, you may encounter more than just a little resistance from engineers when switching to daily stand-ups and burndown charts. Beyond training, there’s one often overlooked practice that can help socialize the idea and practice of scrum inside your team – talking to people.

The daily walkaround that most managers engage in isn’t designed to randomly annoy engineers. Rather, it is one of the most proven methods of management – management by walking around, or MBWA. This simple practice ensures that you and your team members talk face to face, semi-privately at least once a day, partly to get caught up on activities, and partly to socialize new ideas. If the new idea is scrum, you might want to try a variation on MBWA that I call SBWA – Scrum By Walking Around.

The idea is simple. You’ve trained the team, but the daily scrums aren’t going well. People are missing their commitments, and the burndown chart seems to be flaming up like tech stocks in the good old days. Engineers are frustrated, and their frustration is partly directed at you for advocating YAM – Yet Another Methodology. If this is your situation, you need to do a better job of socializing scrum among your team members. There’s no better time to do this than during your daily walkaround.

Try this: plan your walkaround to take place in the hour before the daily scrum. As you visit each engineer, ask them how they feel the new methodology is going, and take lots of mental notes. Then spend a minute reinforcing the key goals of scrum: accountability to commitments, visible progress measures, and short term rigidity combined with long term flexibility. Later, after the scrum is over but before everyone leaves the room, share the concerns that you’ve gathered privately from your walkaround, and get everyone to agree on a plan of action to address the issues. Chances are that there are a few common concerns that everyone has. By getting these out in the open, it signals to the team that you’re responsive to them, and not just another pointy-haired paper-pushing process wonk.

Written by Matthew D. Laudato

December 19, 2008 at 12:43 pm

People, Process and Product

leave a comment »

Yesterday I had lunch with an old friend and colleague who like me, is between jobs. After talking about the kids and the family, the conversation turned to shop talk, which for my friend and I is the software business. Both of us are experienced managers, in my case having led teams anywhere from 4 to 45 persons, and for my friend, organizations upwards of 200 developers. What emerged from the conversation was our common view that the single most important thing that a manager can do to ensure a successful software product is to hire and train the right people.

Now, this may seem obvious, but there are managers out there who for whatever reason believe that the development process is the most important factor in team and product success. That you can take mediocre talent, insert it into a formal process, and have superior code emerge from the other end. At the risk of starting a flame war between the process-centric and people-centric folks out there, let’s examine the single equation that rules the software industry: People + Process = Product.

If you walk into a development shop and ask about process, chances are you will get a different answer from everyone you speak with. Managers will often fire off a list of “things that we do” and pass it off as process. Engineers on the other hand, tend to chuckle, smirk and give you a more direct answer, usually something like “I look at my list of defects and features and then write code to resolve them”. If asked about the details of the process, you will get as many different answers as there are team members. This is my first point: your process more likely than not, isn’t what you think it is.

Now, go and ask the same development team about people, and I suspect you will hear a different story: Joe is the best algorithm guy I’ve ever worked with. Jane can step up to unfamiliar code, grok it instantly, and fix nasty bugs quickly. Bob writes useful unit tests. This is my second point: the team knows intuitively who does what best, and if pressed, why those roles are critical to the success of the team.

When asked to come in and fix a troubled team, my friend doesn’t inquire directly about the process when interviewing the team. Rather he asks: what’s working around here? Usually there are 3 or 4 things that the team does well, that can and should be used as the basis of a new process. The interviews also tend to give him a sense of who the top talent is, and who the laggards are. This sets the stage for shifting people into the most effective roles, and adjusting the process – in that order. Similarly, when I have been asked to build a team from scratch, process is the last thing I think of. The first thing is hiring and training top talent. Once there is a critical mass of developers (usually at least 4), a funny thing happens. The developers, if they are truly top-notch, will start to self-organize and suggest a process. At this stage, I step in and help the team put some formalism around the process so that we can measure our progress, and the race is on.

To sum it up:
1. Your process is what your engineers actually do, not what you’ve written up on paper.
2. Great engineers deliver great products.
3. Process is a guideline to keep the greatness wheels turning.
4. If a team is underperforming, focus on your people first, then fix the process.

If you’re managing a large organization or a complex set of deliverables, there’s no question that your development process is important – it needs to be scalable, easy to measure, and non-obtrusive. But, as anyone who has watched the 0-14 Detroit Lions lately knows, without talent in all key positions, no amount of process can produce magic and turn a sow’s ear into a software silk purse.

Written by Matthew D. Laudato

December 17, 2008 at 2:15 pm

The Truth About Agile

with one comment

When you work for a company, it’s important to align your goals with the company goals. In software engineering firms, that often means setting a goal to be adept at your coding job while following the company practices and development processes. If one of those processes happens to be agile development, strange things can happen when engineers try to ‘get with the program’ (coding pun intended!) Engineering managers at software companies, read on to  learn how to help your team adjust to agile.

I think there’s a good reason why engineers can sometimes have a hard time adjusting to and adopting agile. The truth about agile as applied at software development companies is that it is not a software development process. It is a product management process, fundamentally designed to feed prioritized, must-do requirements to engineering teams. Once an engineering team has these requirements in front of them, individual engineers may find it hard to distinguish life before from life with agile. Someone, a manager or scrum master, asks the engineer to commit to doing some work. If the team is using scrum and doing short 2-week sprints, then engineer gets to give the most tried and true answer in software development: yup, it’ll take about 2 weeks. And then they put their heads down and start coding. Every morning they stand up at the daily scrum and say ‘yup, it’ll take till the end of those two weeks I told you about yesterday and the day before…’. From an engineer’s point of view, this interaction can be indistinguishable from their behavior under older methodologies like waterfall, and therein lies the rub.

For engineers to really commit to agile, they need to be told another truth. The hard truth in the software business is that it is market driven – and thus the real goals of a company from a product perspective are and should be defined and socialized internally by the marketing department. What agile really does for a company is to force marketing – product management, specifically – to constantly engage with engineering at a fine-grained level. Reviewing requirements, crafting stories, building a global, prioritized backlog. In other words, doing real work to ensure that requirements are understood and that new information on customer needs and market direction is properly reflected in the backlog priorities.

To successfully socialize agile within engineering, there are three things a manager must communicate to their team:

1. Priorities change

2. Team and individual commitments do not

3. Our process moves as fast as the market

The good thing about agile is that it is self-reinforcing with respect to these three points. By doing short sprints, changing priorities become an evident norm. Unlike waterfall, where an incoming course change forces developers to drop what they’re doing and work on something new, agile maintains current commitments until the end of the sprint, reinforcing point number two. When a course change comes in in agile, the next planned sprint can immediately reflect this, highlighting point number three.

Agile isn’t hard or easy. But it is different. By communicating clearly to your team about how priorities are reached, holding them and yourself to commitments, and adeptly shifting gears as your customer and market priorities change, you will improve your success with agile and win over even the most process-skeptical engineers on your team.

Agile Governance: Oil and Water?

leave a comment »

Agile governance is about as controversial a topic as there is these days in software methodology circles. Here’s a post that I did for AccuRev (my last before exiting the company) that summarizes my take on best practices in this area. Enjoy!

Agile Governance: Oil and Water?

Written by Matthew D. Laudato

December 14, 2008 at 4:05 pm

Developing in streams, releasing from streams

leave a comment »

Here’s a link to yet another post I did for AccuRev. It’s a critique of some so-called best practices around branching. Eventually every developer will realize that branches are old and dead, so here’s my small contribution to that end.

Developing in streams, releasing from streams

Written by Matthew D. Laudato

December 14, 2008 at 4:02 pm

Whither branches?

leave a comment »

Here’s a link to a post I wrote on blog.accurev.com that addresses some of the problems that development teams have with branches, and why I think AccuRev streams are a superior method of managing code configurations.

Written by Matthew D. Laudato

December 14, 2008 at 3:59 pm

Posted in software development

Tagged with , , ,