Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

``Die CIS scum''

Name: Anonymous 2012-10-17 6:06

Amazing programming explanation using examples which respect people of all genders! I think everyone engaged in IT discussion and teaching should follow this style of highly tolerant and privilege-aware writing. ``Transgender'' and ``homosexual'' should become new ``foo'' and ``bar'' in educational code snippets.

---

I'll take a crack at the Factory Method pattern:

The Factory Method pattern uses a single method to construct objects according to some run-time data rather than hardcoding with new. For example, you may have a program which in various places may need to create a MalePerson or FemalePerson object depending on input, so you'd naturally pepper your code with:

if (gender.equalsIgnoreCase("male")) {
      return new MalePerson(name);
} else {
      return new FemalePerson(name);
}


Now what if you need to handle instances of TransgenderPerson or UndeclaredGenderPerson, etc? You'll have to go back and add those conditions to each place that conditional object creation occurs.

So, instead we employ the Factory Method pattern to be able to just call

PersonFactory.makePerson("male");

This encapsulates all creation of objects based on run-time data behind a single interface.

In Java this might be implemented as

public abstract class Person {
    protected final String name;
    public Person(String name) {
      this.name = name;
    }
}

public class MalePerson extends Person {
    public MalePerson(String name) {
      super(name);
    }
}

public class FemalePerson extends Person {
    public FemalePerson(String name) {
      super(name);
    }
}

public class PersonFactory {
    public static Person makePerson(String gender, String name) {
      if (gender.equalsIgnoreCase("male")) {
          return new MalePerson(name);
     } else {
          return new FemalePerson(name);
     }
    }

}


The declaration of the corresponding classes in Common Lisp is pretty straight forward:

(defclass person ()
  ((name :initarg :name :reader name)))

(defclass female-person (person)
  ())

(defclass male-person (person)
  ())


But, in Common Lisp, methods do not belong to classes, but to generic functions which dispatch specific methods based on their arguments. There is even EQL specialization on methods, which allows for methods to be dispatched based on the equality of their arguments to a specified value. So our PersonFactory in Common Lisp would look like:

(defgeneric make-person (gender name))

(defmethod make-person ((gender (eql 'male)) name)
  (make-instance 'male-person :name name))

(defmethod make-person ((gender (eql 'female)) name)
  (make-instance 'female-person :name name))


You'll notice that Common Lisp lacks a new operator. That's because there are no "constructors" in the usual sense of the word. The standard way of creating objects is to pass runtime data either a class object or symbol that is the name of the class object to the factory method MAKE-INSTANCE.

Now, that's all well and good, but let's look at what happens when we want to add the feature to create a TransgenderPerson to our factories. In Java we have to open the PersonFactory.java class file and modify it:

public class PersonFactory {
    public static Person makePerson(String gender, String name) {
      if (gender.equalsIgnoreCase("male")) {
          return new MalePerson(name);
      } else if (gender.equalsIgnoreCase("transgender")) {
          return new TransgenderPerson(name);
      } else {
          return new FemalePerson(name);
      }
    }

}


But in Common Lisp, we do not need to modify anything. We can just extend the MAKE-PERSON generic function with a new method:

(defmethod make-person ((gender (eql 'transgender)) name)
  (make-instance 'transgender-person :name name))

Name: Anonymous 2012-10-17 8:29

>>3
A white heteronormative cisgendered CEO professor and Baptist preacher was teaching a class on Karl Rove, known Christian.

“Before the class begins, you must get on your knees and worship Jesus Christ and accept that you too can become straight through daily prayer, self-flagellation, and eating Chik-Fil-A every day!”

At this moment, a brave, trans-Asian, self-diagnosed pansexual demiromantic vegan multisouled person who had been free of all animal products and only bought products at the local transgender co-op boldly stood up, holding a glass filled with some white liquid.

“Hey, Professor, what is this?”

The arrogant professor smirked like a rapist and smugly replied “It’s clearly milk, you crazy faggot. What the fuck does milk have to do with political science?”

“Wrong. It’s an all natural vegan soy almond kombucha latte. No animals or transpeople were harmed or raped in the making of this product.”

The professor was visibly shaken, and dropped his chalk and copy of the Wall Street Journal. He stormed out of the room, clearly planning some kind of rape. The professor realized that he had been playing into the hands of the kyriarchy of CEOs, investment bankers, the Religious Right, and psychiatrists. He then killed himself. The proper term for this is “trans-dead”.

The students checked their privilege, all diagnosed themselves with autism and gender identity disorder and joined the Gay-Straight Alliance. An obese trans-eagle furry otherkin waddled into the room and tried to perch upon the American Flag, bending the flagpole in the process. All parties involved gave up meat, Christianity, and the right to bear arms.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List