Archive for March, 2011

Getting the CRUD out

Friday, March 18th, 2011

The topic of one of GORGES recent internal Friday Tech Talks was “Yii CRUD: Tips and Tricks.”  I proposed this because I was curious to hear war stories from other developers about the problems and solutions they ran into when building “CRUD” – principally in the Yii framework, which has become one of our favorite tools at GORGES for creating complex web applications.

CRUD stands for Create, Read, Update and Delete (or, for some folks, Create, Retrieve, Update and Destroy). It refers to the basic operations that any data-centered application needs to make it run – creating new objects or records, viewing them, editing them, and getting rid of them. The code that performs these operations tends to get pretty repetitive after a while, so for a seasoned developer it can become the part of the application that you most want to “get out of the way” so you can focus on the more interesting bits, like complex business logic and nifty Javascript widgets. It is also often predominant in the administrative side of an application, where there is typically less budget for fancy design and interactivity than on the public side – but it still needs to work effectively. Thus, when developers refer to it as “crud”, they don’t always have the acronym in mind.

Here are some of the comments I heard from our team on how to create CRUD efficiently, in order to deliver quality, maintainable, cost-effective applications to our clients:

1. Don’t build it at all, if you can help it - For simpler web applications, or ones that are more content-oriented, a “full stack” framework like Yii or Ruby on Rails can be overkill – a platform such as Drupal can take care of most of the housekeeping operations, with coding (or configuration) only required for the more “custom” features of the application.

2. Use code generators – Yii and most other advanced web frameworks include tools for generating “skeleton” code for CRUD operations. Most developers felt that these are a good starting point, especially when first learning a framework, but after a while it becomes more efficient to write from scratch, with judicious use of copy and paste from existing similar code (but beware the Rule of Three).

3. Modularize your MVC components – Even though the Model-View-Controller idiom forces the developer to think in modular terms to some extent, it is still possible to write overly repetitive code within that idiom, and violate the DRY principle. Frameworks such as Yii provide a great foundation for building a web app, but the larger and more complex an application is, the more it makes sense to build on that foundation by using inheritance, polymorphism, and other object-oriented techniques in the CRUD (as well as in the non-CRUD components).

4. Build widgets where appropriate – This is just a specific example of modularization; Yii provides a widget API for building components that can be reused in different areas of an application. There are many standard widgets available, for components such as date pickers, but again, in some cases custom-building just the widget you need for a given application makes sense to keep everything “DRY”.

5. Use advanced languages - Just like application frameworks, many of the standard web development languages provide a great basis, but leave plenty of room for additional optimization. Two tools that our team is very excited about are HAML and SASS, which provide more efficient and elegant syntax for generating XHTML and CSS, respectively, than coding directly to each language. I won’t go into technical details here, but both tools allow the developer to create more robust solutions with fewer keystrokes.

These techniques and the fact that GORGES has structured ways of building staff efficiency, illustrate how GORGES developers are constantly looking for better ways to deliver quality web applications – avoiding CRUD!

Ted Caldwell is an Application Developer and Senior Software Architect for GORGES. Ted's work encompasses all aspects of web application development, including requirements analysis, database and software design, programming, project management, and system administration. Ted focuses on delivering practical, cost-effective technology solutions for GORGES clients, using a variety of custom and off-the-shelf software tools and frameworks.

Unit Testing – A Key Part of Web Development Best Practices

Thursday, March 10th, 2011

Unit Testing: What is it and Why is it Important?

A unit test is a program that verifies that another program works as expected. Unit testing is an approach to software development in which the programmers write tests for their code to make sure that it continues to work as the system evolves.

A simple example of a unit test for some programming code that calculates sales tax based on the state in which an order is placed would have inputs of a state and an order amount, and test whether the result is the expected sales tax.

The ‘test suite’ is run continuously during development, instantly alerting developers to emerging code issues. The developers also run the test suite before publishing updated code to make sure they don’t break anything that used to work. Some software development environments, such as Rails and .NET provide unit testing frameworks out-of-the-box. Other development environments need varying levels of work to configure a working unit testing framework.

A common objection to unit testing is the time and expense it takes to write the tests themselves versus the time it would take along the way to fix bugs as they emerge. We at GORGES have found this to be a spurious argument. As we write programs, we have to check that they work and that they don’t break other programs. If we don’t have tests, we have to manually click around. That introduces both the element of human error (oops I forgot about that!) and the expense of paying humans the time it takes to do all that clicking when a machine could do it just fine. However these are not the only benefits of unit testing:

  • Programming code changes that break an existing test are identified immediately, allowing the programmer to fix the problem while the issues are still fresh, saving time, and money.
  • Unit tests provide effective code documentation so that new programmers on the project can become productive faster.
  • Changes made to supporting software, such as frameworks and operating systems, are tested quickly, reducing the risk of introducing bugs when technology upgrades are made.
  • The cost of implementing new features in the future is reduced because the unit tests provide context and ensure that old programming code is not broken by the new programming code
  • Refactoring, a common task of restructuring the code to make it easier to use and maintain, easier and less time-consuming because the unit tests ensure the refactoring process does not break the application.
  • Regression bugs, issues that appear multiple times, can have specific unit tests written for them, so ensure we don’t get ‘bitten’ twice or more times by the same bug.

Unit testing is not a panacea for ensuring that a software application is free of bugs – almost all software applications exhibit a problem at some point. The value of unit testing is that it helps to significantly reduce bugs, and make it easier and cheaper to fix any bugs that do appear.

Making your website work for you!

Tuesday, March 1st, 2011

You have invested real effort and funds into a new website.  It is beautiful, full of good content, kept up to date and has many features.  But, you aren’t getting the traffic or sales you are hoping for.  Here, we will help you find out why.

First, you need to establish a clear goal for your site.  While we build many websites and web applications that aren’t strictly for sales, such social networks, tracking systems, content management systems, and customized back-office tools; this article will focus on websites that are cultivating relationships and selling products or services.

Your product or service has to solve your visitors ‘problem or need’, or they won’t buy it. Keeping your content up-to-date and fresh is very important.  New content can be provided by the website administrators, site visitors, or automated feeds.  Stale websites are easy to detect and quickly turn away potential customers.

With that in mind, you need to make sure that when you are designing your marketing plan, you allow for a series of action steps.

Incorporate those steps from the beginning into your web marketing plan, and watch your sales grow as you achieve a positive return.

There are four concepts to follow so that your website starts to bring you business, which will, in turn, lead to sales.

ATTENTION:  Once a visitor to your website has arrived, you have a very short amount of time to grab their attention.  The content on your landing page should prominently display an offer or promise.  Keep the graphics and colors minimal and professional.  Make sure the site loads FAST.

INTEREST: You have caught your visitors attention, now keep them interested.  Offer information and links that keep them engaged.  Show problems or needs paired up with your solutions to make your offering relevant to their situation.  Offer a new benefit or feature or idea they hadn’t considered and they will keep reading.

DESIRE: Their interest has been secured, so now it is time to create desire. Motivate them to take action of some kind.

ACTION: Your website’s first action should be to ask your guest to identify himself or herself, and be sure to get some sort of contact information to begin to build a relationship. Get your guest interested in something that you are offering free of charge.

You want your website to work for you.  In order for that to happen, the web marketing plan needs to be built into the website, or given sufficient priority if happening later in the life cycle of your website.

Your website needs to acquire the visitors attention, stir up interest, cultivate desire intelligently, and get them to take some action.  This first action doesn’t need to cost any money.  Establish communications, usually via email or auto-responders that are thoroughly planned.

Try to put yourself in the shoes of your target customer. If you were visiting a website, what would you want to see there? What would fulfill your needs?

Remember that if your visitor visits your website and she doesn’t leave you with any way to contact her, your website has not been successful in this most-important first step.

If you want your visitor to connect with you, tell him or her. Let your visitor know in clear and simple terms how much you want to interact with him or her and make it easy.  There are many ways in which to successfully use your website. You just need to put those ways to work and you will start to enjoy more and more success for your business.

Check more about our Web Marketing Services.

Christopher Grant, CEO of GORGES, has been building Internet web sites and commerce applications since 1994, pioneering early database-driven Web application and e-commerce projects. He has been instrumental in the construction of hundreds of Internet projects, large and small.
©2012 GORGES - All rights reserved
where programming meets design and lives happily ever after