iPhone 4 MMS / Group Messaging

I just got an iPhone 4, less than a week ago. It’s my first iPhone. As a self-described textaholic, I’ve been having a lot of fun with it.

The only trouble I’ve had texting so far is with MMS and group messaging. If you turn on MMS and group messaging, all group messages will be sent as MMS regardless of whether or not they include photos/video/etc. This is because all the recipients are sent along with each text, so if you send a group text to iPhone users, any replies will go to all of the original recipients.

Cool, right? Usually – but if one of your recipients can’t receive MMS (probably because of their phone’s model) they won’t receive that text at all. Or any replies.

Unless you send texts exclusively to iPhone users, it’s probably safest to turn MMS on and keep group messaging off.

Posted in News, iPhone | Leave a comment

A Certain Elephant #98

A Certain Elephant #98: Tina's Sense of Awesome: feeling okay.

Please rate:
Next

Updated Sometimes

Help me transcribe this comic


Posted in A Certain Elephant, News | Leave a comment

PHP best practices #1: duplication is evil

I am very opinionated about my code.  The source of most of my opinions is the DRY/DIE principal: Don’t Repeat Yourself / Duplication Is Evil.

 

Take, for instance, a Human Resources application I worked on recently. It is a collection of web forms to get information to and from the HR department at work.  I inherited the system and had to make several improvements: form field validation had to be more robust, submitted form data had to be formatted in a prettier way, fields had to be removed/added, etc.

This was a pain. This application was simple – two forms, less than 50 fields total across each. Total lines of PHP code: 1000 maximum, including comments and HTML. That’s tiny! And yet, within this tiny code base, information was duplicated at least six times. And it was inconsistent – each duplicated piece of information told a different, contradictory story about the web form.

This is why I have internalized the DRY/DIE principal. If you stick with this principal from the get-go, applications are much more robust and easier to maintain. Luckily, my story has a happy ending: I ported 90% of it to PHP-Frame and modified the forms with time to spare, and even got a few nice cosmetic extras in.

tl;dr for this post: next project you’re working on, count how many places you duplicate similar information. Try to minimize that number. I reduced it from 6 to 2 in my application (all the form field validation requirements laid out in the application’s Model; and all the form fields laid out in HTML).  Many methods can be used to avoid (or eliminate, when refactoring) duplicated code and information, including solid framework design (which I have focused on thus far) and using generated code (which I haven’t delved into very much). Regardless of which path you take: don’t duplicate code, and don’t duplicate information.  Duplication is evil.

 

Further reading:

Rule three [wikipedia]

Single source of truth [wikipedia]

Don’t Repeat Yourself [wikipedia]

Separation of concerns [wikipedia]

Posted in Coding, News | Tagged | 1 Comment

PHP Best Practices: Introduction

 

I started programming when I was about 12, did so continuously until I was 18, took a couple years off to be a kid again, and recently started programming again seriously (in professional, production, multiple-developer environments).

I have a lot of standards and ideals with programming, but there are also a lot of gaps. This “best practices” series will be my attempt to explain every facet of my programming philosophy, and hopefully start a conversation.

I think this conversation is necessary because most code we see on a daily basis is bad – real bad. It’s bloated and slow when it works at all. It’s brittle and doesn’t like to change. It probably took forever to get the initial product, but it probably needs a LOT of work – and that’s unfortunate since it’s so difficult to change.

I will probably talk a lot about unit testing and MVC. The reason you should read more is because I don’t like the way those are done now, at all; I think we can do better. The reason I want you to read more is because I know you, as a programmer, are uncomfortable with a lot of what you do. There should be a better way to do things, and I intend to discover it – with your help.

 

So, before I write my next post, a note : any methods I come up with should be general enough to port to other languages. PHP is what I’m most familiar with, but I don’t intend to be exclusive.

 

Thanks for reading.

 

Posted in Coding, News | Leave a comment

Fancy command-line alarm for Mac OS X

I have a Calc exam in the morning. Instead of studying for it, I decided to program a command-line alarm for myself so I don’t sleep through the exam. It doesn’t help that my phone is MIA and I’ve never owned a regular alarm clock.

Here:


#!/bin/bash
osascript -e 'tell app "iTunes" to pause' > /dev/null
osascript -e "set Volume 3"
say "Wake up, Josh. Time to get out of bed. You have an exam to take."
sleep 5
osascript -e "set Volume 0.5"
osascript -e 'tell app "iTunes" to play playlist "morning music"' > /dev/null
sleep 5
osascript -e "set Volume 1"
sleep 5
osascript -e "set Volume 1.5"
sleep 5
osascript -e "set Volume 2"
sleep 5
osascript -e "set Volume 2.5"
sleep 5
osascript -e "set Volume 3"

Save it in your ~/bin folder, reference it from your crontab, set up a “Morning music” playlist in iTunes and customize the wakeup message. Also, the tiered volume is fun but really janky.

And my crontab, IN CASE YOU WONDERED:


0 8 * * mon,tue,wed,thu,fri ~/bin/alarm.sh > /dev/null
30 8 * * mon,tue,wed,thu,fri ~/bin/alarm.sh > /dev/null
0 9 * * sat,sun ~/bin/alarm.sh > /dev/null
30 9 * * sat,sun ~/bin/alarm.sh > /dev/null

A snooze feature would be nice, but that can wait.

Posted in Coding, News, Personal | Leave a comment

Twitter updates on 2010-06-25

  • I have posted a new comic, it is about existentialist elephants http://www.acertainelephant.com/ace-97.html #
  • "It was probably just an honest mistake, but that's unlike Apple." Ugh. #
  • Denmark: Not Doing So Well #worldcup #
  • Thankfully, the Slashdot summary about IceCube is incorrect. It just wouldn't be the same if the summary was accurate #
  • My employer is featured on Slashdot. This is a first for me so I HAVE to tweet it. http://3h98.sl.pt #

Powered by Twitter Tools

Posted in News, Twitter updates | Tagged , | Leave a comment

A Certain Elephant #97

A Certain Elephant #97: Auto. Bio. Graphical.

Please rate:

Updated Sometimes

Help me transcribe this comic

Posted in A Certain Elephant, News | Leave a comment

Twitter updates on 2010-06-15

  • Now that futures trading for movies is legal, does that mean movie pundits are now financial experts? fffffuuuuuuuu #
  • Futures trading for new Hollywood films now legal. What? http://3crg.sl.pt #
  • Smoking some pipe tobacco (Big Dipper from Uhle's) and listening to Estradasphere. Hooray for expanding horizons. #

Powered by Twitter Tools

Posted in News, Twitter updates | Tagged , | Leave a comment

MVC or just pretending?

I used to think I hated MVC. I realized in the past few months that MVC is great, but not many programmers actually adhere to it in the PHP world.

A lot of PHP frameworks pay lip service to MVC without actually adhering to any strict standards. I see this resulting in (1) duplicated code, (2) duplicated information, and (3) a messy hodge-podge of PHP+HTML, almost every day.

The first symptom (duplicated code) happens because of sloppy programming more than not sticking to MVC. However, the problem is much worse because functional code is placed in the controller, the model, AND the view. Functional code should be placed only in the controller (or “helpers” or “libraries” called from the controller, as the case may be depending on your framework).

The second symptom (duplicated information) occurs because information is placed in the controller and the view. It should only be in the model. For example, form validation: the controller should validate form data, but all validation information should be in the model.

The third symptom occurs because functional code and information is placed in the view. Only the layout and UI design should go into the view. Form validation, sending emails, saving to the database – that’s outside the boundaries of the view, or it should be.

I’m still trying to flesh all these details out. One thing I know for sure that will improve a project by leaps and bounds – don’t allow PHP code in the view! At all. Ever. Some programming philosophies state that, because PHP is a templating language itself, HTML and PHP should be mixed together. I think that’s wrong. It leads to messy, hard to manage, and even dangerous code. My solution is the template engine in PHP-Frame.

Posted in Coding, News | Tagged | Leave a comment

Twitter updates on 2010-06-14

  • Okay, we have the iPhone and iPad now… we need another Apple rumor to keep ourselves occupied. #
  • Explaining PHP-Frame to @kanatzidisg, good times and paradigm shifts are bound to ensue #
  • The physicist and Oingo-Boingo fanboy extraordinaire, @kanatzidisg, is now on Twitter! #
  • Some of my friends are making Facebook accounts for their kids… these kids will have had a Facebook account for their entire life. #

Powered by Twitter Tools

Posted in News, Twitter updates | Tagged , | Leave a comment