Subscribe to ...considered harmful        RSS Feed
- - - - -

Java: "Why isn't my input inputting?"

Icon Leave Comment
One of the most common beginner traps in Java is the behavior of the "convenience" methods of the Scanner class. The usual scenario is this: the assignment is to write code accepting inputs of various types and process those inputs in some fashion. For example the assignment might be to prompt the user for a String, a substring, an...
- - - - -

Switch Statements in Java

Icon 1 Comments
It has come to my attention, both here on DIC and in the real world, that many programmers do not actually know that there is a difference between a switch statement and a string of if-else clauses. This seems worthy of correction. It is simply not the case.

Before I begin, I should point out that this is really a somewhat academic question. In...
- - - - -

The Easy Way

Icon Leave Comment
Just to clarify: "the easy way", in the real world, is the way that you can get done, and up and running, immediately. "The easy way" is not the way that would be easier if you just figured out how to do it - don't go down that rabbit hole!
If you have to choose between the clever way and the way you know, do it the...
- - - - -

Everything is done wrong

Icon Leave Comment
Everything in software is done wrong. This is because, by the time you know how to do it right, you've already done it. The only exception is when you do the same thing over and over - and that's a DRY violation, and so wrong by definition.
- - - - -

Dynamic Programming Example: Nim

Icon Leave Comment
Inspired by Tom Morley's Combinatorial Games course, I've whipped up a tiny little solver for one of the combinatorial games. This might be a useful case study for anyone curious about the Dynamic Programming paradigm for algorithm design.

The code is up at github...
- - - - -

How to think about finding primes

Icon Leave Comment
Finding primes is a common exercise in programming, and for good reason: it's a good exercise that combines mathematical thinking with programmatic thinking. The exercise comes in various forms, most commonly "find the nth prime" or "find the first n primes". Also common is "find all primes less than n". It turns...
* * * * *

++ considered hazardous

Icon 2 Comments
The postincrement (++) and postdecrement (--) operators (hereafter called "postinc" and "postdec") are a perennial source of befucklement for new and intermediate Java programmers. In particular, people get snagged on complex exp...
- - - - -

The Programmer's Bookshelf

Icon Leave Comment
Following is a list of some titles that I've found beautiful or useful or both. I'm not gong to say much about them here, but they're all likely to give you interesting things to think about.

  • Introduction to Graph Theory (Richard Trudeau)
  • The Art of Computer Programming (Donald E. Knuth)
  • ...
- - - - -

"Write a code" considered painful

Icon 2 Comments
Pet peeve time: "code" in the software sense is a mass noun, not a collective noun. It has no plural. You don't eat "an oatmeal" or several "oatmeals", you eat oatmeal. In the same way, you don't write "a code" or "codes", you write code. If you mean a unified body of code that can be run...
- - - - -

dd considered terrifying

Icon Leave Comment
If you don't feel a little twinge of fear any time you start typing an invocation of dd, you should probably not have admin access to anything at all, including your refrigerator. dd is the primal Elder Sorcery of unix. It is absolutely terrifying in the raw power that it commands, and the utter disregard it shows for safety. Its very syntax...

  • (2 Pages)
  • +
  • 1
  • 2

Recent Entries

July 2014

S M T W T F S
  12345
6789101112
13141516171819
202122232425 26
2728293031