To NULL or Not to NULL

I’ve found programmers that I’ve worked with lately don’t like my use of null declarations in PHP. I come from a Perl and JavaScript background (with just enough C++ to be dangerous but not particularly useful), so I tend to declare variables before assigning them values (granted, it’s not a requirement in Perl, just a good idea).

If it adds to the complexity (and/or size) of code, why do it?

Yes, it will make the file a little bit larger…but I’ve never seen—or heard of—a minimized PHP file. Minimizing is great for client-side code (primarily JavaScript, HTML, and CSS) but unnecessary when servers handle the workload. You can find discussions of single- vs. double-quotes all over the Internet, even on PHP.net, but declaring variables in PHP seems odd because there’s no requirement to do so (technically, a variable in PHP has a NULL value when declared…but that doesn’t mean you won’t flag a notice).

Why do I [usually] declare NULL?

  1. Clarifying code; by declaring everything before I use it, I know what variables to look for later when I’m debugging (OOP PHP does this out of necessity with class-level variables)
  2. When using an IDE, the software auto-references those variables later; if I don’t have a matching variable, it won’t reflect in the IDE and I can catch typos before they become time-sucking issues
  3. Finally, PHP flags a notice-level error when a variable is referenced that has not been pre-declared; not everyone knows to turn off notice-level errors, and it’s a waste of log space (and effort to dig through logs full of notices)

I highly recommend working with other programmers; I believe it makes us better coders, we learn new ways of doing things and thinking about things. For continuity, you need to agree on programming conventions. I’m not overjoyed about giving up NULL declarations, but all things change—Facebook just released their fork of PHP, Hack.

Dodge Vipers and the Downfall of Society

If you haven’t heard yet, Chrysler Group is demanding a number of early (and even some pre-production) Dodge Vipers crushed. As a longtime fan of this marque (I was 15 when they came out and it is my all-time favorite automobile), I was brokenhearted. Cars get donated to schools and destroyed after their useful lifetimes all the time. Chrysler claims these cars are not historically significant (although I would say any small-batch car is historically significant, especially pre-production ones). Chrysler claims “they felt it was time,” but a little digging shows a couple of these cars got into the wild.

Let’s back up for a second…the donated cars are used to teach students how to work on cars. The reality is technology has come a long way in the last 15-20 years, and the Viper has been one of the few cars that (at least up until the Generation V’s) you could work on from home without complex computer systems. These cars have never been forgiving to drive (stability control is brand new on them in 2013) and somewhere around 20% of all new Vipers end up wrecked. This is the draw of the Viper—as close as you can get to a street-legal race car off the showroom floor.  This isn’t a car for new or under-skilled drivers. Again…this is the draw.

With this knowledge in hand (and recalling that the Vipers loaned to schools were  worked on by students, taken apart and put together over and over again over the years, and were deemed unsafe to drive. That’s probably a fair sentiment, a well-maintained Viper in the hands of an unskilled driver is potentially unsafe (the same could be said for the Corvette ZR1, Lamborghini Aventador, or any other high-powered car). You don’t put that much power into the hands of an unskilled driver. Take a beast of a car like the Dodge Viper, give it 15 years of being worked on and modified by students just to make changes, and the car gets out? What the f*** do you think is going to happen?

We live in an age of lawsuits, and Fiat (via owning Chrysler Group) gets sued when someone gets hurt. I’m not sure at which point Fiat was at fault, it seems to me that the dimwit who took the car for a joyride is the only one to blame. If ignorance of the law is no excuse, than ignoring the common sense of you don’t f***ing drive a car that’s been worked on by students for years should also be no excuse.

Vipers by Generation (semi-official)

Generation I RT-10 1992-1995
Generation II RT-10, GTS, ACR (’99) 1996-2002
Generation III SRT-10: Roadster, Coupe (’06) 2003-2006
Generation IV SRT-10 Roadster & Coupe, ACR 2008-2010
Generation V SRT, GTS, TA (’14) 2013-

No Longer Under the Law

I’ve been thinking about this for a while, and this blog post has been written for probably two or three months. I think it’s as important now as ever.

It seems to me the fights “liberals” and “conservatives” have, and all the mudslinging back-and-forth, only benefits politicians who thrive on our willingness to tear one another apart (while we ignore what they do behind closed doors and worry about what our *neighbors* do behind closed doors).

Which of those is going to have the greatest effect on your life and mine? Why would you want to start the slippery slope of denying rights to a group of people? How many people realize that gun control is where it’s at because rich old white men wanted to disarm the Black Panthers? Almost all of us can agree that criminals shouldn’t have guns. If said Black Panthers were engaging in criminal activity, they shouldn’t have had guns. But stripping guns (or rights) away from the oppressed only starts a slippery slope toward taking those rights away from EVERYONE.

Republicans often talk about keeping the government out of private lives…that means even when you disagree with someone’s choice of who to marry. That means allowing gay marriage…not forcing a church that believes it’s wrong to go against their beliefs but rather allowing it. There are churches that are okay with gay marriage…you may find it distasteful (or pick another term) but instead of condemning that church, maybe we ought to look inside ourselves and ask why we’re worried about what other people do.

I’m of the [unpopular] opinion that as Christ taught peace, love, and tolerance, he expected that to go to everyone…sinner or not (think Mary Magdalene or even the taxman Matthew…Matt 9:11). Further, as the New Covenant, Christ frees us from the severity of law of the Old Testament (which is why we’re not sacrificing animals, avoiding blended clothing, etc.). It just so happens that the whole “don’t wear blended clothing” (Lev 19:19) is just a few verses away from the one forbidding homosexuality (Lev 20:13).

Unless you want to hold yourself to every law in the Old Testament, perhaps we should consider Christ’s words in Matthew 7:1-5 (NIV): “Do not judge, or you too will be judged. 2 For in the same way you judge others, you will be judged, and with the measure you use, it will be measured to you. 3 “Why do you look at the speck of sawdust in your brother’s eye and pay no attention to the plank in your own eye? 4 How can you say to your brother, ‘Let me take the speck out of your eye,’ when all the time there is a plank in your own eye? 5 You hypocrite, first take the plank out of your own eye, and then you will see clearly to remove the speck from your brother’s eye.”

Let’s take Matthew 7:9-12 also (NIV): 9 “Which of you, if your son asks for bread, will give him a stone? 10 Or if he asks for a fish, will give him a snake? 11 If you, then, though you are evil, know how to give good gifts to your children, how much more will your Father in heaven give good gifts to those who ask him! 12 So in everything, do to others what you would have them do to you, for this sums up the Law and the Prophets.”

In Matthew 19:16-19, a wealthy young man approaches Jesus and asks for guidance: 16 Just then a man came up to Jesus and asked, “Teacher, what good thing must I do to get eternal life ?”17 “Why do you ask me about what is good?” Jesus replied. “There is only One who is good. If you want to enter life, keep the commandments.” 18 “Which ones?” he inquired. Jesus replied, “‘You shall not murder, you shall not commit adultery, you shall not steal, you shall not give false testimony, 19 honor your father and mother,’[c] and ‘love your neighbor as yourself.’[d]” I assume most of you know how this ends, with Jesus telling the young man to give up his wealth…before anyone decides to get socialist on me, the lesson is not that money is evil but that LOVE of money is evil…that the young man desired his wealth MORE than his salvation!

Nowhere did Christ even *reference* Leviticus. He didn’t even reference all Ten Commandments. Yet there are believers who believe their vision superior to Christ’s!

Instead of worrying about what others are doing, Christ teaches us to take care of others and to concern ourselves with our own righteousness…that faith in Christ is the ONLY way to Heaven. If we were concerned about legalities, no one would make it…David and Job are considered amongst the holiest men and even they cracked (and David did some pretty bad stuff)!

Before you decide to exclude a group of people for their actions, consider how Christ would behave in the exact same situation. I don’t believe Christ would argue the fine points of marriage or the semantics of it…the Pharisees and Sadducees often tried to trip Christ up with words and legalese…and every time he pointed out where they failed.

You might think, “but I’m no Pharisee or Sadducee!”…we all are at some level. Anytime we get on the legalese of the Old Testament or think we have all the answers because we’re “educated” (religiously or otherwise) we’re acting just like them.

I’m no expert. I’m no theologian. I believe and I ask for direction…that’s it…in my opinion, that’s all any of us can do. I think the world can use a lot less hate (call it what you want, lie to others and to yourselves, but God knows your heart) and a lot more love and acceptance.

Lime Light CRM API

I put up a new repository at GitHub yesterday that converts the entire Lime Light CRM API into a simple PHP class. The superclass (creatively called LimeLight) has two child classes, Membership and Transaction (with respect to the pertinent Lime Light APIs). This is a work-in-progress and is still in beta…it’s mostly bug-free. As there is no official PHP implementation (only recommendations and companies that will integrate for you), I figured it was high-time for an open source version. I’ve written this code probably a dozen times and frankly I’m tired of rewriting it.

Also, I lack the time to integrate Lime Light outside my existing client scope, and this is as good a way as any to put it in everyone’s hands.

It’s pretty rough and I’m working on building in controls to provide better options and more accurately reflect the API. In the meantime, take a look at the source code here, and feel free to fork it/improve it/etc. I’ve learned and benefited a great deal from open source solutions and am looking forward to giving back.

If you haven’t decided on a CRM solution yet…and you go with Lime Light CRM…tell them I sent you.

NOTE: Neither True Marketing Partners nor Lime Light CRM paid me to write this post or recommend their product. IF you buy Lime Light CRM and if you mention me on the contract, they’ll kick me back. If you buy it and don’t mention me or don’t put me down as your reference on the contract, I won’t get one cent. If you’re already using Lime Light and want to expand from the web forms to the API, this is a good place to start. I have to have a live version within a week anyway… 😉