Embedded IDs in Network Structures

Here’s an issue I’ve been wrestling with and cannot come up with a solid solution:
Should IDs be included inside structures, or is that metadata that should be encapsulated at a higher level?

Here is a more concrete example. We are tracking the state of a given Fighter in the game. This is a stateless server environment, so we need to transfer as little information as possible, but we must still describe everything. We assume there is a larger datastore on the server that has additional constant “definition” information for each Fighter.

Here is what the definition looks like for the external metadata version. Incidentally we are using Thrift, but the issue is the same in any environment.

// current state for fighter.
struct FighterState {
1: required i32 CurHealth;
2: required i32 MaxHealth;

struct FighterList {
// indexing
1: required map fighters;

// connects a fighter to the definition datastore.
2: required map definitionIndex;

Immutable information is clearly separated from mutable. However, every method that needs to operate on a Fighter requires two parameters: The FighterList and the FighterID to identify which one is involved.

So this is what the information looks like if we encapsulate it all in one location.

// current state for fighter.
struct FighterState {
// indexing. this is immutable.
1: required FighterID FighterID;
2: required string DefinitionID;

// actual state
3: required i32 CurHealth;
4: required i32 MaxHealth;

This produces a mixed-mutability object. This feels less than ideal. Every time I transfer the state between client and server, I repeat the DefinitionID. However, if I want to pass a Fighter to a method, I can simply pass the FighterState and have enough information.

So let’s approach this in another way. What if we use compositing?

// current state for fighter. This is mutable.
struct FighterState {
1: required i32 CurHealth;
2: required i32 MaxHealth;

// immutable
struct FighterInfo {
1: required FighterID FighterID;
2: required string DefinitionID;

// combine them for runtime use
struct Fighter {
1: required FighterState State;
2: required FighterInfo Info;

We have now clearly separated the mutable from the immutable. We also can pass just the one Fighter to methods. But this feels very wordy. Also, the needs of the client and the server are slightly different. The server needs the complete “view” of the fighter definition, while the client can use a trimmed down “view”.

This can be simplified by merging the FighterInfo into the Fighter. Not quite as clean of a separation, but it maintains the mutability model.

// current state for fighter. This is mutable.
struct FighterState {
1: required i32 CurHealth;
2: required i32 MaxHealth;

// Network view of the fighter. It includes a mutable base, but the additional fields are immutable.
// This is minimal information for sending across the network.
struct FighterNetworkView {
1: required FighterID FighterID;
2: required string DefinitionID;
3: required FighterState State;

// the server is now able to add additional information - the complete definition for the fighter.
// This no longer must be handled in Thrift, it can be a subclass of FighterNetworkView, which simplifies accessing.
struct FighterServerView {
1: required FighterNetworkView Network;
2: required FighterDefinition Definition; // we no longer need to look this up externally

Now it is implied that only the base FighterState is mutable, while preserving just one parameter to methods. Additionally, this assists unit testing because there is no longer an external dependency to grab the Definition information at each use.

This still feels slightly wrong however because we are making a FighterServerView technically “mutable” because the base class is.

On the other hand, I’m used to SQL tables where IDs are regularly included with the data rather than external, necessary for lookups.

Opinions anyone?

Advertising Done Right

Your attention please. Please yell if you’re paying attention. This is worth watching. We will wait. YouTube Video

This is how advertising should be done. I don’t really know or care anything about the product, or the company behind it. But seeing this video changes my mind. *This* is exactly how advertising should be. It changes my mind, without making me feel bad for doing so. Yes, it uses the “tug at my heartstrings,” but it is more about hope than it is about selling something. It respects the viewer, instead of pandering to them.

This is worth pointing out as an example of what this world should be more like.

Don’t Fear the Button

I’m afraid to push a button.
User interface design is something I care about. I am a developer, which practically makes me a power user by default. And yet I still come across boneheaded design in commonly used applications. Design that would make computers less accessible to the general public. Worse, in places that didn’t previously have these issues.

Latest: Youtube on a desktop browser. Drag the playhead to sometime later in the timeline. If it’s not loaded yet – tough cookies! It will only work on the section that’s loaded. Worse – it changes the “scale” of the playhead to only show what’s loaded, but *only while you are holding the playhead.* Absolutely no semblance of user expectation.

Why is this suddenly too difficult for YouTube to manage? I know a year ago I could easily have just skipped right to where I wanted to be, and simply wait for the data to download starting at the new location. As a developer, I can imagine why this choice was made. Perhaps the data format is not well suited for seeking. Is a “please wait” indicator too much to ask? Then the playhead scale will stay consistent. The user will have an understanding of where things stand. Instead, somewhere inside Google, a bunch of extra code was written to support this “seek only within loaded area” code, with special cases for the display and input system. Someone had to deliberately break the user’s trust.

Okay, fine, I can’t move the playhead to the actual intended target. There is another button, with the tooltip “watch later.” Maybe that will download it in the background so I can close the page and return. Oops! Nope, that means??? well, I’m not exactly sure. Some menu shows up on the left side of the browser and there is no indication of how it relates to the action I’ve requested – “watch later.”

That’s not what I wanted it to do. But I’m afraid that if I push the button again to “undo” whatever I just did, maybe the page will reload and I’ll have to wait for the whole thing to reload all over again. At this point there is no trust between me and the application that it will do anything that I expect it to.

We must always keep a watchful eye on our designs, whether they be games, websites, or applications. Every “feature” needs to be examined through the lens of the intended audience for clarity, not confusion. This is an ongoing battle that has been fought for many years, and will be for many years to come.
Let’s not forget it!

Hello world!

It is long about time I updated this site. So after much fussing, here we are. I???m going to be importing a lot of content from my old sites, and slowly it will fill up. Also will be cleaning up the formatting of older posts. Until then, keep watching!

Choose. But choose wisely.

It appears there are two possibilities: a) Windows hardware manufacturers do not understand marketing or b) Apple is seriously undervalued because they make good hardware and know how to sell it.

Let’s compare this situation to a familiar occurrence:
It is time for your group to be seated at the dinner table in a crowded restaurant. Where should I sit? If I sit by Ron, then I have to listen to him complain about his ex again. Gene knows really good stories, but his wife Jenny tells them better. But Jenny likes to hang with Ron. And Pete, Mr. Comedy, hasn’t even shown up yet.

Who do I sit with? Choose well and I get a conversation worth having. Poorly and I’ll have to listen to drivel all night, wasting one of the few opportunities a busy father of three gets to get out of the house.


A friend recently asked for some help choosing a new computer for schoolwork. He’s starting a new school and his old PowerPC Mac is far too old to even watch the lecture videos. Windows is cheaper than Mac, so he said go ahead. And thus begins the nightmare of too much choice.

First off, things would have been fine if the people who repackaged the factory refurb 14″ had simply done their job. Factory refurb suggests someone has gone through it and fixed any issues. Nobody apparently checks that the battery actually fits. But this was not the case. This was discovered only after having fixed the faulty spacebar on the keyboard.

So I undertake the two hour round trip to return this machine. Note that this is why I do not purchase a windows box online, for this same reason: I have to check everything myself, since clearly nobody else thought it was their job to check it.

I did my homework up to this point: I have two machines lined up as alternatives in case they do not have an exact replacement. And sure enough, they do not. Okay, I tell myself, I am prepared for that.

So I start with he first one in the list. It takes them fifteen minutes to find it in the back while the kids wait in the car. So I go through and check it for everything I can think of, the battery, the keyboard. they comp me the ten dollars difference in price for my trouble.

As I walk out I realize the processor is not the same i3 the first had, it is a Pentium. That can’t be so bad, can it? One google search later reveals that the Pentium is very poor compared. What? After all that effort in making sure these people did their jobs, I still get it wrong.


Conversely, how about a Mac purchase? You need to know only two pieces of information: what form factor you need, and whether or not a little power is good enough or not. That is it. I can order it online because I know what I get will be correct the first time. Period.

A month ago I attended a local c# developer conference. Many people had Macs. Every one I asked said they just use them to boot Windows.

Out of all the manufacturers, it seems that the only contender on par with Apple is Samsung. And even they have six different laptop offerings.

What really confuses me is that a lot of people were expecting more from Apple’s WWDC address last week. Their stock price has been in free fall for months. Why? They clearly understand how to make solid hardware, not even opening the floodgates of the OS debate.

But in the same breath, I’ve been really annoyed at many of the hardware and software decisions Apple has been making lately. Xcode 4 is no better than Eclipse or Visual Studio. There is no 17″ MacBook Pro for my ailing eyesight.

So why isn’t anyone else trying this simplified hardware model in the Windows world?


A new machine purchase is something has to be lived with for at least a couple of years, let alone just one night. It’s clearly important. And yet it is still so complicated to decide the “right” one.

At that dinner, I handed the Pentium machine to Pete and had a grand old time. The machine seems to be working fine.