CMI Web Studio Blog

Web 3.0 – Everything As You Know It Will Change

August 14th, 2010 0 Comments

Yes, if you’ve been keeping up, I’ve been preaching for several years now about Web 3.0. When I mention it, I usually get a look like a dog hearing a high pitched whistle. In fact, this might be the first place you’ve ever heard of this concept, so the reactions can be expected. Well, life as we know it in technology will be changing. In fact, we’re already seeing this change starting to take place. The fact is, once the global internet infrastructure can handle the demands of the what will be the biggest impact to technology since the computer itself, everything as you know it will change. Your daily life. Your daily routines. The way you interface and retrieve data. You’ve seen nothing yet.

Let’s take a look at some basic examples already following this inevitable future.

Browser-based Everything

Google is developing a variety of applications and programs that exist entirely within the browser. Their PAC-MAN game was a preview of what’s to come because it allowed in-browser play of a simple, lightweight video game that required no downloads and relied on pure HTML, CSS, and Javascript. At the company’s 2010 I/O conference, Google laid out its plans to develop “rich multimedia applications that operate within the browser” (according to this New York Times report on the conference). The company plans to sell in-browser web applications like photo editing software (imagine using a Photoshop equivalent entirely within the browser) that it will sell in a web applications store called the Chrome Web Store.

If our programs and applications are about to be folded into the browser, what will exist within the browser in ten years? Currency? Education? Consciousness? Why will anyone buy standalone computer software? They won’t. Our entire world will live and breath in a streaming real-time global internet infrastructure. Get ready…

Adobe Dreamweavers Future For Developers

August 1st, 2010 0 Comments

OK, Dreamweaver has reused the recordset code for too long, but let’s look at the big picture for Dreamweaver CS5. The easiest front end development tool that exists… period. No one can take that away. In CS5, Adobe has finally stepped up their development game a notch.

As a PHP developer, it’s the changes in Code view that really excite me. When you start typing a PHP script in Dreamweaver CS5, you’ll immediately notice a red marker in the line numbers column and an alert about a syntax error. Complete the line without errors, and the marker and warning disappear. Dreamweaver constantly checks your syntax on the fly. It doesn’t tell you what the errors are, but it highlights all lines with errors, making the debugging process much quicker. PHP code hints have also been improved dramatically. There’s full support for all core functions, constants, and classes (as of PHP 5.2).

Code hinting is also much smarter. Instead of needing to search through code hints alphabetically, Dreamweaver CS5 searches for substrings. This is helpful when you can’t remember the exact name of function or class—just type the part of the name that you remember, and Dreamweaver includes it in the list. You can also work out your own shortcuts. For example, if you press Ctrl+spacebar and type gesi, the code hints take you straight to getimagesize() by recognizing the ge of “image” and the si of “size”. And in case you don’t know how a function or class works, the official manual page—complete with code examples—appears as a tooltip at the bottom of the selected code hint.

For serious PHP developers, it gets even better. Dreamweaver CS5 is capable of code introspection, so it builds code hints on the fly for your own functions and classes, as well as for third-party libraries, such as the Zend Framework. The definition files don’t even need to be directly attached to the page you’re working in. With Site-Specific Code Hints, you tell Dreamweaver where your library files are located, and it scans them for you automatically.

So should you upgrade? Seriously, you’re asking that? YES… it’s the best version of Dreamweaver that’s existed.

The Untold Truth About PHP Programming – OO if you want slow and Pretty, Procedural if you want fast and profits

August 1st, 2010 0 Comments

The concept of object oriented programming is great. The application is even better. But like all philosophically powerful abstract concepts, object oriented programming generally takes longer to develop from scratch, cost more money for all parties involved to develop unless you’re reusing a large portion of past project code, and in almost all cases, will execute slower day to day than code written in a procedural fashion.

Wait, it get’s even more complicated…
Most business applications are mission, time and budget driven. Therefore, the chances that the business will spend extra money for quality code that can have a longer extensible life (which usually doesn’t mean much to a business man) to choose the object oriented methodology are slim to none. This is the reason why most software houses develop code using procedural methodologies with PHP that are grinding sites out daily.

So if you’re developing the next open source flavor of the month you’re hoping will turn into a wordpress or magento… then you have to use OO.  But for the other 99% of clients that want a website with perhaps content management, you might want to rethink things. There are several other factors to consider, but the table below should give you a very basic idea of how this works.

The following is a very brief, and by no means fully comprehensive, list of characteristics to consider when building applications with PHP 5 under either of the methodologies:

Procedural PHP Object Oriented PHP
Budget Tight Not so tight
Timeline Tight Not so tight
Will need to develop APIs / Web Services for other parties to interact with application Not necessarily Yes
Application Speed is Critical Yes, it is of utmost priority Speed can be sacrificed for quality of code
Time available for good documentation If it is well documented, procedural code is not that difficult to follow Documentation helps, but independence of objects doesn’t make it as critical as in the case of procedural
Independence of data and structure Somewhat critical Vital
Adaptability of code Medium Highly adaptable

OO versus Procedural Programming in PHP

August 1st, 2010 0 Comments

In PHP, unlike many other languages, you can choose between using an object oriented (OO) or a procedural approach. Most PHP programmers use a procedural approach by default, since web pages themselves operate in a very procedural way (this tag, then this tag, then this tag). Interspersing procedural code with HTML is more straightforward, and so PHP programmers often develop their own style, based on this approach.

If you are new to PHP, procedural programming is probably the only kind of programming you are familiar with. However, if you have been exploring the PHP community for best practices, by now you have probably seen posts in forums and newsgroups about “object bloat”. You have probably also seen tutorials on how to write object oriented code in PHP. You may have downloaded libraries that employ classes, and learned to instantiate their objects and use their methods. Yet it is quite possible that you have never really understood when, where, or why it is appropriate to use an object oriented approach.

There is a certain amount of ranting on both sides of the issue, and slogans such as “Objects are bad!” or “Objects are good!” are sometimes heard. This article does not attempt to decide between the two approaches and come up with a single “best practice”, but to explore the advantages and disadvantages of each.

Here is an example of a procedural program:

<?php
print “Hello, world.”;
?>

Here is an example of an object-oriented program that achieves the same objective:

<?php
class helloWorld {
function myPrint() {
print “Hello, world.”;
}
}
$myHelloWorld = new helloWorld();
$myHelloWorld->myPrint();
?>

Who Writes Code Like This?
In order to understand why this issue has become the subject of flame wars, let’s examine some extreme examples from both ends of the spectrum. First we’ll look at “the Procedural Fanatic” and then at “the Object Fanatic”. See if any of this sounds familiar.

The Procedural Fanatic
The Procedural Fanatic was criticized by his computer science teacher for not using a more abstract approach. His argument, “But it works!”, didn’t improve his grade. Later, he went on to a career writing drivers, file systems, packetizers and other low-level programs, where his focus on speed and terseness gained him recognition.

Extreme examples of the Procedural Fanatic go a step beyond rejecting objects, and criticize abstraction itself. They are always looking for ways to make things faster, and don’t care if nobody else can read their code. Often, they consider programming a competitive rather than a team activity. They like to enter obfuscated code contests. Their favorite languages besides PHP are C and Assembler. In the PHP world they might write PECL modules, contributing code that is efficient.

The Objects Fanatic
The Objects Fanatic recently discovered object oriented programming and is eager to put it to use – everywhere! The Objects Fanatic doesn’t really understand the performance considerations behind his approach. It sometimes seems that he enjoys abstract design concepts more than actual code. He probably has a career in project management or documentation.

Objects Fanatics are quick to point out to the proceduralists that without abstraction we’d all still be using ones and zeroes. They are known to speak in pseudocode. Extreme examples of Object Fanatics go beyond coding on objects at the expense of performance – they do it at the expense of elegance and even readability. Their favorite language besides PHP is Java or Smalltalk. In the PHP world, they may write PEAR modules, contributing code that is well documented and easy to maintain.

And Never The Twain Shall Meet
Can you understand why forums are chock full of biased viewpoints? Your experiences, and the resulting philosophies you adopt, color your approach to new ideas. As programmers, we must constantly be aware of these prejudices and remain open to learning new things. As computer scientists, we must learn to set these prejudices aside and find the best methods for a given situation.

When Is Each Approach Useful?
We have looked at which directives are best served by each approach individually. We have also explored some practical examples of real programs that use each type of programming effectively. But what happens when you have multiple directives?

Here is my advice:

Consider your directives.
Become aware of your theoretical biases.
Test out your assumptions.

Generic benchmarking reports of generic examples in object oriented and procedural fashion tell you very little about what to expect in your own unique application. Instead, find a benchmarking approach that you like, and use it to check whether you are actually fulfilling the directive of writing code that runs fast. Examine the functions that you are writing to see whether they need to share common data. Think whether there would ever be a case for extending them. Consider whether writing a class would be conducive to making your code extendable.

Above all, consider your directives on a scale. Weigh them out. By taking a practical, project-by-project approach to evaluating the usefulness of object oriented versus procedural programming you ensure a sober, informed decision. And remember, with PHP you always have a choice. You can even mix and match.

Summary
Hopefully this article has given you a greater appreciation for the usefulness of each of the two programming approaches, and – more importantly – armed you with enough information and interest to explore these issues in greater detail. I hope that you will think for yourself, examining your project directives, checking out more real-world examples, and taking the good, bad, and ugly comments you sometimes hear about this topic with a grain of salt. Both approaches have their own advantages. So get out there and write some code!

Never Use $_GET Again… SAY WHAT?

August 1st, 2010 0 Comments

You don’t need to use $_GET or$_POST anymore. In fact, you probably shouldn’t use $_GET and$_POST anymore. Since PHP 5.2, there is a new and better way to safely retrieve user-submitted data.

How many times have we heard about security issues in PHP applications stemming from unescaped GET and POST parameters? Proper escaping of input is a perennial problem with web development in general, and for whatever reason PHP seems to have had more than its fair share of bad publicity on this front.

On the database side, many worries over SQL injection have been squelched. The clever developers of PDO, for example, have constructed a library that analyzes data and escapes it appropriately. But the problem of validating and sanitizing input is still a substantial issue. To my surprise, many seasoned PHP developers still spend precious development cycles building custom code to filter input.

Why is this surprising? Because PHP (from 5.2 onward) has a built-in filtering system that makes the tasks of validating and sanitizing data trivially easy. Rather than accessing the$_GET and $_POST superglobals directly, you can make use of PHP functions likefilter_input() and filter_input_array(). Let’s take a quick look at an example:

<?php
$my_string = filter_input(INPUT_GET, ‘my_string’, FILTER_SANITIZE_STRING);
?>

The code above is roughly the equivalent of retrieving $_GET[‘my_string’] and then running it through some sort of filter that strips HTML and other undesirable characters. This represents data sanitization, one of the two things that the filtering system can do. These are the two tasks of the filtering system:

  • Validation: Making sure the supplied data complies with specific expectations. In this mode, the filtering system will indicate (as a boolean) whether or not the data matches some criterion.
  • Sanitizing: Removing unwanted data from the input and performing any necessary type coercion. In this mode the filtering system returns the sanitized data.

By default, the filter system provides a menagerie of filters ranging from validation and sanitization of basic types (booleans, integers, floats, etc.) to more advanced filters which allow regular expressions or even custom callbacks.

The utility of this library should be obvious. Gone are the days of rolling our own input checking tools. We can use a standard (and better performing) built-in system.

Filters won’t solve every security-related problem, but they are a tremendous step in the right direction when it comes to writing safe (and performant) code. It’s also simpler. Sure, the function call is longer, but it relieves developers of the need to write their own filtering systems. These are darn good reasons to never use $_GET (or $_POST and the others) again.

10 Things You Need to Know to Get Started on Twitter

August 1st, 2010 0 Comments

1. Using Twitter is Simple; Using it Well is a Challenge

However complicated it may seem when you first log on to your new account, Twitter is a simple platform.

You can write 140-character updates that will be seen by your followers and also watch a news stream of comments left by people you follow. To direct a comment at a specific follower, simply prefix their name with “@” — for example, “@kevgibbo + your message.”

Send a direct message (one that can’t be seen by anyone other than the recipient) by prefixing a name with a “d” — for example: “d kevgibbo + your message.”

More Social Media
A Day in the Life of a Trending Topic
What History Tells us About Facebook’s Potential as a Search Engine, Part 2
How to be a Social Media Medic
Twitter has also created new grammar — the hashtag. This allows people to conduct simple searches and see what people are saying about a topic — for example, #leadersdebate during the U.K. election.

Some people use the hashtag ironically or to convey humor, without expecting their chosen term to catch on. For example, someone might tweet about how marvellous their recent SEO campaign has been and then add #modesty.

That’s the bare bones of using Twitter. Using it effectively is much, much harder, which you’ll see in the next nine tips.

2. Twitter Needs a Strategy

Before you begin investing time and energy in Twitter, sit down and work out what you want to use it for. Using Twitter only because everyone else is using it won’t win you success.

Do you want to build small scale relationships or market a major brand? Do you intend to actually drive business using your Twitter account or simply drive people to your website?

Unless you know your goals, you won’t be able to measure your success.

3. Your Account Must Look Professional

Before you start using your Twitter account, make sure it looks professional. Update your bio, add the company logo as an avatar, and customize your page.

Some people’s first interaction with your brand will be via Twitter, so make sure it’s as professional as your website and office space.

4. You Should Search for Mentions…

Monitor Twitter for mentions of your brand, products, well-known staff — any terms that people might conceivably use in reference to you.

Twitter will present you with any specific mentions of your account name but you can also run searches. Using software like TweetDeck allows you to set up permanent searches and be presented with relevant tweets as they happen.

5. …and Reply

You’re using Twitter in order to have conversations with people. If there’s a positive mention of your brand, thank the person who made it. If it’s negative, then get your customer service team to address the problem — often a positive resolution can turn a critic into a fan. If someone asks a question then answer it.

Be as polite on Twitter as you would be at a conference or some other industry event where you deal with people in person.

6. Spamming Harms Brands

Several brands (and even politicians) have fallen down on Twitter because they don’t really understand how people use it. The platform is social and has to be used socially. If you’re intrusive, you’ll alienate the people you want to win over.

Tweet links to blog posts, comments, thoughts, questions, even special offers now and again. But don’t simply pour out sales pitches. People won’t follow you and anyone encountering your tweets won’t leave with a good impression of your brand.

By the way, following thousands of people to try and build your own followers is spam, even if you aren’t sending them sales pitches.

7. Automated Actions are Useless

Twitter needs to be hand fed because it’s all about quality, not quantity. You can’t automate personable, social tweeting.

Also, the roll-out of top tweets means that quality is already beginning to be more rewarded, while those aiming for quantity of tweets will quickly gain a bad reputation as spammers!

By auto-following new followers, retweeting mentions, and automatically tweeting blog posts, you may have a working Twitter account, but it won’t be working well.

8. Your Followers Want Value

Why should people follow you on Twitter? What will they get out of it? Whether it’s humorous tweets, inspired analysis and tips, links to fascinating blog posts, industry breaking news, or discount vouchers, you must add value to their Twitter experience.

Otherwise you’re spamming and you’ll struggle to gain any followers.

9. Make Your Tweets Retweetable

You may only have a few followers — certainly at first. So you want your followers to retweet your posts to their followers, spreading the word about your brand. If your tweets are valuable enough, then that shouldn’t be a problem.

Also, make it easy for people to retweet. Keep your comment as short as possible because, when people retweet it, they will have to add “RT username” at the start. If you’ve used all 140 characters, then people will have to edit your words or chop off the link — or, even worse, use the new retweet button!

10. Twitter Magnifies Mistakes

More SEM Basics
How to Measure Success in an SEO Campaign
Managing Your Inventory Isn’t Just for Overnight Stock Boys
Product Feeds Offer Untapped SEO, PPC Opportunities
Get it wrong on Twitter and you risk a storm of mockery, especially if your brand is well known. Or, if a disgruntled employee tweets something abusive from your corporate account, it could be retweeted hundreds of thousands of times before the company even knows it’s happened.

Even a small brand that tweets too intrusively will find that recipients complain to their followers.

When you work out your strategy, work out some ground rules and make sure that everyone using your account understands them.

Doing social media badly is far worse than failing to do it. So behave well on the platform and treat people as you would like to be treated.

How Do You Decide Between C#, Java, PHP, and Python

July 26th, 2010 0 Comments

In particular, a debate between the C#/.NET/IIS stack and the Java/J2EE/Apache/Solaris stack and the PHP/Apache/Linux stack could go on and on for years and years and you’d never find the right answer. That’s because there are so many pros and cons of all these platforms that advocates of each side can debate and debate and never get any closer to the truth, but it sure as heck is a fun debate.

There’s so much evidence that when it comes right down to it, millions of people are building huge business-critical things in C#, Java, PHP, or Python, and while they may have problems, they’re not mission threatening problems.

So how do you decide between C#, Java, PHP, and Python? The only real difference is which one YOU know better. If you have a serious PHP guru on your team who has built several large systems successfully with PHP, you’re going to be a heck of a lot more successful with PHP, not because PHP is a better language than C#, Java, or Python, but because he knows it better

Web Browser Global Usage 2010

July 25th, 2010 0 Comments

Global usage share of web browsers Q2 2010

Internet Explorer – 60.14%
Mozilla Firefox – 24.98%
Google Chrome – 7.14%
Safari – 5.10%
Opera – 2.66%

And what that means to you and me, is all the “cool” stuff we want to do we can’t do until IE8 and lower disappear forever.  Anyone for mandatory IE9 upgrades?

PHP 5.2 Is Dead

July 25th, 2010 0 Comments

OK, all you slow to convert technology anchors, let’s get with the program.  Reading between the lines, clearly the people developing PHP are tired of supporting the past.  And I agree.  There is no good that can come from forcing this language development to support legacy and sometimes just bad ideas unless you want to see MSs C# take over the world.  And the PHP frameworks out there still trying to put a smile on faces of 4.x users should take the hint as well.

PHP announced with its most recent sub set release of 5.2.14: This release marks the end of the active support for PHP 5.2. Following this release the PHP 5.2 series will receive no further active bug maintenance. Security fixes for PHP 5.2 might be published on a case by cases basis. All users of PHP 5.2 are encouraged to upgrade to PHP 5.3.

Use the latest or jump over to the sinking ship known as RoR… peace out.

Zend Framework The Easy Way

July 25th, 2010 0 Comments

Zend Framework changes quickly, so the easiest way to maintain your server installment for all platforms is the google code pear channel.  That’s the only channel that seem to be updated on a regular basis.

pear channel-discover zend.googlecode.com/svn
pear install zend/zend   OR   pear install zend/zend-1.10.6  (choose the version # you want)

… and at any time you can upgrade using

pear upgrade-all

Now you’ll always have the latest and greatest releases of the Zend Framework installed.  Happy coding