Teaching class classes for PHP development – Rock Band Example

PHP classes

Object-Oriented Programming (OO or OOP) is the best way to have re-usable, sharable, less-bug-ridden, easily readable, easier to debug, and easier-to-pick-up-later professionally written software.

“Learning classes” is the functional way to describe learning object-oriented programming. One skill begets the other. When in college my professor played a video of a band playing music. The band represented a program, and each musician represented a class.

I hope that’s not how it’s described nowadays for comp-sci peeps because it’s a completely backwards way to learn it. It is backwards because you’re already looking at a finished product. To understand OO and classes, think in terms of small portions. Then grow from there.

To give an example of how to build out a class, let’s build a musician or rocker since we’ve been on a Rock Band kick.

Before continuing, this assumes you’ve written some PHP – including at least making a function or two…

.

Now, what does a rocker have?

  • Name
  • Gender (probably)
  • Instrument
  • Talent Level

These will be the variables we put in our Rocker class, here’s the code to support us…

<?php

class Rocker {
// OOP classes are usually capitalized. Good form.
var $name;
var $gender;
var $instrument;
var $talentLevel;
}
?>


Continue Reading

How to post images to Twitter and Flickr at the same time from an iPhone

Sweet - TwitPic + http://flick.com/photos/solyoung works great from the iPhone.

How to is after the jump

With all the web services and photo sharing systems, I’m amazed an integration of Flickr and Twitter hasn’t already happened. Twitxr came out and claimed compatibility in Dave Winer’s scripting.com comments, but it never actually worked. I’ve wanted a way to post a pic to Flickr and have it announced on Twitter right away. Nada.

I love to shoot pics on my iPhone and post them immediately. Live photo streams are terrific! Flickr makes it easy by allowing you send to an email to a pre-defined email address. All you do is send an email with a photo as an attachment to your Flickr upload email address.

Now TwitPic is offering a service for Twitter users just like Flickr’s service, but they store the photo and send an announcement to Twitter with a link. Whatever you put in the subject line of the email is set as your update in Twitter.

Combining these two services is easy. Just send an email to both services at the same time and the pic will be posted in both places. The subject line of the email will be set as your update in Twitter and as the title of the pic in Flickr.

If the above didn’t already give you the ‘Ah HA!’ feeling, here are the precise instructions (iPhone specific, but works with any email capable phone):Continue Reading

Back to running – Nike+ to track progress

After a long time off I’m finally back to running. My wife gave me a Nike+ at Christmas and it’s been gathering dust for the most part.

Why? We’ve been remodeling and we’re finally wrapping things up (photo stream on Flickr). I can feel the all-our-spare-time-sucked-out-of-us-and-put-in-to-construction-duties coming back like the warmth of Spring. Now there will be time for visiting family, coding, and running.

I’ll be adding a static about page to solyoung.com and a Nike+ badge will be a small part of it. The Philadelphia Broad Street 10-miler is coming up in May and I’ve got to get back in runners shape. One huge advantage of working at iofy is our office is right at the finish line. It’s going to be a great, great run!

What you miss in the flow

Meeka telescope Towers Numar.jpg

(interior picture from The Towers of Numar, by Michael Gagne)

It’s been almost two weeks since I started using Twitter as a primary source of news, links, and other fascinating bits of information. The approach has been awesome and I’ve discovered a ton of people and sites which I now return to. It’s been eye opening.

But I’ve been missing sites previously frequented. The time I’ve spent in the flow cut in to time spent reading feeds and visiting sites. And while my Google Reader feeds are grossly limited compared to the nearly 5,000 people I follow on Twitter, there is still some attachment and familiarity that goes missing.

I share my Google Reader items as a feed (RSS) or on a page (HTML), and of course it’s aggregated on my FriendFeed. I am ‘sol‘ on Twitter.

All incoming Twitters are saved and searchable in Gmail

I came by this as a latent side effect from switching to my flow method of using Twitter. It seems a lot of people want a quick and easy way to save their Twitter stream and be able to search it later…

To do this, you need to set up Twitter so you’re getting (or also getting) your updates via a GTalk/Gmail account. It’s very easy:

First – set up Chat in Gmail

1. If you don’t have a Gmail account, get one! After logging in, go to “settings” and hit the “Chat” tab.
GMail Chat Tab
2. Choose to “Save chat history in my Gmail account”.
3. Save this setting.

Second – set up Twitter to send notices to your Gmail account

1. In your Twitter account, go to “Settings” -> “Phone & IM”.
2. Enter details for your Gmail account.
Twitter IM Settings
3. Save the settings.
note: Only updates from Twitterers you follow and are selected for IM updates will be sent to your Gmail account.

Last – Log in to Gmail and keep that browser open

Log in

1. Choose to Sign into chat. Your Twitter updates will start arriving in Gmail.
2. Keep a tab or window open. If you log out of Gmail, or close the browser or tab, the updates will stop arriving since Twitter only sends updates to users that are logged in. Simply keep a browser tab open (very easy to do if you’re already a Gmail aficionado).