Jul 26 2010

Photos of the Week – Motion and Speed

While I took a lot of photos this week, since we have a deadline fast approaching I didn’t have time to specifically take photos for this theme, so the last one is a bit of a stretch. But, in the very least, they’re still photos of the week. Enjoy!

Here’s Sam’s submission.


Jul 1 2010

Why Your Code Sucks – Naming Conventions

I’ve seen a lot of poorly written and ugly looking code in my time. That’s not even considering the undocumented and uncommented code. We all know we should comment our code but how many of us do it consistently? I admit, when I’m in a coding frenzy, stopping to write comments just gets in the way of my thought process and can be distracting. I will however write a bunch of comments before I write the code, of the operations I think I need, in order to give me an outline of where I need to get to. For example:

// Get URL string for video file
// Load video file from URL request
// Load video file into video player
// Set up video player
// Play video

I may not know all the APIs to load and play the video just yet, but at least I’ve given myself an outline and as I fill in the code below each comment, I can see exactly what I’m doing and where I need to go.

Why Your Code Sucks

The point of this article is not to talk about comments, but how to avoid writing them in the first place within your functions and still be clear for everyone else, for the most part. This is your code:

newPlPt = crt2pl( nmc.x, nmc.y );

Not even a comment could concisely convey the meaning of that hideous statement. Instead, why not:

newPolarPoint = cartesianToPolar( newMediaContext.x, newMediaContext.y );

Well written code is self documenting. Let me restate that: if you can write code so that someone can jump to any point of that code and understand what’s going on at that point, read it like a sentence, and not have to decipher minute details like what each variable means, then you don’t have to comment most of your code.

There’s no reason you need to shorten the names in your code. Most programmers have never had file size limitations to deal with, so there’s no reason for it. Stop pretending you live in the 1960s and embrace nearly infinite file storage. To save keystrokes perhaps? Please, use a real IDE with code completion and stop doing stupid things like:

public function updateP( p:Player, d:MovieClip, b:MovieClip, t:Textfield);

Function Names

Also, because your functions are essentially actions, they need to reflect that in the name, so put a verb in the beginning of your function such as: getData(), setStatus(), enableWiFi(), hideControls(), handleGraphicException(), launchBall(), etc.

Class Variables

Get rid of the underscores in front of your class variables. For example: _dg; _myNumber;. All class variables should be private anyway, so why do you need that ridiculous convention? It’s a hold over from C where there was no “private” keyword, so you’re using it and you have no idea why.

Also, what’s with the “my” naming convention? You sound stupid when you have those: myInstanceName, myMovieClip, myGraphicsContext. Of course it’s yours, whose would it be, if not yours? If you’re programming with a colleague, do you refer to his variable references as yourInstanceName? Or hisVideoFileURL? Of course not. Don’t be that stupid; you’re reading too many stupid online tutorials by uncreative people who only code because they have nothing else better to do while living in their parent’s basement.

In the very least, be consistent with your naming conventions.

Hungarian vs. Polish notation

Depending on which language you’re coding in,  you may need to use a notation to help you with type casting. Let me rephrase that: if you’re using a loosely typed language, use Hungarian notation. You should probably use this with strongly typed languages anyway because with abstract types, you never know what you could get into and it’s just generally less confusing.

Hungarian Notation: vendorNameTextField or vendorName_txt

Polish Notation: txtVendorName or textFieldVendorName

Why not Polish notation? Not only is it ugly, but why would I sort on variable type instead of the variable name like I can do in Hungarian notation? The notation names come from how the speakers of those languages modify their verbs and nouns. To say: “My ball” in Hungarian is:  ”labám” where “labda” is the root word and the ‘m’ singifies a first person possessive. Hence the ending of the word shows the crucial information. It’s the opposite in Polish notation where the beginning of the word is modified. In the interest of full disclosure, I love the Polish, but I am Hungarian, but I promise that’s not why I prefer one over the other.

Final Thoughts

In the end, be consistent, be clear and spell out your variable and function names.


Jun 29 2010

Photos of the Week – Black and White

With the advances in digital photography and the cost of high quality cameras so low, everyone has become a photographer. However, few realize what it’s like to shoot  with film and fewer still, to shoot with actual black and white film.

The development process was the best part because you didn’t get to see your photos until you hung up your role of film on the drying line. Often times, you’d forget you even took some of your shots and be pleasantly surprised. There was no looking at your LCD screen after every shot, there was no deleting bad pics so that you could shoot more on your already full memory card. Different films yielded different colors, grain and style, which can now be duplicated in a computer, but it’ll never be the same. This week’s photo challenge was an attempt to force everyone to think about shooting for a purpose rather than for an edit in Photoshop later.

Disrepair

Disrepair

Branches

Branches

Yoga

Yoga


Jun 1 2010

Photos of the Week – After Hours

Sam and I started a photo project. It’s pretty simple: a theme and a set of photos (3-5) taken that week. This week’s theme was “After Hours.”

I always take photos, but rarely do I have time to post them. Since I have peer pressure now, it pushes me to go out, take some more photos with some thought behind it and finally post them.

Here’s Sam’s After Hours post.

A Tree Grows Through It

A Tree Grows Through It

Night Frame

Night Frame

Light Streaks on Fairfax

Light Streaks on Fairfax

Fairfax at Night

Fairfax at Night

A Sleeping Petunia

A Sleeping Petunia


Apr 11 2010

What I’ve Been Up To

I’ve been crazy busy ever since we returned from Colombia. We fell back into life in the US at full sprint and have only had a few periods since where we could rest. As a result, I don’t think I’ve been clear on what exactly I’ve been up to with my family and friends. So here’s the short version of most of the major things I’ve been up to since getting back:

iPhone Development

We started a company last year to allow independent iPhone app developers to make the transition from “wanna-be” to published developer. The model works similar to a record label, where LTZ provides the leverage, so that developers can concentrate on coding rather than the logistics of getting apps out. We wanted to start small, get a few early successes and then use that momentum to gather a pool of developers. We’re also planning a Code Kitchen, which is a class to teach iPhone and Mac programming to anyone interested for free.

Most of our early time was spent on logistics, even though we had our first app idea right from the start. It was a lot of waiting; we waited for resources (copy, data, images, feedback), we waited for Apple, we waited for the lawyers and we waited for contracts. So in a year’s time, we finally had an application ready to release. But thankfully, most of that work won’t have to be completed again since the contracts, setup and other logistics are taken care of. I’ll post a longer article on the whole process (what it took, what we learned, etc), but as I type this, our app, BarNinja is “In Review,” waiting to go up on the Apple App Store. It still might get rejected (one never knows with these processes), but we’re hopeful that it will appease the Apple review gods. We’re also more hopeful that the app will actually sell well and we can get some money into the business so we can buy “test” devices, like the brand new iPad for all our people.

Scuba Diving in Blacksburg

As many already know, scuba diving is a relatively new thing for me. However, I instantly fell in love with the sport and have tried to progress as quickly as I can. It’s been a lot cheaper than flying.

I got my Open Water (OW) certification in November of ’08 (with dives in Cozumel, Mexico in December), my Advanced Open Water (AOW) in July of ’09 (with dives in the Florida Keys and on the US Coast Guard Cutter my grandfather served on in World War II), my Rescue Diver certification (that required another certification of Emergency First Responder) and now I’m working on my Divemaster certification, which is a professional level diving certification. As you can image, this has been a long journey, with a ton of training, reading, and diving. The diving part was especially difficult due to the location. Blacksburg is not known for it’s amazing scuba diving, but diving in the local river, which has a maximum depth of 41 feet, has made it a bit easier.

We should be able to finish up the divemaster certification in May of this year. That’ll allow me to help teach some classes with Scott, who runs Avalon Adventures here in Blacksburg and the New River Valley (NRV). He’s my current instructor and I’ve helped him out with his website. The plan is to serve Blacksburg, Christiansburg, Radford, and the surrounding NRV to provide classes, dive trips, dive refreshers and other adventures. Hopefully, we’ll also make some money in the process.

Music

I’ve picked up my guitars again. Sadly, I don’t think I’ve picked them up in at least six months, but I’m at it again. Luckily it only took me a few minutes to remember what those six months made me forget. I am also helping my old Computer Science instructor with his business at Rocket Music. It helps me get back into music, even though its on a strictly computer programming level. Just talking about guitars, buying guitars, customizing guitars and everything guitars reminds me to go pick up one of my guitars and practice, if for only 15 minutes.

Our Foster Dog

Our foster dog Petunia has really adjusted well with us. When we first got her, she had some problems with other dogs, being generally nervous, crying when we left her home alone, etc. We weren’t surprised, since her previous owners abandoned her and she spent a long time in the shelter. Now all she does it try to cuttle up with us and never leaves us, even if that means following us from room to room.

Ana is getting attached to Petunia and I don’t think we’re going to get her adopted. Being a Pitbull mix, people are afraid of her. However, everyone that’s met her has loved her, which is another reason we don’t think we’ll let her be adopted. She never barks, is great with our cat, loves to play, never complains, and is so adorable. She’s gathered such nicknames as Petu, Petufilese and just Perrita. Dogs are a lot of work, but I think in this case, for her, she’s worth it.

Apartment

My girlfriend of about a year, moved in officially a few months ago. She still has her old apartment, but the rent there is taken care of by a sort of sub-lease. Previously, we were always together anyway, cooking food, studying together, grocery shopping together. The only difference was, she wasn’t paying rent or the massive electricity bill we seemed to rack up with her presence. I have an extra bedroom in my condo, which I gave to her for all her stuff. We moved in her tredmill into that room (producing some of the first small scratches in my new hard wood floors), her desk and a bunch of other things so that she has her own space. It’s worked out extremely well and while we’ve had our fights about stupid apartment and living stuff, you don’t truly know a person until you lived with them. That goes for friends and girlfriends.

Spanish

As a result of living with a native Spanish speaker, I’ve picked up a lot. I never learned Spanish. It was always the language of poor people where I lived. Instead I studied German, the language that’s most understood in Europe. While living in Hungary, I learned Hungarian so picking up Spanish was probably the easiest thing for me. With Spanish, for example, just add an ‘O’ or an ‘A’ after any English word of more than 2 syllables and translate word for word and you have a pretty good, understandable sentence.

Before I met Ana (pronounced Ah-na, not Anne-uh by the way), I probably knew less than 20 words, and that’s after having spent two weeks in Mexico scuba diving. Before that, I probably knew around 5. Now I wish I would have learned it sooner, but I’m glad I learned German since Ana and I are planning a trip back to Europe. Ana has never been, so I’ll take us around Hungary, we’ll visit Italy (which is a language both of us have studied, but she understands a lot better) and she can take us around Spain since they almost speak the same language as she does.

We have a savings account set up that we’ve been putting money in since last summer. It’s not a lot, but it’ll at least pay for the plane tickets out there. Then we plan on staying with friends where we can, and since we both have friends all over Europe, it shouldn’t be an issue.