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

Switch Statements in Java

Icon 2 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. You may have been told at some point in your path to becoming a developer that a switch statement is "just like...
- - - - -

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.
* * * * *

How to think about finding primes

Icon 9 Comments
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...
* * * * *

Death Marches Considered Harmful

Icon Leave Comment
Some Lessons Learned...
- - - - -

My First Scala "Hulk Smash" moment

Icon 6 Comments
Scala has tuples. Great, I like tuples. Immutable sequences, quite handy.
Here's one:
scala> val triple = (1,2,3)triple: (Int, Int, Int) = (1,2,3)

Cool. So how do I get a value out of one of these guys? Like this:

scala> triple._1res6: Int = 1

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

June 2021

1314151617 18 19


    Recent Entries

    Recent Comments

    Search My Blog

    0 user(s) viewing

    0 Guests
    0 member(s)
    0 anonymous member(s)