By Adam Kinder on Oct 27, 2008 in Programming | comments(3)
Are you serious?
It apparently was confirmed on Saturday that PHP’s namespace separator will be a backslash.
Not only does this fly in the face of every coding standard ( and established language ), it’s idiotic. Why not adopt the Java import standard? Instead of something akin to:
require "PDO/mysql.php";
$object = PDO\Mysql("arg");
You would have:
require php.pdo.mysql;
$object = Mysql("arg");
For runtime or static namespacing, you could just use the full namespace:
$object = php.pdo.mysql("arg");
But no, after a “lengthy” IRC discussion, they’ve decided to subject us to this:
$object = Some\stupidly\long\name\space("hi");
One concern with using something like :: or -> is that it was used elsewhere, and \ wasn’t. Oh wait, except for escaping something.
Honestly, after using Python and Java more, I’m rarely even use PHP. Namespaces was something that would have brought me back to the fold, but I’m not interested in using the retarded backslash separator. After nine years of programming in PHP, I think I’m ready to hang up the hat and move on to something better, faster, and more standard.
By Adam Kinder on Oct 14, 2008 in Programming | comments(7)
Ok, I’ve seen this crap come up like ten times in the past month. Usually from PHP “developers” unfortunately, even those with the ZCE badge of honor ( I expect better from you guys! ).
Exceptions are NOT for userland errors. Throwing an exception, especially in PHP, is very expensive.
This is another perfect example of PHP adopting a methodology from another language, and then not guiding their developers in the right direction.
This, is wrong:
if( !$user_email )
{
throw new Exception( "You have to fill out the email field" );
}
A good rule of thumb, if it couldn’t fit logically in a try/catch statement, then it’s not an exception. This is a good use for exceptions:
if( !$dbInstance )
{
// Something went wrong with the DB connection
try
{
$dbInstance = new dbObject();
}
catch( MyDBException $e )
{
print "Something broked: ".$e->getMessage();
}
}
By Adam Kinder on Oct 3, 2008 in Programming | comments(0)
I hope I’m not pulling a Leah Culver here.. but remember, I don’t have a CS degree and Hibernate is just.. odd sometimes.
I just finished up on a very helpful requirement for our disaster application. Since we’re pre-release, I’ll be vague, but the DAO call to the database needs to select a distinct record set of cities, based on the supplied city and state name.
The code I wrote works ( beautifully by the way ), but.. is this honestly how you have to add a DISTINCT restriction to a Hibernate call?
Criteria crit = hbsession.createCriteria(-------.class);
crit.add(Restrictions.eq("state", stateName ));
crit.add(Restrictions.ilike("city", cityName + "%" ));
crit.setProjection(
Projections.distinct(
Projections.property("city")
)
);
I guess my issue is that given the rest of the Hibernate API and naming conventions, I was expecting ( and even tried ) something like this:
Criteria crit = hbsession.createCriteria(------.class);
crit.add(Restrictions.eq("state", stateName ));
crit.add(Restrictions.ilike("city", cityName + "%" ));
crit.add(Projections.distinct("city"));
Is there a better call to make when dealing with DISTINCT, or is the above code ( the working example ) the best implementation?
By Adam Kinder on Aug 21, 2008 in Life, Programming | comments(3)
And verily, this rule of Kinderism I give to you: The 10/120 Rule
The 10/120 rule is something I came up with a few years ago, and began applying to my programming. I guess it could be used for just about anything, but it’s a bit too restrictive when it comes to something like.. skydiving
Read on for the full post.
Continued
By Adam Kinder on Aug 12, 2008 in Programming | comments(3)
Since I’m getting a good piece of residual traffic from my two “is an idiot” posts ( Suze Orman and Leah Culver ), I figure I’ll go for the throat and just start calling everyone idiots.
In actual news, I’ve really gotten hooked on Python, Lunatic Python, Panda3d and Terragen. Honestly, just by using all those together, you could create a pretty awesome video game. My one contribution so far is creating a Boeing 747 in space, but it’s a start