Author Archive

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.

Saving brain cells with WinSCP

Wednesday, September 22nd, 2010

One of my daily challenges is getting access to the hundreds of different web sites that we host in order to make edits, tweak file permissions, or fix bugs. It’s easy to remember a handful of different URLs, login IDs, and passwords, but my photographic memory only has a 5-1/4″ floppy for storage, so as the number grows I need help.

One tool that’s helped me achieve more ninja-like response times is WinSCP, a free GUI-based FTP/SFTP client. Like most FTP clients, it lets me maintain a list of stored sessions that I can open in a flash, but what sets it apart is the slick integration with the popular PuTTY SSH client.

I came to WinSCP by a round-about path – for a long time I used FileZilla for SFTP and PuTTY for SSH, but the effort of maintaining a separate list of site logins for each tool ate up valuable brain cycles and finger motions that could have been used profitably for other tasks. When I discovered WinSCP, it was like a floor wax and a dessert topping in one – the tool lets you launch both PuTTY and SFTP sessions to a given server in a single stroke. Sometimes you need a little command shell, sometimes you need a lot – now you don’t have to choose.

Setting up the PuTTY integration takes a few minutes, but it’s fairly simple. In WinSCP, open the Preferences dialog and select the Integration / Applications heading on the left. Enter the path to your PuTTY installation (you need to install PuTTY separately), and set the other options the way you like them – the most useful one lets you pass the session password to PuTTY so you don’t need to enter it again. You can set it to launch a PuTTY session every time you connect to a server via SFTP, or you can just use the convenient button on the main toolbar to launch PuTTY when you need it. Either way, the seconds you save by not having to re-enter the login ID and password each time can add up in the long run.

One minor annoyance that I recently solved was setting the color preferences for PuTTY when launched from WinSCP – I knew how to do this with stand-alone PuTTY, but the integrated version always came up with a blue-on-black scheme that was a challenge for my aging eyes. To fix this, just use the normal PuTTY settings dialog (in PuTTY, right-click on the title bar and select Change Settings), but be sure to select “WinSCP temporary session” in the list of saved sessions, and save your changes to that.

WinSCP has a host of other features I haven’t even explored yet, including remote directory-synchronization functions and extensive scripting and command-line support. You can also generate Windows shortcuts to saved sessions, which could be stored with
your other project files to make your life still easier.

If you want to spend more time with your family and less time searching for passwords, I’d recommend giving WinSCP a try.

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.
©2012 GORGES - All rights reserved
where programming meets design and lives happily ever after