Skip to content

Instantly share code, notes, and snippets.

Robert C. Martin unclebob

Block or report user

Report or block unclebob

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View healthcare_gov.cc
#include <iostream>
using namespace std;
int main(int ac, char** av) {
cout << "Welcome to healthcare.gov!" << endl;
cout << "If you like your doctor, you can keep your doctor." << endl;
cout << "Please enter your doctor's name:";
string doctor;
cin >> doctor;
cout << "We are sorry but, " << doctor << " is not one of the doctors you can keep." << endl;
View gist:2abcce451bafeab421f2

The first version of this blog was entitled Framework Whipped. I attempted to compare the code that uses a framework to the concubines in a harem. I thought my comments were clever and funny; but many people found them offensive.

I sincerely apologize for that offense, it was not intentional. I broke Don Norman's law:

“If you think something is clever and sophisticated beware-it is probably self-indulgence.”

I will try to avoid mistakes like this in the future. I appreciate the conversation about them, and hope that it can continue constructively.

Let me also say this. My original post had made women the butt of a set of very bad jokes. This had not been my intent. Nor did I realize I had done it. It was pointed out to me later; and I agreed and apologized. I believe that was the right thing to do.

@unclebob
unclebob / gist:5044827
Created Feb 27, 2013
Show how to eliminate duplication from Rectangle code.
View gist:5044827
package rect;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
public class RectTest {
static class Rect {
public double Left;
public double Width;
@unclebob
unclebob / apology.
Created Apr 27, 2012
Apology to Women Programmers.
View apology.
Today I gave a keynote at ACCU in Oxford. In the midst of it I made two (count them) two statements that I should have known better than to make. I was describing the late '70s, and the way we felt about the C language at the time. My slide said something like: "C was for real men." Emily Bache, whom I know and hold in high regard, spoke up and said "What about women?". And I said something like: "We didn't allow women in those days." It was a dumb crack, and should either not have been said, or should have been followed up with a statement to the effect that that was wrong headed.
The second mistake I made was while describing Cobol. I mentioned Adm. Grace Hopper. I said something like "May she rest in peace." I don't know that any of the words were actually demeaning, but the tone was not as respectful as it should have been to an Admiral in the United State Navy, and one who was so instrumental in our industry; despite what I feel about Cobol.
I am a 59 year old programmer who was brought up
@unclebob
unclebob / commatize
Created Feb 7, 2012
A function to format a number with commas
View commatize
(defn commatize [n]
(if (nil? n)
""
(let [s (str n)]
(apply str
(reverse (drop-last
(interleave
(reverse s)
(take (count s) (flatten (repeat [nil nil \,]))))))))))
@unclebob
unclebob / mad_libs_test.clj
Created Oct 18, 2010
Simple Mad Libs app.
View mad_libs_test.clj
(ns mad-libs-test
(:use clojure.test midje.sweet))
(defn find-prompt [t])
(defn get-response [t])
(defn mad-libs [text]
(let [
[pre prompt post] (find-prompt text)]
(if (nil? prompt)
@unclebob
unclebob / prime_factors_test.clj
Created Oct 18, 2010
Prime factors Kata in Clojure
View prime_factors_test.clj
(ns prime-factors-test
(:use clojure.test midje.sweet))
(defn factors-starting-at [f n]
(cond
(> f (Math/sqrt n)) (if (= n 1) [] [n])
(= 0 (mod n f)) (cons f (factors-starting-at f (/ n f)))
:else (recur (inc f) n)))
(defn prime-factors-of [n]
View Wrapper.java
public class Wrapper {
public static String wrap(String s, int col) {
return new Wrapper(col).wrap(s);
}
private int col;
private Wrapper(int col) {
this.col = col;
}
View 1 WrapperTest.java
@Test
public void wrapJustBeforeWordBoundary() throws Exception {
assertThat(wrap("word word", 4), equalTo("word\nword"));
}
View WrapperTest.java
@Test
public void wrapWellBeforeWordBoundary() throws Exception {
assertThat(wrap("word word", 3), equalTo("wor\nd\nwor\nd"));
}
You can’t perform that action at this time.