Made of Everything You're Not

Personal blog of PHP programmer Eric Lamb.
  • Blog
  • Portfolio

Archive for August, 2009

WP-Click-Track: A Roadmap

Posted in Brain Dump, Programming on August 31st, 2009 by Eric Lamb – 1 Comments

When I first started wp-click-track it was because I had a specific need; I wanted to find out how helpful my posts would and what better indicator than how many people clicked on the links in my posts. It was only to drive traffic and get my name out on the Intertubes that I released the plugin to other WordPress users and sites.

Roadmap

I never imagined people would actually use it much less have so much great feedback and improvement suggestions. As great as the insight is though it has pretty much made my plans for features and upgrades secondary to the users requests. As it should; because of the users wp-click-track is on a great track to become something truly useful.

There are only 3 releases left before the final, 1.0, version and to reach that I have the following outline:

0.7

The features for this release are going to focus on Data Export, Localization and a reworking of the configuration page.

Data export is a little complicated because two offerings have to be created to allow for older systems; normal csv/tsv and complete XLS export for users with newer systems. The XLS export will use the Excel 2007 XLS file format built using phpExcel. Since phpExcel requires php 5.2.5, at least, the exporter needs to be smart enough to degrade elegantly when the system can't perform.

The Localization phase has already started with the release of 0.6. Initially, wp-click-track will be localized in french and spanish using Google Translate (until a native speaker can contribute). If anyone knows of a better method for transcription I'm open to suggestions.

There's also going to be a refactoring of the cookie functionality. I admit, I was a little lazy about this, something I'll go into more detail about at a later time. Now it's time to clean this up.

0.8

It's important that wp-click-track act like a native WordPress module; that's what 0.8 is going to focus on. This one is obviously going to include more AJAXy goodness  to make link management easier and a little more inline with the rest of WordPress.

One thing 0.8 will definitely have is a removal of the Edit Link page. I've never really been happy with how that functionality worked; it's very... standard. Instead, it will be modified into a simple "click to edit" style similar to how the permalinks are edited on the post edit page.

0.9

0.9 will include some advanced functionality like backup and import capabilities and the creation of WordPress hooks so other developers can extend the plugin. I have some ideas for a Bookmarklet for link creation but I don't know how relevant that might be to other users.

By this point, I should have a fix for the little bugs that have been with the plugin since the beginning. I can't say they won't be done before 0.9 but they will be done by then.

1.0

Unless there's any objection this release is also going to include functionality to send me usage and error information. I guarantee there won't be any sensitive data being sent; EVER. It's just important to know how the plugin is being used and what errors happen. This will be opt-in too so it won't be a requirement.

The other thing the plugin will be ready for is donations. I never really wanted  to go this route but I had a day job then. This too will be opt-in only and there won't be any nag screens or anything annoying. This will be as unobtrusive as possible I promise.

It should be noted that there's no real guarantee that the functionality mentioned above will be done in that order. Need drives the direction more than anything else and the users certainly aren't shy about steering the ship so to speak.

After 1.0 I don't really anticipate any more updates; except for bug fixes or specific requests. Obviously, when WordPress changes their core functionality again the plugin will be rewritten and tested and a new version cycle will probably begin.

I Want Google Voice and So Should You

Posted in Brain Dump, Business on August 28th, 2009 by Eric Lamb – 0 Comments

I have a problem; ever since I started freelancing my phone bill has exploded. When I was working I didn't use  it all that much during the day; having a day job an all. Now that my days are open, and I have to do the majority of my client interactions on my phone, I've had to deal with HUGE bills ($700) for both text messaging and minute overages.

Google Voice

To the credit of AT&T they credited my account and I wasn't out any cash. But don't forget the fact that the phone companies are essentially gouging customers with their rates on text messaging; the $20 a month for unlimited text messages is just a drop in the bucket compared to that.

BTW, there's no such thing as unlimited text messages. Check the terms of service for your provider; a lot of them actually limit the total amount and you'll face a ginormous bill if you go over.

It's pretty infuriating. Thankfully, once again, Google has come to the rescue with Google Voice. Google Voice is a service that gives you one number for all your phones, voicemail that is easy as email, and many enhanced calling features like call blocking and screening, voicemail transcripts, call conferencing, international calls, and more.

According to the official page for Google Voice includes a crapload of features:

One number for all your calls and SMS

  • Call screening - Announce and screen callers
  • Listen in - Listen before taking a call
  • Block calls - Keep unwanted callers at bay
  • SMS - Send, receive, and store SMS
  • Place calls - Call free within the continental US and to Canada
  • Taking calls - Answer on any of your phones
  • Phone routing - Phones ring based on who calls
  • Forwarding phones - Add phones and decide which ring

Voicemail as easy as email, with transcripts

  • Voicemail transcripts - Read what your voicemail says
  • Listen to voicemail - Check online or from your phone
  • Notifications - Receive voicemails via email or SMS
  • Personalize greeting - Vary greetings by caller
  • Share voicemail - Forward or download voicemails

More cool things you can do with Google Voice

  • Conference calling - Join people into a single call
  • Call record - Record calls and store them online
  • Call switch - Switch phones during a call
  • Mobile apps - Try our apps for Blackberry and Android phones
  • Mobile site - View your inbox from your mobile
  • GOOG-411 - Check directory assistance
  • Manage groups - Set preferences by group

All of that's pretty compelling; but it's not the most important piece. Nope, the best part is that Google Voice operates on your phones data plan so, if I ever get invited to the service, I'm planning on lowering my minute plan, killing unlimited text messaging and saving around $100 a month.

The key is that I use a Blackberry; there's already a Blackberry app that allows for the system to flow. Oddly, if you use an iPhone you're out of luck; Apple pretty much screwed the pooch on that. But, not to fear, you can even access Google Voice through a web browser.

I can't wait to say, "Fuck you" to AT&T. Just got to get that invite first...

Fiddler Web Debugger

Posted in Programming on August 26th, 2009 by Eric Lamb – 0 Comments

Let's not kid ourselves: web development isn't that hard. Nope, the server side stuff (php, .NET, etc) or even what happens in the browser (JavaScript, CSS, etc) isn't too difficult. Not all of it's easy though; sometimes when dealing with the HTTP level things can get a little... random.

Fiddler Web Debugger

In FireFox I use a couple plugins to help make HTTP debugging a little less painful; HttpFox and the venerable FireBug. There's also a cool tool called Fiddler written by Eric Lawrence of Microsoft.

Fiddler is a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect all HTTP(S) traffic, set breakpoints, and "fiddle" with incoming or outgoing data. Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET language.

Fiddler is freeware and can debug traffic from virtually any application, including Internet Explorer, Mozilla Firefox, Opera, and thousands more.

First, it should be noted that Fiddler is covered under a Microsoft license. That might matter to you or your company...

Anyway, in order to get Fiddler to work with anything other than IE, I'm talking about programs like FireFox or similar, you have to do some tampering and configuring of Windows, including the registry, along with the program you want ot send requests from, so for now I only tested it using IE (this can't last though; I'm just NOT going to develop in IE).

Fiddler does the basic HTTP sniffing you'd expect but it also has tools to inspect and tamper with the data in the traffic; this is where HttpFox and Firebug drop the ball. Fiddler allows you to see the basics as you would expect any HTTP sniffer to allow but also displays out an XML rendering as well as the Hex view (if you need that sort of thing).

You can mess with a bunch of the different parts of the session including the session itself using custom built "rules". These rules are written in JavaScript and contain commands that extend Fiddlers UI to allow for extensibility. Needless to say, this is a cool part of the tool.

Another really cool feature of Fiddler is that it can hook into the session for pretty much any Microsoft program that connects to the Internet like Microsoft Office. (I'd always been curious what connections Office makes while open and finding that out scratched a long standing itch.)

It's definitely worth a look if you need to debug any HTTP traffic (AJAX anyone?).

Looking For More From Zend Framework

Posted in Programming on August 24th, 2009 by Eric Lamb – 4 Comments

After about a month of working with the Zend Framework I'm a little... bored with it. If this is what working with a framework is like I don't want it (thank you very much). I, naively, thought using a framework would increase my productivity and highlight some of the joy I feel when developing and learning but, so far, all I have is frustration and a pretty heavy headache.

Looking For More Than Just Zend Framework

Yup. Zend Framework has made my head hurt.

It's not like there's not a lot to love about it; Zend Framework really has the makings of the perfect offering. There's a really easy sample app walk through for newbies to become familiar with the program. The documentation is suberb and includes code samples of most class methods. Best of all: there's a bunch of sites out there with examples how to do pretty much everything I could think of with the framework (this was also one of the issues; more on that in a minute).

All that made me feel pretty encouraged and optimistic about Zend Framework when I initially decided on using it. Everything was going along smoothly for a while too; I had gotten past the ZF_Tool issues, introduction to Zend_Application and even developed a couple, basic CRUD, modules which gave me a good grounding in how the layout and structure of Zend Framework... ahem... worked.

Then, I got into the Auth functionality.

First, a few details about what I was trying to build:

This was to be a basic web app with member signup, login, forgot password, contact page (with form). I wanted to build a permission system using Zend_ACL and Zend_Auth and I needed to have complete control over form layouts. (I'm planning on building a full web framework base to help me when building my client sites. This was just to get up to speed with the Zend Framework.)

Anyway, yeah, once I started in on the Auth functionality everything came to a grinding halt. It looks like Zend changed how the Auth functionality works right around the time I got into the framework so all the tutorials and examples I found online were outdated and no longer applicable. The Zend documentation was up to date, which was nice, but I got so turned around from reading the wrong information that the documentation didn't help. Like, at all.

Let me touch on that point for a minute; Zend changed how the Auth component of the framework worked around version 1.8. There were all sorts of tutorials and example code out online, and some even on Zend itself, but Zend essentially made all of them obsolete through a minor update release.

It's not like this was a 1.0 to 2.0 release. This was a 1.7 to 1.8 release. It's always been my understanding and experience that you don't want to make large, sweeping, changes like that for a minor release.

Fuck, just think of all the code that had to be rewritten so the program would work with the latest version of the framework. Must have pissed off a bunch of people...

I struggled with the Auth functionality for a couple days. A couple full and long days. Understand, I'm not new; it's been a while since I've had any issue with php.

So, I did the only reasonable thing; I walked away. Not from the framework or the project, just the part I was working on. I decided to tackle the issue of form layout. Remember, I needed to have complete control over how the forms were structured. This, too, was an exercise in patience in frustration. This time it was all me just not knowing something; I eventually found my answer on Stack Overflow.

But, as I was working on the form question I noticed I wasn't having much fun working with the framework. This led me to give serious thought to my choice of Zend Framework. Why was it so popular? What was I missing? Why didn't I get that "joy!" everyone kept talking about when working with it? Hell, why was I even using it?

I don't think I did enough research. This is definitely my fault; I should have done more research into my options and try to find something I enjoyed working with instead of the one that was more compelling. Besides, I can still use individual Zend Framework components without using the framework as the core.

Looking at my alternatives I think my best options are going to be either Symphony, CakePHP or even CodeIgniter. I had used CakePHP a couple years ago and wasn't even a little impressed. This probably had more to do with my reluctance to use a framework than anything else. I hate to say it, because it's kind of a trite argument, but at the time a framework to me was a directory structure with a couple helper classes. I was not impressed.

The point is that I have to do some serious research and testing now. I have to put a critical eye on all those frameworks (even Cake; 2 years is a long time) and find the one that allows me the most control and gives me the most pleasure to work with. Something I should have done anyway.

PHPLinq: PHP Language Integrated Query

Posted in Code, Programming on August 21st, 2009 by Eric Lamb – 2 Comments

I admit, sometimes I get language envy. Don't get me wrong, I love php, but every once in a while I'll hear about a feature in another language that just gets me going. The C# Reflection implementation, IntelliSense and LINQ immediately come to mind. I really want to get a look at these features and play with them but, alas, I just haven't yet. (Honestly, I'm just not that good at C# yet. Soon though, very soon.)

PHPLinq: PHP Integrated Language Query

BTW, yes I know php has Reflection but, the way I understand it, the .NET Reflection implementation kicks the crap out of the php one. Get over it.

Now it looks like there's a quasi-sorta-kinda implementation of LINQ done in PHP with the totally original title of PHPLinq. It's not a true port of LINQ, being that it deals with strings and isn't done at the language level, but it's still pretty compelling in it's own right.

If you don't know what LINQ is all about it stands for Language Integrated Query and is a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities.

That basically means it allows you to query stuff, similar in concept but different in practice to how you would query a database. PHPLinq works well for searching an array of objects using a SQL like 0bject syntax.

There's a great tutorial on Switch on the Code that goes into some detail on how to use PHPLinq with a good example of usage. To help pique your interest the below should give you a reason to check it out; the code below searches an array for all the strings in an array with a string length less than 5 characters:

<?php
// Create data source
$names = array("John", "Peter", "Joe", "Patrick", "Donald", "Eric");
$result = from('$name')->in($names)
            ->where('$name => strlen($name) < 5')
            ->select('$name'); 
 
print_r($result);
?>

Notice how it's laid out like a database abstraction? Pretty cool, right?

The really exciting part about PHPLinq is that it can work off of lots of data sources like XML, RSS and a database table (more on this in a minute). Here's an example taken from the unit tests for PHPLinq:

<?php
$rssFeed = simplexml_load_string(file_get_contents('http://blog.maartenballiauw.be/syndication.axd'));
$result = from('$item')->in($rssFeed->xpath('//channel/item'))
			->orderByDescending('$item => strtotime((string)$item->pubDate)')
			->take(2)
			->select('new {
							"PostTitle" => (string)$item->title,
							"PostAuthor" => (string)$item->author,
							"MetaData" => new {
												"Url" => (string)$item->link,
												"Guid" => (string)$item->guid,
												"PostDate" => strtotime((string)$item->pubDate)
										  }
					  }');
 
print_r($result);
?>

The above will return only the post title, author and whatever meta data the feed contains.

When I think about the database option I get a headache though; I can't, for the life of me, think of when I would want to use PHPLinq to search a return database call. If I understand right the flow would work as a) grab all database rows and b) use PHPLinq to search through those rows.

This idea goes against everything I've ever known about SQL and resource management. It's sacrilegious to grab all the rows in a table and just plain silly to use a separate layer of the program to parse those results. What possible argument could there be for not using plain old SQL (or even a SQL generator) and just let MySQL do the heavy lifting.

Admittedly, I haven't found any code samples for how the SQL portion would work so I may be way off base here.

Either way, PHPLinq is still a compelling module to help sifting through array sets and XML. It should make searching files a lot easier too. Even if that's not enough PHPLinq is still worth checking out if for no other reason an example of an interesting idea done in php.

WP-Click-Track 0.6: Going Native

Posted in Programming on August 19th, 2009 by Eric Lamb – 0 Comments

After about a month of working on the plugin around 20 hours a week I'm happy to announce the release of wp-click-track 0.6. This release includes a couple small bugs as well as one really bitch of a bug that's been with the system since the release of 0.1. To make it worthwhile to upgrade there's also a few features that have been requested and a couple I've personally been wanting for a while.

WP-Click-Track 0.6: Going Native

I have to admit, I didn't think this update would take as long to deploy as it did. I don't have a day job so, my time being free, I honestly thought I'd be done in a couple days. Lesson: estimates are hard even for your own projects.

One of the reasons was caused by the addition of a dedicated menu instead of the single entry point. Because the functionality has grown to the point of a full CRUD program the old menu style just wasn't that useful anymore. Making the change required paying down a lot of built up technical debt in the system.

Another new feature is a search system for the links. I've been planning on this one for a while but because there was changes to the database, and I wasn't really confident in deploying those changes until now, I've been sitting on the addition. The system will attempt to convert  the link table to the MyISAM format and, if it can't, will use a basic LIKE search syntax as a fallback. This should really help those with bunches of links.

And, much to the delight of many I'm sure, this release includes a couple sidebar widgets for making the top links and "todays" click count data public. These work as you would expect a widget to work; they'll have to be activated from the Appearance->Widget administration interface as any other widget should.

Finally, as far as the features and additions go, the interface has been changed to match the native WordPress interface. This should keep the experience of looking at the reports a little more fluid and less jarring.

The best thing about this release isn't a feature but a single bug fix. For a while now (too long really) there's been an issue that could keep certain links from being tracked accurately if the link didn't open in a new window on FireFox 2&3. This was a bitch of a bug that was difficult to isolate and fix; but it's finally, finally, dead.

In anticipation of 0.7, which focus primarily on l10n and i18n, 0.6 is ready to be localized. (BTW, if anyone is willing to localize the plugin into a different language please drop me a line.)

As always please report any bugs or issues with wp-click-track; I'll get them fixed ASAP.

FULL TEXT Searching In MySQL

Posted in Code, Programming on August 17th, 2009 by Eric Lamb – 5 Comments

I've been wanting to add a search feature to wp-click-track for a while now. After almost a year of writing 150 posts I have a lot of links; so many in fact that it's getting a little tough finding the links I want when I want them. I've written a few search engines in my time (some actually pretty good and some that just plain sucked) and thought this would be a simple addition to the program.

Boy, was I right.

php & MySQL Full Text SearchingText

Real quick; I'm going to be referencing a MySQL table below. Here's the SQL to create that table:

CREATE TABLE tracking_links (
`link_id` int(10) NOT NULL auto_increment,
`link_title` varchar(255) NOT NULL default '',
`link_desc` text NOT NULL,
`link_destination` varchar(255) NOT NULL default '',
`link_total_clicks` int(10) NOT NULL default '0',
`link_unique_clicks` int(10) NOT NULL default '0',
`creation_date` datetime NOT NULL default '0000-00-00 00:00:00',
`last_modified` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY  (`link_id`)
)

The traditional, no frills, way easy path, would be to build a basic "LIKE" query and attach it to a single text field. The queries would then look like this:

SELECT * FROM tracking_links WHERE link_title LIKE '%$_search%'

If you don't already know; the above query would match all the links with a title that has the string $_search anywhere within the column.The percent character (%) is a wild card; sandwiching $_search like it is basically says "Grab me everything that has this string anywhere within the column".

The above is the lowest of the low when it comes to elegance of design and sheer awesomeness though. It's pretty much the amateur version of a search mechanism.

For one thing performance is going to be an issue when dealing with a lot of rows in the table. The speed on a query like the above, even with an index on the "link_title" column, is going to crumble once  you get more than a couple hundred thousand rows because the MySQL has to do a full table scan.

Another issue is that relevancy is completely absent. There's no way to remove elements or, really, do any boolean matching. You're going to get results that just seem... off.

If I want to search against multiple columns the SQL just gets horrifying:

SELECT * FROM tracking_links WHERE link_title LIKE '%$_search1%' OR link_destination LIKE '%$_search2% OR...'

And then there's the accompanying form for a query like the above. Traditionally, it would be x form fields for each column; in the case of wp-click-track that would be 3 individual fields. This would pretty much destroy the plugin interface or, worse, require a separate, dedicated, search page.

The answer to those problems is full text search. According to Wikipedia :

In a full text search, the search engine examines all of the words in every stored document as it tries to match search words supplied by the user.

This is a difficult concept to grasp, especially for someone coming from the LIKE camp; I know it took me a little bit to get it fully. Here are a couple notes that should help:

  1. String to search must be longer than 3 characters long.
  2. DB Type must be MyISAM
  3. Don't try for individual search fields
    ex: SELECT * FROM table WHERE col1 = '$col1' AND col2 = '$col2'
    instead
    Have all fields setup as a single Fulltext field.
    ex: SELECT table.* , MATCH (col1, col2, col3) AGAINST ('+( $text1) -($text2)') AS Score FROM table WHERE MATCH (col1, col2, col3) AGAINST ('+( $text1) -($text2)' IN BOOLEAN MODE)
  4. IN BOOLEAN MODE is required for queries with the '-' attribute.
  5. Algorithm for relevance is:
    w = (log(dtf)+1)/sumdtf * U/(1+0.0115*U) * log((N-nf)/nf)

Using fulltext searching allows your site users to do Google style searching like so:

+php -mysql +sqlite +temp*

The above search query breaks down to "Grab everything with "php", without "mysql" but with "sqlite" and any word that begins with "temp". Pretty snazzy and useful if your users are savvy in how to search effectively. Hell, even without knowing how to perform boolean searches the above is still useful and makes your code way cleaner.

In order to implement fulltext searching the table has to be setup with the MyISAM engine and a fulltext index has to be defined. To change a table to use the MyISAM engine just run the below query:

ALTER TABLE tracking_links ENGINE = MYISAM

To add a fulltext index you create it like so:

ALTER TABLE tracking_links ADD FULLTEXT search_index (link_title,link_desc,link_destination)

The complete fulltext search query for the above query (+php -mysql +sqlite +temp*) example would look like:

SELECT *
FROM tracking_links
MATCH(link_title,link_desc,link_destination) AGAINST('+php -mysql +sqlite +temp*' IN BOOLEAN MODE);

There's one other feature worth mentioning; the Score option. The Score

SELECT *,
         MATCH(link_title,link_desc,link_destination) AGAINST('+php -mysql +sqlite +temp*' IN BOOLEAN MODE) AS SCORE
FROM tracking_links
         MATCH(link_title,link_desc,link_destination) AGAINST('+php -mysql +sqlite +temp*' IN BOOLEAN MODE);

The above query will return all the rows as well as the relevance of the column to the dataset. On initial inspection the number won't make much sense; it's usually something like 0.9843949302 and 2.9408509384 which is, admittedly, pretty useless by itself. But, using a simple formula you can turn it into something pretty relevant:

Using the above code against a SCORE of .9823475 results in a $score of 98.2% which is a simple way to let your users know the result is relevant.

As the above, hopefully, demonstrates FULL TEXT searching with MySQL is easy and adds an extra layer of awesome and fun to an application.

Living in Two Worlds

Posted in IT, Programming on August 12th, 2009 by Eric Lamb – 0 Comments

I generally consider my professional persona to be a software guy first and a hardware guy second. My first passion is code, through and through, but I have also spent a good deal of my time performing the day to day office IT stuff and, usually, I have a good time doing it. More than that though; I've always found that working on the hardware is a good way to know how my software is going to interact with the hardware. Read: It makes me a better programmer.

Blow My Mind

Needless to say, I have some ideas about hardware setup and deployment; a philosophy if you will. I try to be pretty humble about it but I couldn't help but be reminded of this a when, a few weeks ago, I was listening to Stack Overflow podcast #59.

This one was cool; they had Damien Katz on who, if you don't know, is the creator of CouchDB and used to work on Lotus Notes (back when the Internet didn't matter). Smart guy.

(BTW, if you don't know who he is I highly recommend you read his blog. Start with this post called Signs You're a Crappy Programmer.)

Anyway, like I said; good podcast. Up until the end that is when Joel and Jeff completely blew me away with the following dialog when they were discussing a question on ServerFault about disabling your page file (around 1:01:44 in the podacast):

Joel: There's a problem that we've always had, and it's more common, I hate to say this, it's more common among Unix system administrators than Windows system administrators, which is, they get the thing out of the box, they get the operating system out of the box, they install it, and then they're going to want to do 47 things to that system before they can use it. Mostly removing things that were put there that they don't understand.

So they have this attitude that's like, "What are all these services that are running; I'm going to kill all of these services and then my server will be really fast."

And then, all of a sudden, ok, it works for a while and then you go and install FogBugz, and it doesn't run because some basic service, that everybody else has, has been removed, severely deleted from the operating system, by some system administrator that thinks they know better but, really doesn't.

Jeff: You sound really bitter about this.

Joel: I am bitter because it's all over tech support calls. It comes from people who are like... There is generally a philosophy that security flaws come from things, often come from things, that you don't even realize you have running. And that probably shouldn't be running.

I had to rewind the podcast when I heard that part. Was Joel really suggesting that we leave the default services enabled on an operating system? Did I just hear Joel Spolsky imply it was bad to disable and remove unneeded services from a computer?

Yup, I think I did.I also don't think it's the best idea to keep the default configuration on a server. Why? Because an OS is released with the goal of a good out of box experience not security. For example, does your Linux web server really need CUPS running? Does your Windows server really need Windows Media Player to start every time you start the thing?

Now I'm totally willing to accept that I'm being naive; this is knowledge gained from experience not instruction. But it'd have to be a compelling argument.

But, to be clear, you disable services and programs, not to improve performance, but to improve security and reliability. (Performance improvement should be a side effect in my opinion.) The thing I think Joel might be missing is that he's more than likely dealing with some pretty busy system administrators. They probably did something to keep FogBugz from working, and forgot what it was, so they called support.

Hiding From Legacy Code

Posted in Brain Dump, Programming on August 10th, 2009 by Eric Lamb – 0 Comments

My career history hasn't been what could compare to the typical technology path. I started out in desktop publishing and slowly made my way through the ranks learning all about this crazy world of web development. True, I had been into computers and had written a quite a few programs in BASIC and even done a little Perl and ASP scripting, but I never took it seriously in any real way. I certainly never thought I'd make a career out of it.

Working Effectively With Legacy Code

The point, is I never did the support desk thing (this definitely seems like something a majority of programmers and IT guys did).

Hell, I never even had to maintain an existing system until my third year of working. I spent the majority of my career, up to the point I first encountered a legacy system, working with teams on new systems. This shouldn't imply that I was unfamiliar with code written by other developers; I've always made it a practice to use existing code whenever possible. I just hadn't had to maintain one for a while. Obviously, my life was puppy dogs and rainbows year round.

Today I generally view maintenance work as something to be done with care. If a system is in production, and I didn't write it, that system should be handled with respect when making modifications. Refactoring is strictly off limits unless a) I know the code inside and out and significant pain of future updates is sufficiently unbearable, or, b) there's an immediate need to make the change along with the time to get to know the system. There's obviously exceptions but, for the most part, I need to know the code ahead of time and there has to be some benefit for the change.

There's a new thought I've been struggling with for the last couple weeks; all programming is maintenance programming.

Bill Venners: You say in your book, The Pragmatic Programmer (Addison-Wesley, 1999), that "programmers are constantly in maintenance mode." Why?

Dave Thomas: All programming is maintenance programming, because you are rarely writing original code. If you look at the actual time you spend programming, you write a bit here and then you go back and make a change. Or you go back and fix a bug. Or you rip it out altogether and replace it with something else. But you are very quickly maintaining code even if it's a brand new project with a fresh source file. You spend most of your time in maintenance mode. So you may as well just bite the bullet and say, "I'm maintaining from day one." The disciplines that apply to maintenance should apply globally.

Andy Hunt: It's only the first 10 minutes that the code's original, when you type it in the first time. That's it.

The above hits especially hard now that I'm a full time freelance programmer. I've been BUSY lately (which is why I haven't posted much in the last week) working on "touching up" existing sites. There's  a crap ton of work out there for a programmer who can dive into an existing codebase and make changes.

The crimes against humanity I've witnessed in some of the code I've looked at in the last week are just awe inspiring. There is code out there that was created a few years ago, that have just been edited and changed and modified and customized (and on and on and on) by too many programmers with too different design philosophies that now the code could make your eyes bleed. It's kind of sad when you think about it.

I've mentioned before about the importance of code structure and formatting and I think it bears repeating:

On the other side though, we also have to write code on behalf of our clients. We give them code that they paid us to do so it’s pretty much a foregone conclusion that the client is going to go through the code. If we hand them crap they’re, obviously, going to think we suck. That’s no good for anyone.

It seems like such an obvious thing to write good, clean and well formatted code, that it’s a little surprising how much bad code is out there.

It's kind of depressing if you think about it; all the half hazard changes being done to an existing codebase starts a snowball effect of charges escalating and costs raising. Put simple; the more mods that are done over time the more cost gets associated with subsequent updates.

To help alleviate this for my clients (at least) I think it's important to work within the existing formatting and coding style for any legacy code I touch. It's definitely a pipe dream to think everyone should (or would) but, for me, it seems the least I could do.

What's In Your Toolbox?

Posted in IT, Programming, Servers on August 05th, 2009 by Eric Lamb – 1 Comments

One thing almost all computer users have in common, regardless of vocation, is that we use the computer to achieve some goal. The actual goal doesn't matter so much as the fact that we're using the computer to do something that, otherwise, we wouldn't be able to do. To do so though we use various tools that are, usually, purpose built for the task.

Let's be honest; without the tools we would be useless.

What's in your Toolbox?

Personally I love my tools; specifically, I find developer tools to be some of the most interesting and fun toys available. I don't want this to turn into a fanboy post but, in the interest of honesty, it just might. You have been warned...

What's in my Web Developer Toolbox?

My toolbox is full of programs that are purpose built to help every step along the way for building Internet applications. Over the years, like pretty much all developers I'd guess,  I've come to rely on the below tools to ease the pain of development as much as possible. I totally vouch for these tools.

Version Control

This one's crucial. If I had to rank these (and I really don't plan to) version control would be at the top of the list. There's a whole slew of options available but, for me, version control starts and ends with Subversion.

Yes, there are all sorts of hype surrounding GIT and Mercurial but, because right now, I work alone my needs are way too simple for anything like distributed version control. Nope; just give me Tortoise and an SVN URL, with credentials, and I'm a happy camper.

Local Development Web Server

Once upon a time the thought of using a local development web server was heresy to my style and philosophy. Now that I've been using one for the last year I have to admit I was dead wrong. Dumb even.

Previously, I would always use an external Linux server for all my development. The idea was that since the finished site would be hosted on a Linux server it was important to develop the site in the same environment. There are 2 big problems with this approach though; one is that the project is more likely to be dependent on the environment which can make relocation a problem, and two, is that continued progress on the project requires a connection to the Internet.

On the other hand, developing your projects on a local machine requires finesse and forethought to ensure porting the site from one environment to another doesn't lead to anarchy. There's also the knowledge and insight gained from setting up an environment by hand; there's so much to gain from doing this it's just silly not to without some edge condition.

Text Editor

Only masochists use Notepad for text editing. In today's world of fast CPUs and large amounts of RAM it's really hard to believe anyone would use Notepad for anything other than the most basic of basic editing tasks. If you plan on having a file open, for editing, for any extended period of time it's just stupid (yes; STUPID) to use it.

Instead, I prefer EditPlus for all my text editing needs. Why? For one killer feature; a right click context menu item. Right click over any file and choose EditPlus to open the file for editing; it makes working very fluid and continuous.  It even handles files in the hundreds of MBs with ease.

There are other options for a text editor (Notepad2 comes to mind) but EditPlus is tough to beat.

Database Tools

Sure, a command line tool is perfectly adequate for administering a database server. The problem though is that I develop on a Windows machine and not using a GUI tool for database administration is kind of silly. It's like the people who only use VIM for text editing; it's like trying to prove a point against all logic.

Using MySQL, the easiest, and most familiar tool, is phpMyAdmin; but for remote administration phpMyAdmin starts to break down. Instead, you can't beat the MySQL Administrator. It offers all the functionality as phpMyAdmin as well as a slew of advanced functionality like the ability to create stored procedures (which you should never, ever, do) and functions.

Remote Connectivity

Since pretty much everything I work on has to go somewhere and I usually need to connect directly to a server for administration I need tools that'll allow me access. These tools really come down to 3; FTP, SSH and RDP.

For simply moving files between servers FTP or SFTP is obviously the choice. There's bunches and bunches of options when it comes to FTP clients but I've been using CuteFTP for years and, pretty much, I swear by it. Yes, it's a paid product but CuteFTP is also low impact, easy to use and, more important, doesn't get in the way of my productivity.

And then there's system administration which requires full control and access to a server or computer.

Linux has SSH which requires a small client utility. There's a shitload of options available here but they're all pretty similar so there's not much difference between using, say, PuTTy or SSH Secure Shell Client (or any of the myriad other SSH clients out there). You just need to have one.

For Windows as far as I'm concerned there's really only 2 options; Remote Desktop Connection (RDP) and VNC. For ease of use and quality of experience RDP is the way to go. HINT: There's a setting to allow mapping of HDDs on the client machine to the server for easier file transfers.

Virtual Machines

In my opinion there's been no bigger advance in quality assurance (QA) then the advent of the virtual machine (VM). QA probably wasn't even a goal when VMs were first conceived but, boy, have they filled the gap well.

I've already gone into detail about my choice of VM tool as being Virtual Box:

VirtualBox handles the resource detail pretty elegantly; in that it doesn’t use the resource until it needs it. This means that instead of instantly having 10GB of your hard drive used up VirtualBox will only use the amount already taken. You can tweak the settings for a VM whenever you want so you can get just the right mix.

Web Browsers

You need pretty much every modern browser under the sun here. Um... duh?

So, there you go; those are the primary tools I use for web development. There are definitely some other tools I use that didn't make the list (RegexBuddy, Photoshop and diff tools come to mind) but I didn't feel they deserved mention because of how rare they're used.

Did I miss anything else?

  • Subscribe: Entries | Comments
  • About Me

    Email Email
    Twitter Twitter
    310.739.3322
  • Categories

    • Brain Dump
    • Business
    • Code
    • IT
    • Programming
    • Rant
    • Servers
  • Archives

    • February 2012
    • October 2011
    • August 2011
    • July 2011
    • June 2011
    • May 2011
    • April 2011
    • March 2011
    • February 2011
    • January 2011
    • December 2010
    • November 2010
    • October 2010
    • September 2010
    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • January 2010
    • December 2009
    • November 2009
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
  • Advertisement

Copyright © 2008 - 2013 Eric Lamb - All rights reserved