Made of Everything You're Not

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

Archive for November, 2009

Simple Project Profiling With PHPLoc

Posted in Brain Dump, Programming on November 24th, 2009 by Eric Lamb – 2 Comments

One of the most natural things to do while being an obsessive programmer is focusing on the minutia. Not only do our projects have to perform and function to our standards but they also have to be structured "just so" with just the right comment style and just the right indentation to space ratio (4 of course!). Point being that, for me, it's ridiculously easy to spend time and energy focusing on, what amounts to in the end, as trivial. I was reminded of this while playing around with the latest release of PHPLoc (1.40).

Photo: Grahambones

PHPLoc is a project by Sebastian Berman that measures the size of a PHP project. In a nutshell PHPLoc is a project analyzer that shows details like amount of classes, files, directories and total Lines Of Code (PHPLoc get it?) to name a few features. It's ran from the command line and I had no issue getting it to work on Windows (huge plus for quality IMHO).

According to the Git repository:

phploc is a tool for quickly measuring the size of a PHP project.

The goal of phploc is not not to replace more sophisticated tools such as phpcs, pdepend, or phpmd, but rather to provide an alternative to them when you just need to get a quick understanding of a project's size.

PHPLoc works as a PEAR module (requires PEAR installer version 1.8.1 at least) and as such is really easy to install. There's some great instructions on the Git site that I had zero issues with (outside of having to update PEAR) so I won't go into detail here.

Here's an example of the output when ran against a Zend Framework 1.9 distribution:

C:\php>phploc --count-tests C:\ProjectFiles\ZF
phploc 1.4.0 by Sebastian Bergmann.
 
Directories:                                        393
Files:                                             1856
 
Lines of Code (LOC):                             372292
  Cyclomatic Complexity / Lines of Code:           0.11
Comment Lines of Code (CLOC):                    173793
Non-Comment Lines of Code (NCLOC):               198499
 
Namespaces:                                           0
Interfaces:                                          94
Classes:                                           1758
  Abstract:                                         155 (8.82%)
  Concrete:                                        1603 (91.18%)
  Lines of Code / Number of Classes:                167
Methods:                                          12377
  Scope:
    Non-Static:                                   11517 (93.05%)
    Static:                                         860 (6.95%)
  Visibility:
    Public:                                        9886 (79.87%)
    Non-Public:                                    2491 (20.13%)
  Lines of Code / Number of Methods:                 23
  Cyclomatic Complexity / Number of Methods:       2.78
 
Anonymous Functions:                                  0
Functions:                                            0
 
Constants:                                         3361
  Global constants:                                   1
  Class constants:                                 3360
 
Tests:
  Classes:                                            2
  Methods:                                            0

As you can see, PHPLoc gives some really nice insight into a project. I have to admit I'm more interested in the OCD satisfaction than the practical reasons but it's still cool. Definitely check it out if you're looking to get some interesting though completely trivial information about your project.

Amazon Associate Program

Posted in Business on November 11th, 2009 by Eric Lamb – 0 Comments

A friend of mine recently pointed out to me that my writing seems to say I'm against money; as if I don't appreciate profit or something. To be clear; I'm not against money. I love money. If left alone with money... well you get the idea smile

I just think the accumulation of it needs to be done responsibly and with the consumer in mind. Rarely does this happen and, to date, I haven't really wanted to try and monetize this blog. Then I lost my job and while I'm not poor or anything I do make all my money directly off of me and my work. Keep in mind, I don't have a day job and I'm not going to get one.

Amazon Tour

At the moment, I don't believe that advertising is a good fit for me or this blog. Personally, I always lose a little respect for an author when I've never heard of them and their site is littered with ads all over the place. Nope. There's no way I'm doing that right now. There are other ways to make a little, very, very, little scratch on a blog though. Every little bit helps. Right? Right?

One such option I'm exploring is the Amazon Associate Program.  According to the Get Started Tour (which is actually worthwhile to take a read through):

Amazon Associates is one of the first online affiliate marketing programs and was launched in 1996. The Amazon Associates program has a more than 12 year track record of developing solutions to help website owners, Web developers, and Amazon sellers make money by advertising millions of new and used products from Amazon.com and Endless.com. When website owners and bloggers who are Associates create links and customers click through those links and buy products from Amazon.com or Endless.com, they earn referral fees. It’s free to join and easy to use.

There are quite a few options to start earning a commission on referrals but the only one that's personally appealing to me, insofar as a blog goes, are the text links. The text links work for me because they can be placed in posts when referencing relevant material. Basically, if I'm linking to Amazon anyway why not earn a commission? Obviously, it'd be a mistake to abuse this by placing links inappropriately but staying honest is easy smile

I especially don't approve of those widgets that are all over certain sites. I'm willing to bet you can think of a site that does that right now. The problem is that, frankly, they're ghastly and really take away from the experience. Nothing screams amateur desperation with suspect motives than a site with those little warts on it. Seriously, stay away from those boogers.

Amazon states that it's possible to make up to 15% on referrals if a transaction takes place. As always, it's a good idea to take a read through their Operating Agreement to get an idea of what you're really in for. If you do you'll see that it's not quite so black and white. Not to take away from the program or anything it's just that like everything it's all in the fine print.

I am encouraged by the recent "success" Stack Overflow has had with the program (with success meaning people clicked on the links):

But in the meantime, since we had our fancy-shmancy Amazon Affiliates account set up, we might as well put it to good use. Even way back in the original Stack Overflow beta, people were proposing that we convert any Amazon book links to Stack Overflow amazon affiliate book links. I was hesitant to do this at the time, but given our failure, I was licking my wounds. I was willing to give it a try. Particularly since the community seemed totally OK with the concept.

So, onward to plan B: we now auto-insert Stack Overflow affiliate info into any amazon book links posted on Stack Overflow. Oh yeah, and here’s the kicker. These silly little rewritten text links work 200%-300% better than our custom amazon book ads!

Go figure.

Obviously, I don't have anywhere near the penetration and exposure that Stack Overflow does; not what I'm saying. But I do think their success indicates 2 things; a higher acceptance of Amazon links compared to the run of the mill advertising and a more engaging intrusion to the experience among their, primarily, developer audience (which is my target audience).

I'm always happiest when I can make a buck and not compromise my integrity.

Thoughts on the Akelos PHP Framework

Posted in Programming on November 09th, 2009 by Eric Lamb – 1 Comments

I recently took  on a project that was a failure for the original developers. It was the usual story of outsourcing a project and just getting hosed on cost and timeline (my bread and butter). I was asked to take a look and see if I could finish off the project ASAP. Looking under the hood I found that the site was using a framework I hadn't heard of called Akelos.

Akelos

Akelos touts itself as a port of Ruby on Rails (RoR) to PHP but, frankly, I think that's mostly marketing. Hell, even in the footer disclaimer on the Akelos site they minimize the R0R relationship. Not that that's a bad thing per se (I wouldn't want to be associated with RoR at the moment either).

Expecting a clusterfuck of code I was actually a little surprised to find the use of a framework. Granted, the previous developers weren't using the framework very well, or in any optimal way, but it was still nice to see. Of course that meant I had to learn Another Fucking Framework but what the hell; I like to learn.

According to the site:

The Akelos PHP Framework is a web application development platform based on the MVC (Model View Controller) design pattern. Based on good practices, it allows you to:

  • Write views using Ajax easily
  • Control requests and responses through a controller
  • Manage internationalized applications
  • Communicate models and the database using simple conventions.

Your Akelos based applications can run on most shared hosting service providers since Akelos only requires that PHP be available at the server. This means that the Akelos PHP Framework is the ideal candidate for distributing standalone web applications as it does not require any non-standard PHP configuration to run.

It seems to work similarly to most MVC frameworks, like the Zend Framework, in file structure and hierarchy which definitely eased some of the pain. Unfortunately, I can't really speak to the Ajax ease of use because, well, like I said above the previous developers were not so much on the... ummm, good side of the coin.

There is a video which is definitely worth checking out; it'll walk you through the basics of how to use Akelos to generate your project. While there's a bunch of options for generating your project it does come off a little schizophrenic in that it uses both command line and a web interface depending on what you're trying to do.

One thing I was impressed with was the localization functionality. Basically, it works like most do, using translate files (read; arrays), which by itself isn't that impressive, but I really appreciate the way the system uses the browser locale value if one isn't selected. Nice.

One thing that really didn't impress me was the absolute NEED for a database connection; NO MATTER WHAT. That's just confining and comes across to me as lazy and wasteful. Seriously, why would this be a good idea? Does no one care about performance anymore?

It's unfortunate that Zend Framework and Symfony are the juggernauts they are; I know I wouldn't want to go against them. It's got to be tough building a competitive framework with those two being as rad as they are.

All and all Akelos isn't a bad framework and it does have potential. The Ajax readiness is intriguing and the file structure and hierarchy is intuitive (if you've used any other MVC framework )so it was easy to figure things out. There's also the plugin architecture; I do enjoy me a good plugin architecture.

But I don't think the relationship to Ruby on Rails is as good a thing as the developers of Akelos think it is. To be honest, I found the similarities between the two jarring due to how uneven the implementation was. Plus, similarities to RoR might have been a good marketing hook 2 years ago, these days it's just another bullet point. Add to that my personal bias that PHP should function like... you know... PHP.

Point being, I like RoR and if I want to code like RoR I'll use RoR, not PHP, thankyouverymuch. Add to that my dislike for code generation (and Akelos has a lot of code generation) and I just don't care anymore.

So for me, Akelos is a fail. Not because Akelos sucks and not because Akelos isn't good (though it does suck a little and it's not all that good). More because of design decisions that can't be helped that disagree with how I like to work.

Zf = 1
Akelos = 0

http://framework.zend.com/

Introduction to jQuery UI

Posted in Code, Programming on November 06th, 2009 by Eric Lamb – 2 Comments

Building the fancy, web 2.0 / Ajaxy, user interfaces for a web application we've all come to expect is, frankly, a pain in the ass. Depending on the JavaScript library you're using there's usually some addon library to extend the functionality for UI which helps make it easier and ease the pain. If you're using jQuery (and to be honest I'm more of a Prototype guy) a good library is jQuery Ui.

JQuery UI

According to the official site:

jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library. Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code.

I only ran into it because of an update to WP-Click-Track and Wordpress uses jQuery so I kinda had to. Not that it's a bad thing; I like jQuery a little bit more because of jQuery UI.

One of the really cool things about jQuery UI is that there's an online tool to generate a custom download specific to the project. Having worked with JavaScript libraries for a while I appreciate the customization and convenience of having the smallest footprint as possible. Kudos to them on that.

There's also a Theme Builder that gives a good overview of what's available by default along with some preset themes to test; there's a good deal of widgets there to work with. Almost, almost, makes me want to start a project with it.

jQuery UI - ThemeRoller

Implementation is really elegant too; if you know how jQuery works it'll be pretty obvious. Otherwise take a look at the below for creating tabs:

<div id="tab-jquery-id">
<ul>
<li><a href="#tab1">Tab 1</a></li>
<li><a href="#tab2">Tab 2</a></li>
<li><a href="#tab3">Tab 3</a></li>
<li><a href="#tab4">Tab 4</a></li>
<li><a href="#tab5">Tab 5</a></li>
</ul>
<div id="tab1"></div>
<div id="tab2"></div>
<div id="tab3"></div>
<div id="tab4"></div>
<div id="tab5"></div>
</div>
 
<script type="text/javascript">
//<!|\.)/));
	$("#tab-jquery-id"+(needs_jquery_hotfix ? ">ul" : "")).tabs({
		selected: 0
	}); 
	$('.tab5:last').show().removeClass('tab5');
});
//]]]]><![CDATA[>
</script>

As you can see there's not much there in so far as design or class decorators go; most of that's handled by jQuery itself as well as the generated css. The only thing to really worry about is adding the wrapper div id in the bottom JavaScript. Still, not a bad thing.

This, of course, barely scratched the surface of jQuery UI but it doesn't get much more difficult. If you're using jQuery for a library and you need to make something cool it's definitely worth checking out.

Mea Culpa Twitter. Mea Culpa…

Posted in Brain Dump, Business on November 04th, 2009 by Eric Lamb – 0 Comments

Anyone who knows me knows I'm not a fan of social networks. Frankly, I find participating in social networks to be a false representation of social behavior;  a farce I just don't have the desire to humor. Not to get too preachy here but, well, this is my blog so na-na-nana-na:

Mea Culpa Twiter. Mea Culpa...

The way I look at social networks is as time sinks with little practical use compared to the maintenance and care required for the account. Not that I find them useless though. I had spent the last 4 years (around) working for a social marketing agency and have personally witnessed the benefits of social networks in building brand awareness and loyalty. But the work required entailed a dedicated, college educated, person and a couple student interns working 40 hours a week each to accomplish.

Me? I have shit to do thankyouverymuch. I want to spend my time producing ideas, projects and programs. I don't want to spend any time tending to a social network profile with ephemeral friendships and connections. But apparently Twitter is different. Michael Lop sums it up nicely:

Twitter is a social network, yes, but it’s a social network without the superpoke scrabtaculous zombie noise and, for that, I’m thankful, because I’ve got work to do. Yes, I could spend days tidying my profile and scrubbing my friends list, but to what end? I want to know more people, and sure, it’s interesting to see what they’re up to, but what I really want to know is what is going on inside their heads with a minimum of fuss.

So once again I'm late to a party acting like they're lucky to have me. I have finally, finally, begun to see the usefulness and benefits of Twitter. It's weird because I've been working so closely with Twitter for the last year interacting with their API and I never "got" it until recently. I'm actually a little embarrassed about this. So many of my personal friends are on Twitter along with my peers online and I was a little pompous about the whole thing. My Bad.

What ended up turning  my perspective around was the realization that Twitter didn't take any real effort. Outside of the marketing and announcement use (blog posts/updates, code release, project release, etc) all other status updates Twitter needs can be completely random thoughts along the lines of  a friendly conversation.

One key difference between Twitter and this blog is that this blog, and the discussion in it, are not in any way personal towards me or anyone else. But with Twitter, well, that can be, and probably should be, personal and a little intimate. Not completely understand, but the conversation appears to need to be a little more random and personal.

When I ask myself why I have this blog (and really why I think anyone has a blog), and if there's a requirement of complete honesty, career is definitely at the top of the list. Yes there's a love of writing and the conversation. But after that, career and ambition are what really motivates me to write and drives this site. (And yes ego has a little to do with it too but that's a whole other discussion smile)

So, we're really talking about a tool of promotion and marketing. I can understand that a little better for some reason.

So yes. I am on Twitter now and I actually like it. It's liberating to be so open (which doesn't make much sense to me at all... but there it is). If you're a fan of this blog (hell, even if you hate me and think I'm an idiot) you might want to follow me smile.

Welcome to The McDonaldification of Web Development

Posted in Brain Dump, Business, Rant on November 02nd, 2009 by Eric Lamb – 2 Comments

When I was a kid I remember McDonald's as having some of the best food and providing the best experience ever. Just the thought of going there was exciting. Breakfast, lunch and dinner; it didn't matter what meal it was. They went out of their way to, at least try, to make the experience fun for the kids. Yes, this was part of a plan to get the kids hooked to bring in the family (which it did in spades) but it was one of those rare strategies that was win-win for both the customer and company.

Welcome to The McDonaldification of Web Development

Fast forward 20 years (sigh...) and McDonalds and it's ilk are the lowest of the low when it comes to quality of service and product. It's been years since any fast food restaurant has provided me with an experience worthy of my money; the food is always horrible processed shit, and the service (even at the most basic of basic levels) is completely nonexistent. Hell, I can't remember the last time I was given ketchup with fries without having to ask for it...

Having worked in web development professionally for the last eight years I'm starting to notice a similar pattern in this industry. What was once an industry ruled by high profits for a job performed by professionals (mostly anyway) has quickly become an industry full of amateurs and scammers (mostly) trying to make as much money with as little thought to quality as quickly as possible. I've spoken before about the lack of quality I find in a lot of programmers I work with, and while I'm not saying it's the complete cause, I do think there's a link.

Oddly, I’m in the minority here. In my, limited, exposure to other programmers I can say definitively that the majority just plain suck; mostly because they refuse to grow and learn.

I’ve heard all the arguments before, “My weekends are mine”, “I work hard enough; I don’t have the energy”, and the best ever, “My employer should pay for this like Google does. Whah!!”. (I know Google doesn’t, in fact, do this but people still say it.) All just pure crap excuses for maintaining a level of competence just high enough to not get fired.

Bottom line: working 8 hours a day is just not enough to matter. If you think you’re a programmer and you don’t spend time improving your skills you’ll quickly, really quickly, become obsolete. It just doesn’t matter if .Net is going to be around forever and your employer won’t ever upgrade from 1.1; you’re a hack (and not in a good way).

Now that I'm an active freelancer I'm really, really, starting to see the differences. Time and time again I end up taking a meeting with someone who has just been worked over by others in this field. The stories some of these companies and people have are just appalling and I've heard some doozies. Worst of all, behavior like this tends to skew their perspective and they view all freelancers as suspect.  Too much of my time is spent building confidence in me as a professional it's really starting to become laughable.

It was all really quite the mystery until I recently reached out on craigslist to find a designer for a WordPress theme (I need to update this site BAD). I was pretty explicit that all I was looking for was a PSD file that I would personally turn into a WordPress theme but 4 out of 5 responses to the ad indicated that the respondent hadn't even read the post. Frankly, it was irritating wading through the crap and, obviously, automated responses.

This is troubling for a couple reasons. For one thing it basically indicates, to me anyways, that the person (company, freelancer, whatever) had very little regard for what I wanted, instead opting for a fastest gun approach. The number of emails I received immediately after posting my ad was around 20 and after reviewing each one it was obvious they were automated. I pity the individual or company who entertains these people.

The long term harm this can cause for other programmers (much less themselves) is completely short sighted. Crappy work begets a crappy experience for the client. Simple.

  • 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