XPath Tool – Visual XPath

A while ago, one of my customers asked whether there was a visual tool where he could click into an XML document and see the XPath expression generated from navigating to that node, as well as being able to type in the node and have it point to the correct place in the document.

The best free tool I found to fulfill this requirement is Visual XPath:

http://cid-4bb423973bbcdc56.skydrive.live.com/self.aspx/Public/visualxpath.zip

This will be useful to you if you are new to XML and/or XPath. There are some pieces of syntax it doesn’t seem to like, but it supports the basics (and helped my customer who was learning XML and XPath to avoid case-sensitivity issues and typos).

Are there other free tools out there that are as good as this?

The shortest amount of time that could possibly work – shrinking your iterations

It’ll never work

It’s hard to believe this with my looks, but back in Liverpool I sang and played guitar in a band. One day, in rehearsal we were working on a new song, and I asked the guitarist to play an unusual arrangement.[1] His response was, “it’ll never work – the chords are going to clash together.”

Now bear in mind, at this point we are in a rehearsal room, with guitars strapped around our necks and plugged into amplifiers. It would have taken thirty seconds to try this out and see (or in this case, hear) whether or not it worked, but instead a long argument about music theory ensued. Eventually we played it, and it worked.[2]

In retrospect, to get the guitarist to try out the idea, what I should have done (instead of arguing about music theory), was to say, “you know, you might be right, but let’s try it – if it doesn’t work, we’ll know pretty quickly and we’ll try something else.”

A resistance to short iterations

One of the things I almost always find when working with customers is a reluctance to shorten their development cycles. Although they begin to adopt a lot of good development practices and are enthusiastic about the benefits of an agile approach, they’ve been conditioned over the years to think that there’s nothing achievable in a week or less, and they want to start out with iterations a month long or more.

This resistance to change was recently summed up by Mike “GeePaw” Hill as a case of the “Yabbits.”

Yabbitting is when people go through a sequence of resistance statements, where each statement begins with the words, “Yeah, but…”.

While Yabbits can be annoying, Mike goes on to state their value:

Yabbits don’t always, or even usually, represent real resistance to change. On the contrary, they are probes, whose intent is to test an idea’s prima facie validity.

A person who offers you yabbits is typically more open to an idea than a person who says nothing at all.

So when faced with this resistance, remember that these objections are often coming because people care and because they have real concerns. I should have been happy that the guitarist cared enough about how the song would sound, rather than just going along with my idea.

Often it is easy to show someone who is resistant to change a way forward by asking them to try something for a little while and show them that there is little risk in trying it out. This approach avoids getting embroiled in an argument about about some esoteric theory of agile software development (or music theory!) For some practices, the change may be perceived as risky, but for others, like shortening an iteration, or playing a new arrangement of a song, the risk is minimal.

The shortest amount of time that could possibly work

The problem with having long cycles (particularly when transitioning from a traditional approach to an agile one) is that the cycles tend to behave like mini waterfalls: most of the work gets done at the end of the cycle, the testers have most of the features dropped into their laps in the last few days of the cycle, and a lot of the real tools and practices needed for a sustainable pace (for example continuous integration, build automation, automated regression test suites and improved communication) often don’t happen early enough in the project for the team to get real benefit from them and ease their transition.

The benefits of a short iteration far outweigh the risks. The only real risk is that you won’t get much done in the iteration, and the overhead of settingClock up the iteration will be high. However, shortening the cycle means that you will not waste time in high ceremony activities, and any pain points or roadblocks will become evident very quickly. In addition, the risk of not achieving much soon disappears as you become much better at slicing requirements down into small but valuable features. You will also improve several techniques that will help you work at a sustainable pace.

To summarize, you will see the following benefits:

  • Risks and inefficiencies are exposed earlier.
  • High overhead activities like long meetings that don’t get you closer to your goal of releasing a valuable feature are removed or reduced.
  • The team will work together, swarming on a single feature until it is complete, rather than continuing to work across many features in the traditional manner.
  • Improved communication between the team and the business owners is necessary to keep the work flowing.
  • Automation becomes a necessity, rather than a nice to have.
  • Less temptation and opportunity to revert to old practices and do mini waterfall.

So given all of these benefits,  how short should an iteration be?

Ward Cunningham famously rephrased Occam’s razor when applied to software development as:

…ask yourself, “What’s the simplest thing that could possibly work?”

Let’s redefine an iteration in this way:

Ask yourself, “What’s the shortest amount of time that could possibly work?”

In other words, find the shortest time-frame in which you can get something of value to the business done.

How short is that? Almost certainly shorter than you think.

How do you get there? Luckily, several people smarter than me have some ideas.

The disappearing iteration meme

There has been a recent meme about shortening iterations, with several people blogging on the topic from different approaches.

Michael Feathers recently wrote about Zeno length iterations, where he proposes an experiment:

Suppose that you had an iteration of one week, followed by an iteration of 2 days, followed by an iteration of 1 day, followed by an iteration of one-half a day, and so on…

…you can deliver business value in shorter times than you can currently imagine.

From Michael’s perspective, one of the main benefits of short time boxes is that they force trade-offs and produce creative solutions. He concludes by saying:

Look at your product today.  If you only had one day to develop and deploy some feature, before putting the product on ice and letting it generate revenue as is forever, what would it be?

While I think Michael’s experiment is a little abstract, the point he is making is that you can deliver value with very small chunks of code – smaller than you think today.

Kent Beck recently proposed a different experiment in extremely short iterations, for a different reason, continuous deployment immersion:

Get the whole team in a conference room Monday morning. Choose a feature you are going to add. Have one person come up to the one machine in the room. Write one line of code. Deploy.

If you can’t deploy, erase that line of code and write a different line of code first. Deploy.

Once the deployment is done, write another line of code. Deploy.

About this time some of the rest of the team is going to be bored watching all the manual steps in the deployment. Have them go off and automate the most tedious, boring, or error-prone step. Bring the automation back to the conference room and start using it.

Kent suggests that by doing this, you will start to automate your deployment, automate your tests and understand a lot more about slicing up your features into smaller chunks.

By Friday afternoon you may not have made much progress on your feature (but you may be pleasantly surprised), but you will understand deployment much better than you do now. You will also understand how to slice development more finely and rearrange the pieces. You will also understand the value of automation.

He also (with tongue in cheek) concludes that it’s a crazy idea, but in reality, there is also a lot of value here. Forcing everyone to think about where their pain points are and making the pain points happen often (due to shortening the cycle) means that the team will be motivated to remove and automate those pain points and ultimately work more efficiently.

James Shore and Arlo Belshee also recently gave a very entertaining talk at the Lean Software and Systems 2010 conference, entitled “Single-Piece Flow in Kanban: A How-To.”

Single Piece Flow In Kanban

In it they propose stripping down a lot of the complexity of Lean and only having two queues, On Deck, and In Progress.

Ideally, only one item (Minimum Marketable Feature, or MMF to use Lean terminology) would be in progress at any time. Instead of moving the MMF through the traditional production line of Kanban (for example, through requirements definition, story queue, development, testing and deployment), you instead create a detective’s blackboard by putting all of the information about the MMF onto the board. The name comes from detective TV shows, where all of the information about a crime is displayed on a blackboard. This information might translate to tasks or information about the feature.

The whole team swarms on this single feature until it’s completed and then it is removed from the board and the next item added from the On Deck queue. What is fascinating about this talk is that while Jim and Arlo disagree about some details and definitions (including their definitions of an MMF), they both agree that this is a more efficient way to build software.

Try it!

While there are several approaches to shortening the iteration, or taking a Lean approach and not having iterations at all[3],  the best approach for you is the one that you try. Whether you take Michael Feathers’ approach of shortening the iteration length to find a workable minimum, Kent Beck’s approach of starting with a single line of code at a time, James Shore and Arlo Belshee’s Lean approach of swarming on a single feature, or some other means doesn’t really matter. What does matter is not being scared to shorten the cycle until things are a little uncomfortable and real work needs to be done to make efficiencies such as automation or continuous integration, or coming up with creative ways to solve problems and chunk up work.

Don’t get bogged down in figuring which way will be the best to shorten your iterations – that is like arguing about music theory when you have guitars in your hands. Instead, just pick an approach and try it.

You’ll soon arrive at the shortest iteration that works for your team, and it’s almost certainly shorter than you think.

And before you become a Yabbit and say “it’ll never work” ask yourself this: “what’s the risk?”

  1. For the music geeks amongst you, one guitarist would play the three chord trick in the chorus, and the other guitarist would play the relative minor chords at the same time []
  2. We recorded the song some time later and I think that those chords played together still sound rather nice []
  3. For more information on Lean and Kanban development, read Jeff Patton’s excellent post, Kanban development oversimplified []

Half-way through the Internship…

There was a grin on my face when, half-way through the internship, I tried to recollect things I have learned and the value I created for the company. I became a part of ext.IT from June 16, 2010. First few days were easy as I was getting acclimatized with the company culture and environment. A business developer/consulting intern profile was a perfect match with my interests. Also, the timing was perfect to boot. The company size grew significantly within the last three months, accompanied by a new office space with added resources. This led to new opportunities and challenges for me to apply my business acumen.

Some of the lessons I learned through my internship:

1.     Speak up early and often

2.     Be flexible and learn to adjust yourself

3.     Learn to disagree but commit

4.     Invite different ideas and views

5.     Learn to handle criticism with subtlety

6.     Vouch for your assertion

7.     Be yourself

As important as these explicit lessons are, equally important are the skills of presence of mind, mindful self-awareness, networking and sensitive reading of people and situations.

Internship is paving the way for me to utilize my technical skills and at the same time learn to think from a business perspective. It is teaching me how – in the professional world – all decisions are made depending on the business requirements and resource availability. My first task to research about different cloud computing services (Amazon’s EC2, Microsoft’s Azure and Salesforce and VMware’s VMforce) was a pure bliss. Knowing what different services are available in the market helped me understand its capabilities, differences and its practical applications. This followed by several tasks with increasing work load. Setting and customizing company’s Salesforce account to manage contacts, accounts, expenses and opportunities was a great experience indeed. Along with this, I also got a chance to improve my writing skills and share my knowledge and experience by blogging about it on the company website.

They say, having a good manager is more important than having a good job. I am fortunate enough to have an observant and experienced manager to guide and direct me. I learned much more from him than from anything else. The best thing he is doing to me is reviewing my work early and often which helps me sharpen my skills further.

Through this internship, I am gaining experience in applying my knowledge in the industry, preparing myself for the time when I will join the workforce, in terms of confidence and competence. The most valuable thing I am earning from it is to get to know my strengths and weaknesses and work on improving them. I am sure with days passing by, my learning curve will increase along with the satisfaction of the quality of work.

EC2 vs VMforce

“Cloud computing” has replaced “Web 2.0″ and “social networking” as the latest buzz phrase. Today, every other company or organization is gearing itself to move onto the cloud. Getting onto the cloud is itself a big deal but what is more challenging is to decide on which cloud one should go to. Today, the three most impactful companies providing cloud services are Amazon (EC2), Salesforce and Microsoft (Azure). Other than this, VMforce, the first enterprise cloud computing service for java developers, is grabbing significant attention in the market.

Amazon’s EC2 is an Infrastructure-as-a-Service (IaaS) solution where customers can consume a generic server resource in the cloud. It still requires customers to install and manage an application stack including the application server, database, and other middleware elements. On the other hand, VMforce is a full Platform-as-a-service (PaaS) solution where the customer doesn’t need to worry about installing and managing the middleware and application stack. All that ‘plumbing’ is done as a service. EC2 pricing is per instance-hour consumed for each instance type and varies based on several different factors. Pricing for VMforce will be announced closer to its release date.

EC2 (Amazon):

Amazon’s EC2 is a cloud computing service that allows users to deploy and run their applications on rented virtual computers. Users can boot what are called Amazon Machine Images and create an instance, also known as a virtual machine, and pay for the amount of computing power they need by the hour. EC2 is particularly well suited for applications that experience hourly, daily, or weekly variability in usage. Below are some of its main features:

VMforce (SalesForce and VMWare):

VMforce is the shared vision of Salesforce.com and VMware. With VMforce, the customer focuses on the application logic and leaves the rest to VMware and Salesforce.com.  VMforce is aimed at SaaS and Web services developers. The major components of VMforce are VMware’s Spring platform — and its community of Java developers — and Salesforce.com’s Force.com platform.

Below is the table with brief comparison between the two:

Amazon Ec2

VMforce

IaaS

PaaS

Virtual services in the cloud

Complete platform as a service

Generic Server Images

Complete development service

Self-assembly & management of stack

Automatic stack management

Self-managed database

Database as a service

Self-managed scalability

Automatic scalability

AWS Services

Chatter services

You can download this file here for detailed features of EC2 and VMforce.

Is your consulting code an asset or a liability?

Overview

When you hire consultants to build software for you, how do you know if the code is worth the money you pay them?

Consulting code (indeed, any custom code) should be an asset to your business, but unfortunately, many times it’s quite the opposite.

Consulting code can become a liability. Lack of tests and poor quality, buggy code can leave you, your code and your pocket book in worse shape than before the consultants arrived (and usually with little to no recourse).

Untested code has no business value

Years ago at the Agile 2006 conference, one of the sessions was “Delivering flawless tested software every iteration”, delivered by Alex Pukinskis. The catchy name attracted a big audience and it was standing room only.

During this presentation, Alex made the following statement:[1]

Untested code has no business value

This struck a chord with me, because at the time I was working for a company that was trying to transition to agile, but many of our practices still hadn’t changed. We were (okay I was) still breaking the build and still expecting the QA team to find our bugs for us. We weren’t consistently doing TDD, we had no automation of the build acceptance and we were not practicing continuous integration. I could go on, but I’m sure you get the idea.

The “aha” moment for me was the concept that the quality of the code, and a lack of defects was my responsibility as a professional developer. It was my responsibility to ensure that no defects were passed to QA. Of course, I know that software cannot be perfect, and there will be defects, but my attitude towards defects changed after that talk. Defects should be unexpected. Defects should be unusual. Defects should be prevented, not found.

No Bugs

The attitude that defects should be prevented, not found, can be summarized in the “No Bugs” philosophy.

James Shore recently published the full text of the No Bugs section from his excellent Art of Agile book. He summarizes the text in 99 words:

Rather than fixing bugs, agile methods strive to prevent them.

Test-driven development structures work into easily-verifiable steps. Pair programming provides instant peer review, enhances brainpower, and maintains self-discipline. Energized work reduces silly mistakes. Coding standards and a “done done” checklist catch common errors.

On-site customers clarify requirements and discover misunderstandings. Customer tests communicate complicated domain rules. Iteration demos allow stakeholders to correct the team’s course.

Simple design, refactoring, slack, collective code ownership, and fixing bugs early eliminates bug breeding grounds. Exploratory testing discovers teams’ blind spots, and root-cause analysis allows teams to eliminate them.

Asking the right questions

Now you are probably expecting some sales pitch from me at this point to say that you should hire us because we’re great. Well that’s not the point of this post (although you should, and we are). The point of this post is that the next time you are talking to a consulting firm or hiring a developer[2], ask them about their definition of code quality and how they ensure it. By simply asking a couple of questions you should be able to determine whether they are all “smoke and mirrors” or if they will add value to your business. For example, you might ask:

  1. What is your definition of quality code?
  2. How do you ensure your code is bug free?

The answer to the first question should mention practices like the Law of Demeter, coding standards, refactoring and adherence to the SOLID principles.

Although unsettling, it is okay if the answer to the second question is “I‘m never 100% sure my code is bug free” (particularly if they mention Gödel’s proofs). However, they should quickly follow up with, “I make bugs less likely by practicing test driven development, peer reviews (or pair programming), automated acceptance tests and adherence to coding standards and good design principles.”

If they can answer those two questions to your satisfaction (and follow through by demonstrating these practices when building the code) then they might know what they are talking about, and actually give you value for your money.

  1. I’m not sure whether Alex was quoting someone, but googling that precise phrase returned zero results, so I’m attributing it to him []
  2. For more information on hiring developer team members, read http://jamesshore.com/Blog/Alternatives-to-Certifications.html []

Helper Application – DiffMerge – File Comparison and Merge tool

Interesting Find

As Software Consultants we are always on the prowl for tools and applications that can speed up the development and delivery process. One of our fearless leaders, Peter Drum, recently shared a tool with us and I thought I would pass this along. The tool is called DiffMerge and is distributed by SourceGear. From the SourceGear site, here are some features for DiffMerge:

DiffMerge is an application to visually compare and merge files for Windows, Mac OS X and Linux.

Product Features

  • Diff. Graphically shows the changes between two files. Includes intra-line highlighting and full support for editing.
  • Merge. Graphically shows the changes between 3 files. Allows automatic merging (when safe to do so) and full control over editing the resulting file.
  • Folder Diff. Performs a side-by-side comparison of 2 folders, showing which files are only present in one file or the other, as well as file pairs which are identical or different.
  • Configurable. Rulesets and options provide for customized appearance and behavior.
  • International. Compatible with 42 different character encodings.
  • FREE. Full featured. Not a demo!

Why another tool (you may ask)? One of the tools that I had used until most recently was WinMerge. Some key points from the Keith Craig on the SourceGear blog regarding differences between WinMerge and DiffMerge below (the main point being that based on what you main intent is (comparing or merging) the tool you use may be different).

Things I really like about DiffMerge include:

  • You can select text from any of the panes and patch it together in the merge result window as necessary
  • It displays differences within a line, which can be a huge time-saver!
  • It does true three-way merges (it uses the common ancestor of a file to determine what it can merge automatically)
  • It is completely free for commercial or personal usage
  • I believe that one of most disappointing “features” of most compare tools has been an lack of displaying in line changes between files, most tools will show that a line has changed, but does not show the actual portion of the line that has changed. Chasing down an errant carriage return, or spelling change in a long line of code can take awhile. From the screen shots in the Blog above, you can see that this is addressed.

    Happy Comparing and Merging!

    Pragmatism in Business & Technology Strategy

    Wiktionary defines pragmatic as:

    pragmatic – Practical, concerned with making decisions and actions that are useful in practice, not just theory.

    As a technology consulting organization we frequently get asked to assist people in defining or refining their business and technology strategy, or to explain why we’re an organization that people should work with.

    My normal response when giving advice or answering this question is pretty simple: we focus on results – achieving a positive outcome for the business (in our case our customer’s business). I then go on to explain a little more of my thinking…

    It’s rare to find a problem that has only a single possible solution – in most cases there are are a number, with some being better or worse, easier or harder, cheaper or more costly etc. How do we weigh up the options and help people pick the right approach? One word comes to mind: pragmatic.

    Here are some ideas that we consider when helping our customers make pragmatic strategy choices.

    Look Back as well as Forward!

    Reality dictates that unless your business is a startup any strategy must co-exist with products, processes, systems and technology that are already in place. While we shouldn’t be bound by the past and present if there’s a good reason to move in a different direction, we should at least consider the implications for a business in moving to a new strategy.

    Of course, this is also a good way to avoid making the mistakes of the past all over again.

    Plan for Change

    I’ve often heard people say that change is the only constant! Organizations grow, shrink, get acquired or dramatically change course all the time. Making strategic choices that recognize this and are at least partly proof to the winds of change may not be obvious to everyone at the time, but just about everyone can see them after the fact.

    The first question from many of you will be “How do I know what will change, and when?”. The answer (of course) is that many times you won’t know precisely what will change, but you can often predict what is more likely to change. An example might be taxation rules or rates – if these factor into your decisions you had better assess the impact of them changing because you can be certain that over time they will!

    Technology is a Tool, Not a Goal

    I’m sure many of us know someone who just has to have the latest gadget or toy, and can find some “reason” why it’s valuable. We see the same thing in business surprisingly often – with the same lack of real results.

    Weeding this out of your strategy can sometimes be a bit tougher than we think since simply not keeping pace with technology trends can mean death to some businesses. But even when we undertake pure technology modernization projects we should always consider whether we’re satisfying a true business need, and getting “value for money” compared to not doing it at all. If not, maybe we’re too focused on the technology, and not enough on the real goal.

    No One Answer

    Sometimes a single right answer may be unrealistic. A solution in one environment may simply add complexity or cause pain when applied to another. Don’t be afraid to choose two options if one is not enough. Or after reviewing all the options, the one where you do nothing at all may be the best!

    Avoid Short Term Syndrome

    How many “short-term” solutions become long term problems? It’s important to overcome resistance to looking forward, and to consider the same fundamentals – including future flexibility.

    Agile Strategy

    Finally, you might be wondering how the above fits alongside our stated preference for using an Agile approach to implementing technology solutions? My answer is that ultimately we believe the outcome is what is important, not the approach to getting there. Our current thinking (and we’re obviously not alone!) just happens to be that Agile approaches help organizations get there faster and more effectively than the alternatives right now.

    To back this up from a slightly different perspective, Elisabeth Hendrickson recently discussed why she defines Agile in terms of results:

    Where people define Agile in terms of practices, I see more instances of Cargo Cult adoption (”We’re Agile because we stand up every morning!”) and religious dogmatism (”You don’t TDD?!? You can’t possibly be Agile!”).

    Where people define Agile in terms of values, I see more instances of Agile-as-an-excuse (”Documentation? No. We don’t document anything. We’re Agile!”).

    But where people define Agile in terms of results, I see greater focus on the ultimate goal: value to the business.

    I really couldn’t put it much better: attention to results keeps everyone focused on what’s ultimately important.


    Are you tired of working with consulting companies who give you what you ask for, but not what you need? If you want to partner with us to extend your IT capabilities and produce real results, contact us

    Heilmeier’s Catechism – a checklist for software projects

    Speak & SpellUntil recently, I am ashamed to say that I had never heard of George Harry Heilmeier. A recent retweet by Roy Osherove on Twitter soon had me digging for more information.

    It turns out that not only was Mr. Heilmeier  a pioneering contributor to liquid crystal displays, he was a Vice President (and later CTO) of Texas Instruments during the time they produced the mighty Speak and Spell.

    Mr Heilmeier’s Wikipedia page lists an amazing amount of awards, including the National Medal of Science  and the IEEE Medal of Honor, but that’s not what sparked my curiousity.

    What was interesting to me about Mr. Heilmeier was a series of questions anyone should be able to answer when proposing a research project or product development effort. These questions are known as Heilmeier’s Catechism.

    Here is Heilmeier’s original list of questions:

    Heilmeier’s Catechism

    • What are you trying to do? Articulate your objectives using absolutely no jargon.
    • How is it done today, and what are the limits of current practice?
    • What’s new in your approach and why do you think it will be successful?
    • Who cares?
    • If you’re successful, what difference will it make?
    • What are the risks and the payoffs?
    • How much will it cost?
    • How long will it take?
    • What are the midterm and final “exams” to check for success?

    When I read this list, it struck me that these questions could easily be adapted as a software project checklist.

    With some small tweaks in language, this list becomes a standard project checklist that any consulting organization should work on with their customers to answer when deciding whether or not to go ahead with a project:

    Project Checklist

    • What is the underlying business problem we are trying to solve with this project?
    • What happens today? Is this problem worked around with manual processes?
    • What’s new in this approach and why do we think it will be successful?
    • Who are the project stakeholders?
    • If we’re successful, what difference will it make?
    • What are the risks and the payoffs? How can the risks be mitigated?
    • How much will it cost?
    • How long will it take?
    • How will we measure progress on the project? How do we know we’ve been successful?

    What about your organization’s project approval process? Does your company use Heilmeier’s Catechism to decide whether to give a project a green light? What other questions should be asked before starting a project?

    SOQL Group By – Grouping records in Salesforce.com

    Overview

    One of the most sought after features in SOQL (Salesforce.com Object Query Language) has been the inclusion of record grouping. While Aggregate functions such as Min, Max, Count, and Sum have been available, they have not been available to retrieve grouped Aggregate results. For example, if you wanted to retrieve the Count and Sum(Amount) of Opportunity Records grouped by an Account, you have to retrieve all of the Opportunities and create a loop to increment Counts and Sum based on the Account associated with the Opportunity. Ugly!
    With the introduction of the Salesforce Platform Winter 2010 release and version 18 of the API, grouping and a few other functions are available. In this post I will concentrate on the “GROUP BY” clause. In future posts, I will examine other clauses such as:

    • GROUP BY ROLLUP ()
    • GROUPING ()
    • GROUP BY CUBE ()
    • HAVING ()

    EXAMPLE

    In this example, I want to showcase the different types of Grouping and Aggregate Functions that can be combined to come up with some interesting results. I want to create a Visual Force Page bound to a Custom Controller, where I can display the results of the SOQL statement.

    First, let’s start with the Controller code. I wanted to bind the results of the query directly to a apex:dataTable, so I created an object to hold the Grouping values and Aggregated results. Below is the object:

    public class GroupedQuery
    {
        public string GroupBy1     {get;set;}
        public string GroupBy2     {get;set;}
        public string GroupBy3     {get;set;}
        public integer Count {get;set;}
        public Decimal Sum {get;set;}
        public Decimal Average {get;set;}
        public Decimal Min {get;set;}
        public Decimal Max {get;set;}
    }

    In addition, in order to bind an object to the dataTable within the Visual Force page, you need to expose a public member from your Controller code. For brevity sake, I just added a public List<> member like this:

    public List<GroupedQuery> queryResults {get;set;}

    Next in the Controller Constructor (keep in mind this is for demo purposes!) we use a SOQL query to retrieve a List of generic sObjects:

    List<sObject> queries = [select Account.Name AccountName, Count(Name) CountResult
                                               from Opportunity group by Account.Name];

    Once we have the Results we iterate through a loop to create our collection of GroupedQuery objects:

    queryResults = new List<GroupedQuery>();
    for (sObject query: queries)
    {
        GroupedQuery myObject = new GroupedQuery();
        myObject.Count = Integer.valueOf(query.get('CountResult'));
        myObject.GroupBy1 = String.valueOf(query.get('AccountName'));
        queryResults.Add(myObject);
    }

    The variable queryResults is exposed as a public variable from the controller and thus we can tie this List directly to a dataTable and access the public properties of the GroupedQuery object contained in the List. Below is the Visual Force page code:

    <apex:dataTable id="queryResults" value="{!queryResults}"
                    var="queryResultsRow" border="1" width="100%">
        <apex:column >
            <apex:facet name="header">GroupBy1</apex:facet>
            {!queryResultsRow.GroupBy1}
        </apex:column>
        <apex:column >
            <apex:facet name="header">Count</apex:facet>
            {!queryResultsRow.Count}
        </apex:column>
    </apex:dataTable>

    The code above will output the following results (the Account data is data from the Developer Edition of Salesforce.com)

    A more involved example is included below. This includes two levels of grouping, as well as Min, Max, Sum and Average functions:

    Summary

    As demonstrated, the new functionality released with the Salesforce.com API Version 18 with regards to Grouping is extremely powerful and addresses a pain point that many developers have had to overcome to achieve Rollup type queries. This information is contained within the What’s New notes for Salesforce.com Version 18. Keep in mind this is included with the Winter 2010 release of the Salesforce.com platform, so you will need to ensure that your organization has been upgraded in order to avail of this functionality.

    Are you tired of working with consulting companies who give you what you ask for, but not what you need? If you want to partner with us to extend your IT capabilities and produce real results, contact us

    public class GroupedQuery
    {
    public string GroupBy1     {get;set;}
    public string GroupBy2     {get;set;}
    public string GroupBy3     {get;set;}
    public integer Count {get;set;}
    public Decimal Sum {get;set;}
    public Decimal Average {get;set;}
    public Decimal Min {get;set;}
    public Decimal Max {get;set;}
    }