An introduction to the idea of an object in object-oriented programming, 3

Playing Cards Deck

In previous posts, we established the following:

  • Real-world objects have states and behavior. Objects in object-oriented programming (OOP) have analogues to these called fields and methods.
  • The fields of object-oriented objects parallel the states of real-world objects more or less faithfully. But the parallel between the methods of object-oriented objects and the behavior of real-world objects breaks down relatively quickly, for two reasons:
    • The first is that more often than not, the methods of object oriented objects do not represent things the object can do, but things that can be done to the object.
    • Second, objects in object-oriented languages don’t neatly distinguish between methods that act on the object in accordance with the nature of the object it is intended to represent (e.g. as a ‘pedal’ method might work on a bicycle object), and methods that act on the object precisely as a bundle of code within a computer program. Colloquially, one might say there is a blending together of larger reality that the object is meant to represent with that which it is, as a piece of code, actually a part of.

What are OOP objects?

What, then, are OOP Objects? Better yet, what is it that makes such objects unified in some way, rather than random bundles of code? And accordingly, what is it that makes some OOP objects better conform to the ideal of an OOP object than others?

To answer this question, let’s look at one more example:

public class Card {
    private final int rank;
    private final int suit;

    // Kinds of suits
    public final static int DIAMONDS = 1;
    public final static int CLUBS    = 2;
    public final static int HEARTS   = 3;
    public final static int SPADES   = 4;

    // Kinds of ranks
    public final static int ACE   = 1;
    public final static int DEUCE = 2;
    public final static int THREE = 3;
    public final static int FOUR  = 4;
    public final static int FIVE  = 5;
    public final static int SIX   = 6;
    public final static int SEVEN = 7;
    public final static int EIGHT = 8;
    public final static int NINE  = 9;
    public final static int TEN   = 10;
    public final static int JACK  = 11;
    public final static int QUEEN = 12;
    public final static int KING  = 13;

    public Card(int rank, int suit) {
        assert isValidRank(rank);
        assert isValidSuit(suit);
        this.rank = rank;
        this.suit = suit;
    }

    public int getSuit() {
        return suit;
    }

    public int getRank() {
        return rank;
    }

    public static boolean isValidRank(int rank) {
        return ACE <= rank && rank <= KING;
    }

    public static boolean isValidSuit(int suit) {
        return DIAMONDS <= suit && suit <= SPADES;
    }

    public static String rankToString(int rank) {
        switch (rank) {
        case ACE:
            return "Ace";
        case DEUCE:
            return "Deuce";
        case THREE:
            return "Three";
        case FOUR:
            return "Four";
        case FIVE:
            return "Five";
        case SIX:
            return "Six";
        case SEVEN:
            return "Seven";
        case EIGHT:
            return "Eight";
        case NINE:
            return "Nine";
        case TEN:
            return "Ten";
        case JACK:
            return "Jack";
        case QUEEN:
            return "Queen";
        case KING:
            return "King";
        default:
            //Handle an illegal argument.  There are generally two
            //ways to handle invalid arguments, throwing an exception
            //(see the section on Handling Exceptions) or return null
            return null;
        }    
    }
    
    public static String suitToString(int suit) {
        switch (suit) {
        case DIAMONDS:
            return "Diamonds";
        case CLUBS:
            return "Clubs";
        case HEARTS:
            return "Hearts";
        case SPADES:
            return "Spades";
        default:
            return null;
        }    
    }

    public static void main(String[] args) {
    	
    	// must run program with -ea flag (java -ea ..) to
    	// use assert statements
        assert rankToString(ACE) == "Ace";
        assert rankToString(DEUCE) == "Deuce";
        assert rankToString(THREE) == "Three";
        assert rankToString(FOUR) == "Four";
        assert rankToString(FIVE) == "Five";
        assert rankToString(SIX) == "Six";
        assert rankToString(SEVEN) == "Seven";
        assert rankToString(EIGHT) == "Eight";
        assert rankToString(NINE) == "Nine";
        assert rankToString(TEN) == "Ten";
        assert rankToString(JACK) == "Jack";
        assert rankToString(QUEEN) == "Queen";
        assert rankToString(KING) == "King";

        assert suitToString(DIAMONDS) == "Diamonds";
        assert suitToString(CLUBS) == "Clubs";
        assert suitToString(HEARTS) == "Hearts";
        assert suitToString(SPADES) == "Spades";

    }
}

The above provides an example of a Card class, again taken from Oracle’s Java tutorials. Let’s walk through it.

After the name of the class and an initial curly brace, two fields are declared: rank and suit. After this follow all the kinds of suits, then the kinds of ranks. This is followed by a special kind of method, called a constructor, which may be used by other objects to generate an instance of the Card class, then a pair of methods getSuit() and getRank(), which respectively provide, or return, the value of the suit and rank of a card object to whatever object makes use of, or calls, these methods. This pair of functions belongs to a larger class of methods called getters, whose naming and functionality follow a longstanding coding convention. This is followed by two boolean methods, isValidRank() and isValidSuit(), the methods suitToString() and rankToString(), and the main method.

Tomorrow, I’ll continue to explain how to understand objects and classes in object-oriented programming.

A short note on being, being true, and existence

Some statements describe states of affairs that can never occur. An example is the statement ‘2+2=5’, assuming the terms ‘2’, ‘+’, ‘=’, and ‘5’ retain their standard meaning. Another example would ‘John owns three dogs, but no canines’.

Other statements describe states of affairs that can occur, but can never be stated truly. The medieval logician John Buridan gives ‘no statement is negative’ as an example. Other examples include ‘I am not here’ and ‘I am not speaking’.

In other words, there is a difference between something being impossible on account of what it is and its being impossible because its existence or obtaining would entail a contradiction.

Therefore, there is a difference between essence and existence.

Author’s picks, April 28-May 4

This week’s recommendations include two posts.

The first, On passionate disagreement and self-identity, argues that the proximate passionate disagreement over a topic arises from the way an opinion on it challenges one to break with a certain understanding of the self, itself ultimately grounded in how the matter in question demands adherence to a certain way of life.

The second, A dilemma for a constitutionally protected, publicly funded right to abortion, argues from a distinction between private and public goods that abortion is  constitutionally protected if and only if it is not publicly fundable.

A dilemma for a constitutionally protected, publicly funded right to abortion

File:Womens March on Washington.jpg

Whatever permits being publicly funded by the state is deemed a public good by the polity that funds it.

Nothing deemed to be a private good can also be deemed to be a public good by the same polity.

Therefore, nothing which permits being publicly funded by the state is a private good

Whatever is deemed constitutionally protected under the justification of privacy is a private good. Since private and public are mutually exclusive categories, no such goods are public goods.

Public funding for abortion is required by law in multiple U. S. jurisdictions, and hence would be deemed a public good by those same jurisdictions.

By the same criterion, it cannot constitute a private good in contradistinction to a public one, and thus cannot be legally protected under grounds of privacy.

But the grounds on which abortion is legally protected are exactly those of privacy.

Thus, if abortion is constitutionally protected on the grounds of its being a private good, then it is not permissible to publicly fund it. Likewise, if abortion is publicly funded, and hence treated as a public good, it is not constitutionally protected.

Therefore, abortion may be publicly funded in U. S. jurisdictions if and only if it is not constitutionally protected.

File:Pro-Life Demonstration at Supreme Court.jpg

On passionate disagreement and self-identity

pelican-argument.jpg

I recently had a disagreement with a friend over what, to me, seemed to be a minor issue of academic interest, namely whether deliberately structuring a work of fiction so as to illustrate a moral message would degrade the character of the work. The other party to the conversation, an aspiring author, passionately disagreed with me on the matter, to the point of being offended by my view.

In what follows, I intend to focus not on the topic we disagreed over but on what the instance can tell us about how passionate disagreement itself arises and operates.

It’s clear that the fact that my discussion partner was aspiring to be a novelist is not irrelevant to the matter. More generally, a disagreement that brings into question a person’s understanding of self is more likely to be passionate than one that doesn’t. For example, moral disagreement generates more passion than disagreements in mathematics (except, perhaps, among some professional mathematicians, which only proves the general rule).

Passionate disagreement is thus likely to arise when the matter of disagreement is one affecting the self-understanding of one or more parties to the disagreement. When it affects only one party, the disagreement is likely to be one-sided, with anger on one side and bewilderment on the part of others. When it affects the self-understanding of multiple parties, the disagreement is likely to arise to the level of argument.

In this way, understanding how disagreement becomes passionate thus requires an understanding of how self-identification occurs.

Self-identification is a contingent act of understanding oneself in the light of a non-present, non-necessary goal or end. The act need not be one of explicitly modeling oneself after another – as a Christian, for instance, may model his life on that of Jesus, but may be more generally one of comporting oneself in accordance with what an end demands – as a writer, for instance, comes to have a given understanding of self according with his or her idea of a good work. The end sought is not a present, achieved one, but one that serves as a regulatory ideal of the nature of a certain good, which brings with it a corresponding concept of the self. The goal is non-necessary, not in that it is avoidable, but only in that the act of fully accepting and living in accord with it is. A king, for instance, may be born into his position, and societal pressures may be such that he lacks the choice of being anything other than a king. But such a king could still fail to seize the end of ruling a people rightly as his own end.

Because self-identification is consequent upon the acceptance of a given goal or end, it can never be understood as arising from something that lacks the nature of a goal. Thus, for instance, examples like being black, being female, etc. can only have the nature of identities inasmuch as they refer not to material qualities like gender or skin color, but rather to the implications those qualities have for a way of living. Hence, for any thing, there can only be a self-identification as that thing if there is a corresponding way of being that thing.

Inasmuch as passionate disagreement is disagreement about ends, which bring with them a corresponding conception of self, such disagreements are never merely factual, in the sense that they may be adjudicated by appeal to some present, objective state of affairs. Rather, passionate disagreement, inasmuch as it concerns a non-present goal, involves a concept of being that ‘stretches’ through time: a person who disagrees passionately is one whose vision not of a given moment, but of a lasting movement, is interrupted. Part of what makes this disagreement passionate is that ceding one’s vision involves the abandonment of plans, hence the abandonment of a possible future, of one’s self through time, of a way of life.

A matter of passionate disagreement thus confronts the individual with the task of breaking with their current understanding of self by confronting them to abandon a given end. The passion it invokes will be proportionate with the depth of the matter itself and the breadth of the self-conception of the person thus challenged. A person who is ‘full of himself’, as the phrase goes, to the degree that this person is able to be confronted, will have more frequent occasion to be angered. Absent the task of emptying out his self-conception, such a person’s only alternative will be that of hardening the self to outside influence. Hence, a person with a wide conception of core self-identity is likely to become either irascible or impenetrable. Correspondingly, societies which encourage a wide concept of core identity are more likely to generate such individuals.

Traditional religions provide a name for the break with the past which a matter of passionate disagreement demands: conversion. It is thus understandable that disagreement arises with the greatest frequency and intensity in matters that, in a broad sense, should be described as religious (from the Latin religare, ‘to bind back, to bind in response’). Passion arises when the task of binding oneself to a goal, and with it, the unification of one’s life through time, is interrupted by a call to break with one’s past and rupture one’s conception of self, a call to conversion. If we see this phenomenon arising with greater frequency in secular society and less in traditional religious settings, this would seem to suggest that the principal loci of modern religious sentiment may have navigated away from the dominant loci of traditional religious content, and hence are not what they once were.

How refutation works, 2

recreation board game competition war power battle decision sports chess strategy chessboard move contest planning draw games tournament debate challenge conflict putsch coup combat surrender confrontation check checkmate dispute chess pieces skirmish quarrel give up defeat struggle usurp rivalry resignation assassination stalemate game over treachery treacherous treason hostilities overthrow indoor games and sports tabletop game

As stated in the previous post on this topic, a refutation of a thesis consists in a proof that the thesis is not the case. This can happen in two ways. The first is by proving that the thesis is false. The second is by proving that it is ill-formed or non-sensical.

In a simple statement, the proof that a statement is false is a proof that what it attributes to the subject is not attributable to it. Such a proof may occur either solely by way of explication of the being of what is named by the subject and predicate, or it may occur by way of the addition of information about other beings. In the first case, a proof will concludes to a necessary conclusion about the nature of the things in question. In the second case, the conclusion may be merely factual. In every refutation of a thesis, an explication of the nature of what is named in its terms must play at least a partial role.

For instance, utilitarianism is a view that contains, as one of its constitutive elements, the thesis that what it is for something to be good is for it to be useful. But the nature of utility is such that something is only ever called useful with respect to a given end. Hence, whenever someone calls some thing useful, this must be read as saying that thing is useful for some end b, i.e. is useful for achieving b. But goodness is not only said with respect to some end. Some things are good without respect to ends, viz. those ends themselves. Therefore, utility is not goodness. Therefore, utilitarianism is false.

When a constitutive part of a view is refuted, such a refutation is ipso facto a refutation of any view or thesis that implies the original view, including any subspecies of that view.

A consequence of this is that no refuted view can become unrefuted by the addition of further nuance to that view, provided it remains a species of the originally refuted view. Hence, attempts to avoid refutation by the imposition of nuance constitute a failure to understand how refutation works. Given that this is the de facto means by which views are modified over time in academic literature on philosophical questions, the implication is that this failure of understanding is widespread.

Author’s picks for April 2019

What follows is a short list of my favorite posts from this month:

1. What is Philosophy Outside the Text?

This post provides an overview of the nature and scope of a new Medium.com publication that I’ve launched, Philosophy Outside the Text.

2. What makes philosophy difficult?

This post provides some background to the motivation of the Philosophy Outside the Text project. In it, I argue that there are two main difficulties to doing philosophy today: one is the inherent difficulty of the questions it asks; the other is the linguistic and institutional baggage associated with academic approaches to those questions. I argue in favor of a way of doing philosophy that still engages with the former while jettisoning much of the latter.

3. On New Age-ism and western appropriations of eastern religion

This post argues that the popularity of New Age religion is largely a function of the way it functions as a lever in an internal dispute between traditional western religion and post-enlightenment western consumerism. In several important respects New Age appropriations of eastern religion actually conflict with both traditional eastern and traditional western religions where they agree with the newer western paradigm.

4. A glimpse of early Hebrew Metaphysics in the book of Genesis

This post examines a passage from the book of Genesis, on the patriarch Jacob’s meeting Rachel and Leah, and shows how a mistake in the received text itself exemplifies a shift from a linguistic framework where the attribution of attributes to objects is variable and context-dependent to one where the association of an adjective with an object is predetermined in advance. I argue that this linguistic shift itself reflects a shift towards an ‘object-oriented’ ontology where attributes are themselves always thought of as dependent on particular substances.

5. The political philosophy of distributism: a very short introduction

This post provides an introduction to distributism, often regarded as a third way economic philosophy between capitalism and socialism. Particular emphasis is placed on Hilaire Belloc’s concept of the servile state – a form of oligarchic capitalism to which both capitalism and socialism tend.

6. Libertarianism, racism, federalism, subsidiarity, localism

In this post, I show that the identification of libertarianism with federalism constitutes a category mistake. Against this, I show that libertarianism admits of both federalist and anti-federalist forms, the latter of which is arguably the dominant one. Against this, I provide a positive defense of the notions of localism and subsidiarity that does not itself depend on libertarian individualism.