Private properties need accessors?
April 12th, 2008
I read this post on what not to do with private properties. It’s for Java, but applies to Flash as well. Apparently declaring a property is the “amateur” way to do it. This is how I would do it.
public class Person {
private var _age:int;
public function Person(age:int) {
_age = age;
}
public function birthday():void {
_age++;
}
}
According to this fellow, that’s bad practice. You should always use accessors! Why write short concise code when you can write three times as much? Instead of age, use getAge() and setAge() because apparently its a lot better to write setAge(getAge()+1), rather than write age++.
Flash’s accessors would allow you to write age++, but this is still the most disturbingly defensive code I’ve ever seen. It’s a private property! A class is supposed to be able to manage its own properties. It’s other classes you’re supposed to mistrust, not your own. If a class has become so big it requires this kind of nonsense that’s a pretty good sign it should be split up into smaller classes.
In my opinion his only valid complaint is that its easier to make breakpoints. Fortunatly most of the comments for that article disagree with his opinion.
Free Flex Builder 3 for students
March 29th, 2008
The serial you get works on the Linux version, which is currently in alpha. Get your serial here. Thanks to Colin Moock for pointing it out.
Starfield Stackers Demo
March 22nd, 2008
A while back Andrew Dickman and I tried making games together as an artist/programmer duo.
This is easily the best thing I think we came up with because it’s the most fun to look at and play in its incomplete state. I wrote some decent AI for the game, which I’ve never actually beaten on the hardest difficulty. The gameplay is basically identical to Puyo Puyo, otherwise known as Dr. Robotnik’s Mean Bean Machine and Kirby’s Avalanche.
Use the arrow keys to move, and the spacebar to “spin” the blobs. Chain together 4+ blobs of the same color to clear them and any nearby black blobs. You send more black blobs to your enemy the bigger the chain, and way more than that if you pull off combos.
This game is so incomplete you can’t switch between modes in the game, so you’ll have to pick the type of game you want to play from here.
Yoshi’s Island Flash Demo
February 29th, 2008
When it comes to 2D platformers, there is no better than Yoshi’s Island. It’s innovative, loaded with levels, and just plain fun to play. When I was younger, I went so far as to get 100’s on every level, including the bonus levels.
I was experimenting with tile engines in Flash and I figured it would be very hard, but possible to pull off Yoshi’s Island in Flash. These days, that’s almost easy, but this demo was on the far edge of what Flash 6 was capable of on my old computer. It was reasonable in brief horizontal levels, but slowed way down when in levels involving both axes. I decided to drop it, but I have a special place in my heart for this project, since this is probably the best chunk of code I ever wrote for Flash 6. Ah well. I still gained a lot of experience from it.
Here’s the demo Use the arrow keys to move and Z to jump. Press Z again in mid-air to get Yoshi to float.
You’ll need to view this post in a browser with Javascript and Flash 6 in order to see it.