Saturday, October 22, 2022

This Is How I Would Say It

 This is a follow-up to a previous post, where I mused about what counts as "good" and "bad" writing. I thought it might be interesting to try to document some of the things that I find myself explicitly thinking about when trying to write something important enough to warrant more care than just catching typos. I'm sure that such checks are common to a lot of people who write often. 

Keep structures parallel

 Although I don't always catch them initially, I check to make sure that I am using structures that are parallel when creating lists. In other words, instead of this:

Many things can influence your teaching style, such as what you are teaching, the time of day, and are you familiar with the student population.

do something like this:

Many things can influence your teaching style, such as the focus of the lesson, the time of day, and your familiarity with the student population.

 Keeping things parallel helps avoid grammatical weirdness and makes the writing flow a little better.

Avoid ambiguous pronouns

This is still a work in progress for me. Pronouns are incredibly useful in keeping sentences from getting overly clunky by repeating a huge noun phrase over and over:

(Clunky) Students who have learning styles that differ from your teaching style may have trouble keeping up with the class because students who have learning styles that differ from your teaching style will require extra cognitive effort to be successful.  

(Better) Students who have learning styles that differ from your teaching style may have trouble keeping up with the class because they require extra cognitive effort to be successful.* 

 But there are times when they can become ambiguous or even confusing. [Note that the previous sentence could have been, perhaps more clearly, written as: But there are times when pronouns can become ambiguous or even confusing.] Adding additional words to a sentence or moving sentences around during the editing process can sometimes cause the referential integrity to "break" or to be less clear than it was when the text was first written. 

Vary sentence length

Although it is common for academic writing to be quite verbose, slogging through pages and pages of a never ending river of paragraph-long sentences can be exhausting. The text needs to breathe. This doesn't mean that long sentences are bad and should be avoided at all costs. Rather, there should be a variety of sentence lengths scattered throughout the manuscript. Resist the need to "embellish" short sentences with additional words just because they don't seem "long enough" for "academic" writing. Clarity of thought, not density of text, is the goal. 

 Don't reference the entire field (unless warranted)

 This may be something that was more common when I was in graduate school than now, but it is a bit of a pet peeve (perhaps because I can't do it the way others can). It is great to have an encyclopedic command of the literature, but stringing several lines worth of references to every single statement usually just makes the text harder to read. I'm talking about things like this:

Students who have learning styles (Academic, 2007; Bigwig, 2011a; Bigwig, 2011b; Bigwig, 2015a; Bigwig, 2015b; Bigwig, 2015c, Bigwig & Student, 2016; Bigwig & Colleague, 2017;  Bigwig & Mentor, 1983; Colleague, 2020; Colleague, 2022; Mentor, 1962; Obligatory, 1977; Student, 2018; Zeitgeist, 2022; also see Kirkum, 2009) that differ from your teaching style (Celebrity, 2005; Heavyweight, 2009a; Heavyweight, 2009b; Hotshot, 2017; Hotshot & Celebrity, 2019; Somebody, 2013; Somebodyelse, 1992; Kirkum, 2008) may have trouble keeping up with class (Notable, 2003; Notable & Somebody, 2004; Notable & Student, 2005) because they require extra cognitive effort (Hotshot, 1999; Personage, 2000; VIP, 2013; Kirkum, 2009) to be successful.  

 Of course, there may be a legitimate need to refer specifically to many individual studies, such as to counter the argument that there has been little research into idea X, for example. But if you are just trying to prove that you have done the reading, it is probably better to do that in the strength of your argument rather than the size of your bibliography. I prefer to just list an example or two if I want give a nod to a general area of the literature ("...... learning styles (e.g., Academic, 2007; Bigwig, 2011)...."). 

Don't try to cram everything in

This is another tough one. When we were high school students, it seemed like we were always trying figure out how to make our term papers "long enough" to meet whatever requirements the teacher had set. Page limits were like unachievable goals that you would give anything to reach. ("How could anyone ever right ten whole pages about <insert topic here>?")  

Once you are reporting on your own work, however, it is a completely different story. ("How could anyone ask me to boil down my masterwork to a mere ten pages?") This is particularly true if you are trying to create a paper out of a longer manuscript such as a dissertation. Of course, it is possible to publish things piecemeal, but those pieces need to be able to stand on their own. 

One of the best pieces of advice I heard is to keep the literature review extremely short. Your job is to put the study in context, not to recapitulate the history of the field. Get right into the meat of what you did, pulling relevant literature into the methods and results sections as needed. That may not be the appropriate approach for a dissertation itself, but for a journal article or chapter, your reader will likely thank you.

 

 

*The concept of learning style as it is usually discussed does not have much support in the research literature.

Friday, October 21, 2022

I Wouldn't Say It Like That

 I saw a presentation by Chelsea Troy the other day on the topic of technical debt in software development teams. One of the points she made is that technical debt is not really about "bad" code, but more about the maintainability of the code. Poorly written code is hard to maintain, which is why it can be problematic. But in trying to identify poorly written code that will cause problems, people sometimes conflate the robustness of the code itself with the particular coding style of the developer (i.e., the "that's not how I would have written it" argument).

 That presentation, and the fact that I've been looking at a lot of drafts of academic papers recently, got me thinking about academic writing. How much of our impression of the writing of others is colored by the difference between what they wrote versus our internal "how I would have phrased it" sense of style? I tend to err on the side of accepting what was written if it isn't "wrong" in a technical/grammatical sense or "unclear" (unless I'm a co-author, in which case I might suggest an alternative phrasing), even though there may be many places where I felt I could have written it "better." But where's the line between our idiosyncratic preference for blue when the writer has given us red, versus legitimate feedback on a passage that virtually any other academic would have also found wanting?

I don't have an answer (though Steven Pinker's wonderful book The Sense of Style might). I know that I overuse parenthetical statements in my own writing and have been accused of being too "informal" by some reviewers. I happen to think that too much writing is overly formal when it doesn't need to be. Writing needs to be clear. Sometimes that means being very short and to the point. Other times it may require an extended description with carefully chosen words that precisely delineate the nuanced argument that you are undertaking. (See what I did there?)

I'm not a fan of trying to "academify" writing just for the sake of it. That said, one expects a certain style when reading an academic paper versus a novel or a news story. Although I would be OK with it, I can imagine that some would consider the following sentence too informal for an academic paper (though perhaps not for an academic presentation):

There are as many teaching styles as there are teachers.

One could rewrite the same sentiment in a slightly more "elevated" style:

There are as many styles of teaching as there are practitioners of the craft.

Whether the second sentence is an improvement over the first likely depends on your tolerance for informality in academic writing, as I can imagine many feeling that the first is too pedestrian to be called "well-written." But is it "bad writing" such that it needs to be "fixed"? I'm not sure.

How about an extreme version:

The variance in the distribution of operationalizations of instructional approaches is isomorphic to the variance in the distribution of instructional practitioners.    

 Unless the author is literally comparing statistical distributions of teaching styles and teachers, I would argue that this version is further from "good writing" than the first. It is needlessly opaque. In other words, I wouldn't say it like that.


Sunday, March 6, 2022

Pubsub Crawl

Today was another foray into Google Cloud Functions. This time, my goal was to begin to string things together using Google Pub/Sub. This type of approach forms the backbone of modern "serverless" workflows. 

My final use case requires hitting an API (with the appropriate credentials), retrieving a list of file URLs, and downloading those files to a cloud storage location. Because my brain is not as agile as it was when I was younger and I can't hold too many things in mind at once, I like to break things down into smaller chunks to help with troubleshooting. (This is probably a good practice regardless of age.) Previously, I had been interacting with things via gcloud commands in the CLI, but I broke down and decided to use the console for this bit.

My first hurdle was hitting an API with credentials. When experimenting with cloud functions before, I was always using the –allow-unauthenticated flag, which is really not good practice. I spent a bit of time trying to figure out the most secure way to do things, but ended up going down lots of rabbit holes in the Google's IAM documentation. At the end of the day, it seemed like creating a service account and requiring authentication seemed like the safest bet.
 
By default, Google Cloud Functions use the App Engine default service account, which has an "Editor" role in the project. This is considered a "primitive" role (along with "Owner" and "Viewer") and is not as secure as using more granular permissions. Because I knew that I would need to invoke the function, send pub/sub messages, and access an API key stored in the Google Secrets Manager, I created a new service account with just those permissions. This account will be linked to the Cloud Function.
 
Previously, I had been using the fake data API at http//:jsonplaceholder.typicode.com for practice. That's a great resource, but doesn't require authentication. For that, I turned to https://www.alphavantage.co/, a site that allows you to create an access token for their stock tracker. One can receive stock information by hitting an http endpoint with a stock symbol and the access token. 
 
I created key/value pair in the Google Secret Manager to hold the token, and then spent a while trying to get everything to work, following some of the sample scripts in the Google documentation (https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets). My first bare-bones function literally just tried to return the secret value. Once I could grab the apikey value from a function, I rewrote the function to iterate through a list of stock symbols and create URL strings that incorporate the stock symbol and apikey. 

The next step was to create a pubsub topic and subscriptions, which I did through the console interface. The idea is that the URLs I had just created could be sent as pubsub messages to other cloud functions that would do the actual downloading. Although creating the topic and subscriptions was relatively straight-forward, it took 15 versions of the cloud function script to finally get things working. At least half of the revisions were due to typos and/or forgetting to import a package, with the rest being logical errors or variable issues. 
 
So, now I had a cloud function that could retrieve a stored secret, create appropriately formatted URLs, and send them to a pubsub topic as individual messages. The next step is to create a cloud function that is triggered by those messages and downloads the files. 
 
But that's a task for another day.
 

Saturday, March 5, 2022

How to (Not) Function in the Cloud

I spent a bit of time today poking around with Google Cloud Functions. The idea is very similar to AWS Lambda -- both tools allow you to run small, single purpose Python (or other) scripts in a serverless environment, avoiding the overhead of spinning up a compute instance, installing the appropriate software, configuring access, etc. 

I first worked through the "Hello World" tutorial, which was essentially a function that would return "Hello <users name>!" or "Hello world!" message when the associated http endpoint was hit with or without a "name=<user name>" argument in the http request. That went fairly smoothly, though I try to force myself to type rather than copy/paste code when following tutorials, so there were a good deal of errors due to typos the first few tries.

But, like so many other things, there is usually a huge gap between the "Hello world" example and anything even somewhat approaching a real use case. This may be unavoidable given how many moving pieces there are in any "real" cloud deployment. 

Because my eventual use case was to hit an API and download some data, I decided to tweak the "Hello World" program bit by bit to get closer to that. Luckily, there is a wonderful "fake api" available at http://jsonplaceholder.typicode.com/ which is great for testing. 

It took a good hour of trial and error (and fixing more typos) to figure out which part of the sample "Hello World" code was just part of the sample script and which was needed as part of the Cloud Function deployment. (It turns out that there wasn't much "boilerplate" stuff needed.) It also took a while to realize that some Python packages that I needed weren't part of the standard library (and had to be specified in an associated requirements.txt file), while others were, and putting them in the requirements.txt file confused things. 

I was working from the command line to deploy the scripts, and making changes to them in a text editor. It takes about ~2 min to deploy the script after making changes, and there were many times when I forgot to save the most recent changes before redeploying, confusing myself in the process when things didn't work as anticipated. 

Luckily, I eventually realized that there is a good deal of logging that the service provides through the logs explorer (or through a gcloud command), which greatly improved my troubleshooting process. I think it took me 11 deployments to create a simple function that would hit the fake api and pull out the fake user names from the response json.  

Wednesday, March 2, 2022

Kindly Inquisitors

(Wrote many months ago, but just posting now.)

 I recently finished an interesting book by Jonathan Rauch called "Kindly Inquisitors: The New Attack on Free Speech". (Although the subtitle has the word "new" in it, the book was originally published in 1993, with a second edition in 2013.) The basic gist of the argument is that, in almost all cases, the best antidote for bad ideas is not censoring the ideas, but rather ensuring that free speech is protected so that good ideas come to the fore and eventually win out in the marketplace of ideas. 

Rauch identifies five possible decision-making principles and walks through the pros and cons of each:

  • The Fundamental Principle -- a person or group of people are in charge of determining what is true ("If the king decrees it, it is so")
  • The Simple Egalitarian Principle -- any sincerely held belief is true ("If that's what you believe, it is true for you")
  • The Radical Egalitarian Principle -- similar to the simple principle, but with special weighting for beliefs of marginalized group ("You must be right, because you're <name of marginalized group>")
  • The Humanitarian Principle -- any belief is OK as long as it doesn't cause harm to someone else
  • The Liberal Principle -- beliefs must be subject to public criticism to determine their truth

The bulk of the book is spent defending the final principle, the Liberal Principle, as the best option, even though this can mean that the process will be messy and feelings will get hurt along the way. Ideas that some (or many) would consider "hate speech" would be part of the mix at times. This is a necessary cost, according to Rauch, to avoid the problems inherent with adopting any of the other principles.