Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at

hpr2262 :: Abstracting Nurse Jesus

how I abstracted random number generation for more syntactic sugar

<< First, < Previous, , Latest >>

Thumbnail of Eric Duhamel
Hosted by Eric Duhamel on 2017-04-04 is flagged as Clean and is released under a CC-BY-SA license.
video games, programming, object-oriented, game development, abstraction. (Be the first).
The show is available on the Internet Archive at:

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:05:24


NOTE: the audio recording appears to have periodic jitter. As I recorded at 44.1 Khz this time, I wonder if my S2 just handles recording at a lower quality better, and if so I'll prefer lower quality over jitter in the recording.

In this episode I explain why and how I abstracted random number and choice generation into self-sustainable methods for objects.

  • A superclass was needed so that all the classes of object in the game engine would have access to these random generation methods.
  • I preferred to use methods in this case so objects would be self-sufficient and wouldn't depend on extra modules imported at the top of my code.
  • The syntactic sugar achieved by using customized methods instead of i.e. random.randint(0, 99) makes the code easier to write and understand at a glance.
  • Nurse Jesus is a pun on the acronym RNG for Random Number Generator
  • Let me know if you get the reference at 2:00 ;-)

I recorded this episode in parts using a program called Urecord on my pocket computer (mobile phone).

I program using Pygame, post on a GNU Social account, and maintain a personal website at NoxBanners.NET. I study programming techniques at, style at, and sometimes patterns at Portland Pattern Repository


Subscribe to the comments RSS feed.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Anti Spam Question: What does the letter P in HPR stand for?
Are you a spammer?
What is the HOST_ID for the host of this show?
What does HPR mean to you?