Allaire Brothers talking about ColdFusion

I came across this video and thought i would share it. On the 20th Year anniversary of ColdFusion listen to the Allaire brothers talking about the need for ColdFusion when they started.This is another great example of an idea that was started simply to help a small group of people that took off into this amazing product. Great ideas don’t need to be the next Facebook or Twitter to have a real impact. If you can create something that will be helpful to a few, chances are it will be helpful to many. Happy belated anniversary ColdFusion.

 

Getting Started with Slatwall eCommerce

If you are looking for a stand alone eCommerce solution or one that integrates with an awesome Content Management System (CMS) like Mura than Slatwall is the answer for you. I have been using Slatwall for a couple years now and I love it. I used Slatwall at a previous job for a couple of in house projects and I even moved over my good friends custom eCommerce website to Mura and Slatwall. It’s been a while since I have had a chance to play with Slatwall and they recently released version 4.1 so I thought this was a perfect time to create a series of blog posts to tell you all about it. So lets dive right in.

Getting Started with Slatwall eCommerce

Most of the directions I am going to give you here are in the documentation. In this example we are going to create a new fictitious store called iPhonez. This will be a fictitious store that sells Apple iPhones. This is a good product to to demo because there are different models and inside each model there are different configurations.  My demo is running off of a Mac but you can easily do the same on whatever you are using. First lets start of by downloading the stand alone application from Github or by cloning the repository.

clone_slatwall

 

 

 

Migrating BlogCFC Comments to Disquss

If you haven’t noticed yet I moved my blog over to WordPress. Creating a new WordPress site was incredibly easy and I found it stupid simple to add functionality through plugins. I plan on talking about those plugins over the next few days but for now lets focus on comments.

With the different platforms I was looking at the one thing I did like was that they all supported Disqus comments. I really like the Disqus platform and the idea of handing off my comments to them was intriguing. I also liked the look of everything and the ability to have nested comments. If I ever want to leave they don’t hold you hostage and you can easily export your data out.

PayPal PayflowPro RESULT=117 Failed merchant rule check

I am upgrading an online shopping cart for a friend over the holidays. We are moving over to Slatwall and yesterday I was having some issues with the credit card processing using PayflowPro. Whenever I would submit a test card (from the documentation) I would receive the following response.

RESULT=117&PNREF=B11P5DEBFF57&RESPMSG=Failed merchant rule check

I knew my account information was correct so that couldn’t be the issue. I did some digging and found out that a 117 is caused by one or more of the following.

  • An attempt was made to submit a transaction that failed to meet the security settings specified on the PayPal Manager Security Settings page. If the transaction exceeded the Maximum Amount security setting, then no values are returned for AVS or Card Security Code.
  • AVS validation failed. The AVS return value should appear in the RESPMSG.
  • Card Security Code validation failed. The Card Security Code return value should appear in the RESPMSG

Based on the fact that I was not getting back an AVS or CVV value in the response message I figured It had to do with my security settings. I did a little more digging through the documentation and found this.

IMPORTANT:The default security setting for Payflow Pro accounts is Allow non-referenced credits = No, so sending the ORIGID is the preferred method for performing Credit transactions. Using the ACCT, EXPDATE, or AMT parameters for such accounts leads to RESULT value 117 (failed the security check).

After I found that I went and updated my security settings and was now able to submit my test transactions.

Groovy collections vs My Current Thought Process

I have been a ColdFusion developer since before I can remember. What I have always loved about the language is that it made hard things really easy to do. Somewhere along the way though I think it lost some of this magic at the core of the language. Let’s take a look at a pretty trivial problem (but one that might come up often) and look at how we can solve it in both ColdFusion and Groovy.

Given a collection of names : print each name to screen and display a comma in between each name. Make sure to ommit the comma after the last name in the collection.

This doesn’t seem like that hard of a problem, lets take a stab at it. First we create an array of names. In our first attempt we decide to use a for in loop and loop over each name in the collection. During each iteration we print the name and a comma. The main glaring problem with this approach is that we are going to print a comma after the last element and that won’t solve the problem at hand.

So we move on to our next attempt. We decide to use a for loop so that we can have the index of item that we are printing out. We will print out the name and a comma except for the last item where will not print out the comma.

While this will work it isn’t a very clean solution. All this work to solve a pretty simple problem. Finally we do some looking around and remember these a special function in the language to accomplish this. ArrayToList will actually take an array and create a list with a delimiter. I could of actually left out the comma here as it is the default but I just wanted to make sure it was clear what was going on.

So I asked another dev to look at the same problem and he pretty much took the same thought process I did. I don’t know about you but I feel like I write more loops in ColdFusion than anything so its alway my first instinct. Unless you know ever function the language has to offer the solution may not of been apparent to you right away. Be honest, did arrayToList cross your mind before you got to the solution?

Now let’s look at the Groovy solution. I am pretty new to the language but one thing I have noticed is that working with collections is a joy to do. First lets look at the solution and then we will talk through our thought process. The join method will “join” each element in the list and separate them with the delimiter you provide.

So what is the difference. The difference here is the join() is a first class member function. This means that I can call it directly on the collection itself. I don’t need to start thinking about what functions are available to me and what the arguments are (and what order the come in) I just know that I can call a method to accomplish this. I know that if I want to iterate over the collection of data I can call

names.each()
names.eachWithIndex()

I know that if I am looking for something within the collection I can call

names.find()
names.findAll()

I know that if I need the size of the collection I can call

names.size()

Finally what about a scenario where you want to create a new array that holds the string length of each of our names. Our first thought again is we need to loop over the current collection and create a new one. To do so we need to initialize an empty array, loop over each name and then add a new element using a function that takes the array name and value.

In Groovy we again know that the collection has a 1st class function to do this using collect. This will return a new collection by manipulating the existing collection. This to me is a very clean and elegant solution.

I hope nobody gets the wrong impression about ColdFusion here because many of these same approaches are the same in many languages. I just wanted to point out how much I enjoy working with collections in Groovy. They make me think a different way when dealing with data and I am finding myself writing a lot more boring iteration loops these days.

Groovy’s null safe operator

The more years I get under my belt as a programmer the more I appreciate the smaller things a language has to offer. Today I want to look at Groovy’s null safe operator. When you want to crawl an object graph you always have to be worried about the dreaded null pointer exception. First I want to take a look at this example in ColdFusion. In this example we are looking at the body of a method where we load up a user object. We want to grab the city of the user object but in each step of the object graph we need to make sure that call is not null before preceding.

In Groovy we can do this shorthand by using the null safe operator (?.). If the variable before the question mark is null it will not proceed and actually returns null for you. We could even shorten this statement more but you get the idea.

The Groovy language has so many little things like this that I am really starting to love. What are some of your favorite features in the language?

Bootstrap Breadcrumbs for Mura

I am working on a friends site that uses Mura & Slatwall. I needed a way to display some breadcrumbs for the products area. Luckily Mura comes with a built in way to do this.

This uses a method in the default content renderer. This works great but I actually want to use Bootstrap to style it. To do so I need a little bit different markup than what the default content renederer provides. Luckily Mura allows us to override this method in our our own content renderer. Simply open {site}/includes/contentRenderer.cfc and add your own dspCrumbListLinks method. I just copied the method from the default and made a few changes. This will override it for all themes, of course if you need it only for a specific theme just add it to the content renderer inside the themes folder.

I am having some issues with word wrap on that code so I decided to attach a text file with the function inside. I will update this post when I fix that. Click the download attachments link in the article entry bar below.

I am an Adobe Community Professional, again!

I forgot to share the great news but I received the following email about a week ago.

Hello,

I am pleased to announce that your Adobe Community Professional application has been accepted. Out of all the applicants, you exhibited the qualities that would make you an excellent community member. Congratulations!

It was an extremely hard decision making process this year and many applicants were exemplary. We were not able to accept as many members as in previous years but we feel that with a smaller group we will be able to refocus the program and give you all the attention you deserve.

It really is a great honor to be selected as an ACP for a 3rd year in a row. Thank You Adobe!

Removing duplicates from an array of objects

I have a style of programming that generally works well for me. I like to solve a problem and then step back and evaluate my solution. This gives me a chance to see if there is a better way to solve the problem at hand. In the programming world we gave this a fancy name, refactoring. I am also very lucky to have some really smart people at work so when I have the chance to discuss code I take it.

Last week I was working on a problem that I have solved countless times before. I had an array of objects and I wanted to make sure no duplicates of a certain key were returned to the caller. Before I write some code I like to talk the solution out so in plain English this is what I need to do.

  • create an empty array to hold our new array
  • loop over our existing array of objects
  • if the current key doesn’t exist in our new array, add it

Seems pretty simple and I am betting a lot of people have taken this approach before. So what does this look in code? First we have our example array of objects. In this array class code is the key we don’t want to duplicate. Next we create an empty array that will contain our duplicate free result.

Next we are going to loop over our array. During each iteration we loop through our new array and check to see if that value exists, if it does not go ahead and add this object to the new array.

While this works great I was talking with a coworker (Jason Delmore) and he came up with a pretty cool alternative. Instead of creating a new array to hold our result we can simply look ahead to see if this key exists and if it does remove it and decrement the loop index.

We can also do the same thing in JavaScript.

This may seem like a small change or there may be better ways to solve this (I would love to hear them) but I love it. I enjoy looking at problems like this and understanding ways to solve them (in English) and then taking a look at how we can implement them.

Looking for a ColdFusion developer in Cleveland

Yesterday I announced my plans to join First Comp. Today I would like to help my current employer fill my position. I really like the people here and the company is doing some great things. This is why I want to help them as much as I can to find my replacement. If you are in the Cleveland area and have the following skill set please contact me.

  • HTML/CSS/JavaScript – Strong front end development skillset
  • ColdFusion
  • jQuery

It really is a great place to work for an individual who wants the freedom to take a project from start to finish as they see fit. If you have any questions about the position please let me know.