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.
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.
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.
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 php
|