Jon Aquino's Mental Garden

Engineering beautiful software jon aquino labs | personal blog

Monday, September 16, 2013

Visualizing a 4D hypersphere

My coworker Chris Brewer created a visualization that allows you to experience a 4D sphere (or "hypersphere") by zooming around a 3D space.

Set Viewing Distance to 1000 and choose Map 1.

What appears to be a spherical container is actually the "equator" of the hypersphere. The three spokes are meridians (lines of longitude), and they meet at one of the poles. Mind-blowing.

9:44:27 AM jona: so tell me what this is exactly - it seems that I'm inside a sphere that gets distorted as I move around it
9:45:00 AM BrewerC1: Sure, so do you know what a hypersphere or 4 dimensional sphere is?
9:45:38 AM jona: is that something where x^3 + y^3 + z^3 + a^3 = 5?
9:45:49 AM BrewerC1: Yeah, exactly like that
9:45:52 AM BrewerC1: er except
9:45:55 AM BrewerC1: squared
9:45:57 AM jona: ok
9:46:29 AM jona: how does the x, y, z that I'm moving around relate to that equation's x, y, z, and a?
9:46:58 AM BrewerC1: so in this spaces, you are moving through 4d space, but with the constraint that you are always R^2 units from the origin of the space
9:47:06 AM BrewerC1: which confines you to the surface of the hypersphere
9:47:11 AM jona: ok
9:47:19 AM BrewerC1: So the surface of a sphere is a 2d space
9:47:25 AM BrewerC1: and the surface of a 4d sphere is a 3d space

Thursday, September 12, 2013

Some thoughts on interviewing

I am interviewing candidates for two Application Engineer positions at Ning, and there are a few thoughts that come to mind as I have been doing this.

I'm looking for two things when I look at a candidate's code: style and substance.

Regarding style, is the code clear, well-documented, unit-tested (ideally) and maintainable? Is this candidate's code going to be pleasant to dive into and maintain, or is it going to be a mess of logical spaghetti that's going to be a headache to modify?

Regarding substance, does the candidate have deep knowledge in some area that they can bring to the team? Things like Computer Science knowledge, Unix knowledge, OO expertise?

I am coming to believe that a good grasp of English grammar is quite an asset. If you know what a noun and a verb are, you know what I mean when I say that good object names are nouns and good method names are verbs. And, funny as it sounds, I am a believer that good names are the heart of a good design. If you have well chosen names, your design can scale in size to a large codebase; not to mention, good names are a sign that you are thinking clearly.

I also believe that adding doc blocks to every class, method, field, and constant is very helpful to future maintainers (including yourself). This seems to be contrary to majority opinion – most programmers are of the opinion that well-chosen method names are enough. However, I would much rather make modifications to a class that is documented throughout than one without any doc at all. A well-chosen name is good, but accompanying documentation is even better. Sometimes a phrase won't do – you need a sentence or paragraph. Look at the Java SDK documentation – every class, method, and field is documented – it's great. In response to the objection that the doc basically repeats the function name (/** Gets the color. */ for getColor()), see "the ideal comment" in How to Write Doc Comments for the Javadoc Tool for ideas on how to make comments more helpful.

Friday, September 06, 2013

Trying out Sublime Text text editor

After more than 6 years of using jEdit as my text editor, I'm trying out a new one on the recommendation of my co-worker, Danni McNinch. It's pretty slick. You do Command-P to goto anything. Also it's quite pretty, at least on a Mac.

Things I like better than jEdit:

  • Close an HTML tag using Option+Command+.
  • Looks better overall.
  • Goto Anything is faster and more reliable than jEdit's Fast Open plugin. Update: jEdit's SmartOpen plugin seems to work pretty well, although there's a bug preventing it from working using the Mac OS X theme (workaround is to switch to a different theme).

Things I miss from jEdit:

  • Free SFTP plugin.
  • Highlight Occurrences plugin to highlight all occurrences of any word that the cursor is on. The highlight remains after you leave the word. You can also highlight other words, which will appear in different colors.
  • Splitting windows. It's a lot simpler than the Sublime Text Origami plugin.

Update: I switched back to jEdit. Sublime is good (and it looks better), but I was just too used to my old editor and missed the few things that it did better.

Thursday, September 05, 2013

UX: Is it better to ignore errors or fail loudly?

This question came up in a discussion I was having with my co-worker Chris Brewer. Suppose /foo is valid, but the user asks for /foo/bar. Should we just show /foo, or show a 404?

In other words, which is better: being nice or failing loudly?

Superficial love or tough love?

Arguments for the former: Postel's Law. Null Object pattern.

Arguments for the latter: Throwing exceptions. Fail loudly.