Jane Austen on PEP8: Tips from an English Major on Writing Better Code

Video in TIB AV-Portal: Jane Austen on PEP8: Tips from an English Major on Writing Better Code

Formal Metadata

Jane Austen on PEP8: Tips from an English Major on Writing Better Code
Title of Series
Part Number
Number of Parts
CC Attribution 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Release Date

Content Metadata

Subject Area
I have two English degrees, and I’ve identified some concrete ways this makes me a better developer. This talk will discuss how we can take lessons from literature to write more readable code, make better tests, and create more usable websites. I’ll compare Two Scoops of Django to Strunk and White’s The Elements of Style, that familiar freshman comp text, to explore how they are more alike than they are different. We’ll discuss the importance of readability, creating a “story arc” in your tests through good user stories, how variables names have characterization, and the importance of whitespace and good formatting to everyone. I’ll also compare PEP8 to the MLA Handbook; there’s a reason both disciplines have a style guide!
Computer animation
Graph (mathematics) Open source Software developer Multiplication sign Faculty (division) Degree (graph theory) Revision control Blackboard system Data management Collaborative software Meeting/Interview Personal digital assistant Videoconferencing Website Self-organization Quicksort Writing Physical system E-learning
Point (geometry) Slide rule Presentation of a group Machine code Link (knot theory) Observational study Markup language Multiplication sign Source code Electronic program guide Computer font Public key certificate Rule of inference Twitter Hypothesis Frequency Latent heat Different (Kate Ryan album) Authorization Codierung <Programmierung> Endliche Modelltheorie Dependent and independent variables Software developer Digitizing Gender Gradient Interactive television Bit Line (geometry) Entire function Hand fan Degree (graph theory) Type theory Uniform resource locator Computer animation Website Right angle Quicksort Game theory Family Writing Spacetime
Group action Functional (mathematics) Building Machine code State of matter Plotter Decision theory Frustration Mereology Event horizon Revision control Frequency Programmer (hardware) Irreversibler Prozess Software testing Error message Social class Form (programming) Software developer Electronic mailing list Sampling (statistics) Demoscene Degree (graph theory) Process (computing) Telecommunication Order (biology) Website Family Resolvent formalism Arc (geometry)
Computer animation Software developer Order (biology) Software testing Computer font Social class
Programmer (hardware) Functional (mathematics) Machine code File format Average Multiplication sign Authorization Virtual machine Video game Bit Spacetime
Point (geometry) Complex (psychology) Slide rule Machine code Perfect group Decision theory Multiplication sign Mass Neuroinformatik Programmer (hardware) Goodness of fit Software testing Series (mathematics) Descriptive statistics Position operator Social class Addition Software developer Prisoner's dilemma Line (geometry) System call Compiler Hand fan Data mining Universe (mathematics) Text editor Game theory Writing Reading (process) Row (database)
Point (geometry) NP-hard Trail Complex (psychology) Functional (mathematics) Group action Machine code Computer file Length Multiplication sign Combinational logic Mereology Turtle graphics Rule of inference Formal language Programmer (hardware) Goodness of fit Mathematics Coefficient of determination Different (Kate Ryan album) Term (mathematics) Computer configuration Computer programming Energy level Codierung <Programmierung> Metropolitan area network Physical system Social class Mainframe computer Area Meta element Multiplication Bit Line (geometry) Variable (mathematics) Proof theory Arithmetic mean Word Message passing Integrated development environment Hash function Personal digital assistant Pattern language Right angle Musical ensemble Quicksort Resultant Writing
have but but the black and of the and thank you for the the and the and the fact that of the child that you so much for for having me I'm I'm really excited to be here so as it
started about me I am way see I'm a developer at the University of Texas where I've been in the past 4 years and now and try to slow down and I can talk at fast for the rest of the talk it integrate and but before I
became a developer I really wanted to be an English professor I got my bachelor's degree from Harvard University in 2007 and while I was there I did a lot of tech things I was the webmaster for my professors websites which was maintained in dream weaver and sort on is that drive those were good days and I also worked in a technology center where I a screencast videos to teach professors had use blackboard and which is an online course management system if you've not if not familiar with it and I'll settle for an integrated into the classrooms in ways that I thought were all then because I still wanted to become professor lazy and I wanted to teach and write scholarly articles about literature like articles about in Austin I got a master's degree in English from Texas a & M University and that's just a couple of hours on the road in College Station graph familiar with Texas geography and again no I steered myself into more tech roles I worked in the technology center instead of being a teaching assistant which is what you're supposed to do and I helps faculty screencast make videos and using Moodle which is an open source version of Blackboard and but I know it open source was at the time I just knew it was free and then I also help them integrate GoogleDocs as a collaboration tool in the classrooms I also worked for an organization called the world Shakespeare bibliography which and takes all the articles they're written about Shakespeare puts them all into 1 place as free equal and while I was there I wrote summaries on these articles that I had to use an XML mark so that they can be copied and pasted into our administrative site I didn't know that that was kind of like food then in 2009
I took a workshop on TI the Text Encoding Initiative TEI is an XML markup language that's specific to manuscripts so this is an example of what it looks like on the left you have what is being transcribed and on the right you have the TEI XML and there's also some links at the end of the presentation and all the slides online so if you're really interested in TEI you can dive deep into that and that is really awesome and specific tags for manuscripts so there's a type for the publisher the data the author of the title but then you can do really neat stuff for written manuscript so like there's a way to represent an marker that Mark Twain scratched through a line and then wrote something else about it which is really neat and I wanted to make a site using TEI it whenever I was in grad school talk about Jane Austen fan fiction and that's actually a really rich more calls you if you if you will and not go too far into that I was very briefly tell you that am there these like Twitter accounts were people will will become the different characters from printers for example and they will like over a period of time act out the entire novel and it's it's really find people get into this so like you think that you know you're gaining work driving Honda whatever and you have a net using often people that Israel fans but that I I know how to make a website I was really talking find intact interest in it but I didn't think of myself as tech-savvy despite like everything I've told you about time things I was doing and I did not register a URL I didnt understand with CSS was and if there were tutorials out there I didn't know where they were I wish that I could go back and meant for myself in 2010 as Barbara about this this morning because now there's a generous tutorial and I could say 2010 leads you should do this because gender would be perfect for what you wanna do but I know that and I had impostor syndrome before even got started so instead of doing my amazing website on Genossen fan fiction I wrote a paper on the US and the antigen and with that I got a digital humanities certificates which is still ironic to me that that even was allowed to happen this talk Jane Austen on Feb 8 is sort of my do over it it's a chance for me to talk about literature and tech in 1 place which I've never gotten to do before so this is for the other English majors the bookworms the lovers of literature the people with humanities agrees to struggle with that question so you ever use history degrees it also the people who have asked that question of their colleagues that don't have stand backgrounds who's been confused about how someone might start out a psychology major and wind up writing high and the truth is that the technology world and humanities world are not very far apart a lot of the concepts that English majors have perfected over years of writing thesis paper is we do use in our daily lives of developers this talk isn't really about what coders can learn from humanities majors or vice versa it's more a demonstration of the overlap between those 2 disciplines and study in their compatibility and how they complement 1 another so this is a game called guess the source
I could have a quote from a style guide and you guess where comes from and this is that the Jane Austen handwritten 5 inch leaves a little bit difficult to read but I just can't resist so it says I'm always use to spaces after a sentence ending period any guesses actually eat and I think we can rule out so that the 1st clue the writing code has anything to do with writing a research paper or essay that they also says that when writing English follows Strunk and White's and that it doesn't even cite something white interactions as The Elements of Style it just assumes that you know what that means so if you don't know what we mean when we say Strunk and White's something my refers to a book called The Elements of Style which started out here is an American English style guide that was 1st published in 1959 now I hate this particular line from Pat Bates because in your regular writing you should never do this this this this this summer days of monospaced fonts and typesetting and we'll use models response on the internet or in our publishing anymore except in code so you should follow this rule when you're writing code that you should break it everywhere my brother points at all Strunk and White tho is that it's a guide it written to help people write clearer more concise more consistent and more readable English Pepe is a guide for helping people write clearer more concise more consistent and more readable code so let's talk about
plot driven development but testing testing is a perfect example of where some concepts from your literature class can come in handy so you might remember this from your like you know great books 101 of something but this is phrase through it and this is just a basic illustration of a story arc you have exposition which is where you learn who the characters are where your rats and the basics of what's happening you have the rising action which is where the problem gets introduced and we start experiencing the events that lead us to the climax now this the climax is the most exciting part of the plot this is where the thing happens that changes the main character states so in pride and prejudice this the scene where Mr. Darcy finally proposes to Elizabeth but she says that she would not marry him if he were the last man on and she starts to question herself and the following action is when things began to unravel and fall into place so we figure out the mysteries is actually a nice guy he did her family this huge favor and then we have the where they get married and everything is happening you will we can make use of this art in testing as well In fact that was the idea that that was where I got the idea for this talk I was at pipeline earlier this year and I was in Harry principles and testing tutorial and I realize that the example of a functional test that he gave was an example of a plot so this is a more formal version of my answer to a question I got after that tutorial when I was chatting with someone told them I have an english degree and said so do you agree use your English degree the so in irreversibles example of a functional test he takes us through the plots for the period of someone's journey through this sample to do list act his example has exposition he introduces us to Edith who has heard about this fancy to do list yeah it has rising action Edith locates the AP she goes and she finds a way around and she makes a decision that she's going to enter an item then there's the climax Edith states is for ever changed but I xi forms that she performs the crucial pivotal action and adding an item to her to do list there's the following action she entered the item she sees that it's an entered and saved and then the denouement it is happy and she goes back to sleep but it Harry ever write a single actual functional test he writes out this whole story that follows that plot arc this way he knows what path the user needs to take through his sites what they'll encounter what they'll do and how Wall resolve he can write tests to test these steps happened and then he writes the code a path that we all know what testing itself and the path that Edith takes to the out those that's her plot and even is a character in another world it might be the protagonist in the novel and this particular journey might be a chapter in what I hope is an otherwise more thrilling story the ability to write a complete and convincing user story though is helped by having studied character development and plot development a programmer needs to be confident in what the code is supposed to do and in what order that's supposed to happen in order to effectively test any user stories and functional test
and at the end of the story of how we want Edith to react whenever the outbreaks do we want her to tell her hair and renter garments like in a greek tragedy I certainly hope not we probably 1 of remind her with the tools that she needs to correct the error if possible or reassure her that we know that something went wrong and were already on it so that we have this more reassuring error message that I'll a gallery for you because I just love the spotted subtle dear readable or outside your reader we regret that an error has been made warmly programmers it takes a creative thinking to know where our code might break to build and checks for that and to return something useful to a user any programmer can return the error message AssertionError false is not true but it takes some creative thinking as well as those excellent written and verbal communication skills that you see in job postings but you never know quite what they mean to compose an error message that is helpful not intimidating and its competence inspiring when you're writing good tests you're doing world building accessibility for example requires empathy and empathy requires imagination you can leverage the Austin feeling you get when you get really lost in a book and you identify with the main character super closely into putting yourself in the shoes of your user imagine their struggles their frustrations create a persona for them and fix the things that hinder them or annoy them about their out about your app and let them continue on their journey but back to the functional test so
this is a screenshot from here is book tested development on specifically it's all the comments that he's written out so that he knows what test he needs to act the that also looks like something else so that you may remember from your college English classes
an outline it has specific ideas in a specific order they relate to each other in a specific way and that looks like something else
basically all Python code by 1 loves life a white space and indenting and pretty formatting even more than the average English majors and pipeline uses a lot of the same formatting
as many other written works like news stories blog posts novels research papers even recipes like this 1 is Emily Dickinson's handwritten coconut cake recipes you're function definition is like the title and to convince you that even further you should really check out decubitus talk on meaning things tomorrow and I'm not going to spend a lot of time I mean things because that's what he's here for you're docstring you can think of is like the abstract to a research paper or the forward to a new edition of the favorite novel it tells you a little bit about what's coming it gives you a peek into the author or the programmer's mind then there's everything in the middle there is the need of your function the paragraphs of the article or the story and finally you conclude you return something and your journey through this particular function is over a well-written piece of code will be readable but what we mean by that machine 72 to it to be readable but then we have
this the the Python is pretty clear that readability counts the computer or compiler doesn't character code is the mass but your colleagues share the people who come after you care the people who share in your work need your code to be readable it it's caring about your fellow coder to write readable code readable and conscientiously commented code also helps future programmers understand what he struggled with or why you make decisions the way the dead a friend of mine once said commenter like love notes to yourself another coworker likes to say the comments WikiGIS stain at 3 o'clock in the morning when you get a phone call that something has gone catastrophically wrong now there is a great
example of this from a contemporary series of some of you might have red it's the outlandish series this is basically my perfect book series it's about world war 2 nurse to accidently time troubles back to 18th century Scotland it's amazing but there's more and as romantic as wonderfulness and it's a very great TV series too but none of that is the point and I'm not to spoil anything but I will say that at the end of book 5 this is like in a book series and Markarian Claire is an 18th century and she the most knowledgeable medical professional 4 miles she treat someone you wonder dying and she's pretty sure it's because she gave the patient something that they were allergic to and she struggles with whether to write this down in the medical journal where she keeps records of all of the patients because in a different but she was a child the which because they got her medical uneasiness was actually witchcraft such as I 1 1 right something down it could be used against her she says that and I put some future position here would face the same dilemma to undertake a possibly dangerous treatments or to allow a patient to die might have been saved who might that be and then she thinks for a while about how isolated she is about how there are very many doctors and there are really very many medical schools and she concludes I sat up straight and opened my book I did my pen and began to write the lines that must be there for the sake of the unknown physician who would follow me now we're not saving lives here but this is why we write readable code for the sake of that unknown coder who follows us so I wouldn't college had a roommate was a journalism major and she and I would always at each other's papers and I would invariably tried to get her to use more additives to make your writing more exciting and she would tell me to cut my flowery descriptions and get to the point she was right these next few slides are edicts from top 20 and Strunk and White and I'm not going to specify which lines from which work because it doesn't matter but the point is that the similar good writing is concise and clear and simple and gets to its points whether you're writing a piece of code on article I could take the lines from the Zen of Python that are specific to code and e-mail them to my friends were now those professors and they could just hand them out right now the classes and they would be better for it in fact I should do that so much of what makes the zenith I find great is its universality my favorite line is complex is better than complicated not because I struggle with writing code that is complex and instead of complicated but I do but it's because it speaks to the writer and the it's really hard to explain a complicated idea or to come around to an important point at the end of a long thought during I lost their that's cool I made it like along fine without enough and that it is what you it's why a good editor and a good code review are both so valuable to us as writers anyone who's a fan of Game of Thrones knows how thin the line between complex and complicated can be so what would happen if we can call ourselves coders for programmers or developers when we do all day we write code we read comments we write tests we read pull requests we write a lot of things were readers and were writers the lessons that we learned in classes about reading and writing literature are exceedingly relevant to us as readers and writers of code so do you ever get to use your English agree I get asked that all the time and I use my English every every day the
and I have some sort thank you and I will take questions if you have questions of the the the they great a gradual and I stimuli with literate programming the only case literate programming was something that the loose use uh Dixie espresso professor came up with the idea that uh the documentation for code and the code should be the same thing think you can you compile to documentation compiled core about but what your thoughts in terms of do you think that it should actually be at that level of verbosity that level of engagement engagement between the Kroger writing and what they do is they all what is your opinion is always coming from a humanities the code used literature enough to to to express what's going on so I know I am and I I knew the song was going is a little don't you think that you know go to be felt documenting and should that's true right but that's not always what happens and that we've all maintain those legacy systems where maybe once upon a time that could result document in that time is passed that handling and we're now in a new area where we have no idea of a dozen almost touch it because the words that we have no idea why and ideally ideally code would be self-documenting and there'd be no need for you know hashes that had come and talk to them and I however think that especially whenever you're writing that really complex code that is responding to a really difficult problem or really difficult idea that took you a while or whenever you're doing something new for the 1st time it's nice to leave someone or yourself breadcrumbs that say like this is what I meant to do this with this code does and this is what I was thinking of is how I got here and I'm and I I think that leaving those breadcrumbs is a kind thing to do I'm fro comments and even being pro comment I so their own comments in code review like why don't you document like you'd see is very pro like each other comments to tell us what you meant here and especially since I'm a larger institution there so many different kinds like different world little tiny silos of business rules and so everyone has a slightly different things that they have to think about and but yet I ideally the encoder self-documenting I think that that's not always the for that we want of writing and a you a little bit of the the following which major I don't have enormous no my work on it about the complexity versus will which reverses complexes complicated complement of and that is 1 reason why becomes writer usually was because well want to do it every day which were telling you have the right but I think the English language so this is the sort of struggle become really Jordan eyes and so it's really hard for people express themselves and actually mean something because what Durán means to your true corner of the world is not what it means my and so I would think of words it's like Cobol Aquarius sick every time you add modifier to your modifying results I mean the there might be a sole difference but the significant difference so it's like you're just as it the 1st 2 brevity is not necessarily you always the sole virtue man and and the ideas you shouldn't take of such fire I I've seen as we we want to make sure that we don't have too much or so we know a little bit about is talk so I've seen as notes I think that you would particularly enjoy it but they I think there is there is a tension between and you know being accurate and being brief and sometimes sometimes being fully accurate means using maybe more words than you would like to the role of the the thank you for your the a at the then the are there any are there any other questions if you would like make microphone can come to you do not have to come to my the problem is that I also already the the question I do it so and this so our 1 bit that I struggle a lot with is coming up with useful and intuitive names for classes and functions up because to make some manageable in the code I want to keep the nation shortened click just 1 or 2 words and dog to make them accurately describe what they want to do I want to basically put the docstring in the name of the file and then do this by this is not just me I've I came up in someone's talk yesterday Django has a couple of things called meta and a couple things called options for like so there's multiple metal options combinations that might result in the proof of this fault of it so what problems can you give us from so again I'm pitching Jacobs oximeters cemented sort of like exactly that and like the if you if you want how to name things better and more how what kind of guidelines to have you to to convert to stock tomorrow and the other a hard problem wasn't by finding things and in fur for me I I will say I struggle with that you and I I think for function names refer variable names or class aims it's you want to be accurate if they you also don't want to you know 65 bytes of URI here during his years in the functioning of the meaning that the behavior that and so on it's hard and practice and I think you can get used and I think it's easy to get on a trail right you have like the 1 class that is pretty straightforward any of the other class that inherits from that word referring to that in some ways so you name it in reference to any new name another thing in reference to a new name another thing in reference to and then it's just like turtles all the way down and and and then you have these incredibly long names and so at some point and I think it can be better to maybe tried a single analyze and whenever that happens to be a big it's because you're name something in reference to something else and so you wanna say you know this function is different from the other function in this way and applica functioning and if you can kind of sense that pattern or sense that's what you're doing you maybe you can find a better solvable that and that's not the only way how that's not the only way that we went up with really long names and that's 1 of the ways I notice in myself is that that's the way I want it was too long and this is I'm just work referring and referring and offering I think you for a lovely on I so so good good English evolves over time Brierley's I believe that I know some people I'm so so good english writing evolves spam and yet uh I'm not intimately familiar with the way perhaps work but I believe that they just sits there right in that I do you think that the way we write code in our coding style should evolve over time and and how do we go about doing that I think I can and I and III combined 1 of that I know a lot of English majors don't necessarily agree I agree that you're those evolves over time and that's why I say all you know I'm not using those I think you all is the perfect world around them the and the safety of the even if I'm doing any message today is the probability of men not and I I don't know of the ridiculous about how pets get changed or like can you submitted yard in the past I have no idea but I am I guess is kind of probably tell maybe not really hesitant but I think the discussion that we should have and I think that whenever like when it comes to you like this and I thought I think there's so much about is really timeless and maybe there there are probably a couple of lines and has an effect on and that that would be things that may be could be could be change over time workable things like that they that could and that might be less relevant over time some or maybe we decide that we we don't want you know to full speed like 2 lines after a particular kind of thing and more of those standards change and that they change over usage to a part of the way the english changes through usage and and so as people lined up doing different things and like the title changes like 80 line like like baby by thing that is you know although there's also people at UT worse on a mainframe so we actually do have programmers who do develop in those environments where did the 80 and that most of us are in those environments anymore the seems a little all 1st similarly as so here we cannot band together to make like a working group to talk about the length if we want to the here we have time for 1 more question nobody not yet related thank you thank them you know the the the and we we