• Home
  • About
    • About The Coder
    • Language List
  • Code Rules
    • #1: Clarity Trumps Everything
    • #2: Source Code is for Humans
    • #3: Don’t Ignore Warnings
    • #4: Comment As You Go
    • #5: Always Use Parentheses
    • #6: Always Define Literals
    • #7: Never Repeat Yourself
  • CS-101
  • Python-101
  • Simple Tricks
  • Guestbook

The Hard-Core Coder

~ I can't stop writing code!

The Hard-Core Coder

Category Archives: CS101

Programming basics.

Rule #7: Never Repeat Yourself

30 Monday Jun 2025

Posted by Wyrd Smythe in CS101

≈ 1 Comment

Tags

code clarity, computer programming

In the previous post I semi-corrected a long-time oversight by revisiting the post The Thing About Constants and turning it into a Coding Rule, Rule #6. (I say “semi-corrected” because it really should have been Rule #3.)

In this post I semi-correct another oversight represented by the post The Synchronization Problem. It’s the other one that has been bugging me for a while because it should have been a rule (probably Rule #4). As they say, “Better late than never.”

Continue reading →

Rule #6: Always Define Literals

23 Monday Jun 2025

Posted by Wyrd Smythe in CS101

≈ 2 Comments

Tags

code clarity, computer programming, constants, defined values, global constants, literal values, readable code

It has been more than a few minutes since I posted a Coding Rule, so I thought it was high time I did. There are at least two things I’ve previously written about as important but didn’t elevate to Rules. Both have been bugging me; they should be rules. Today (and a week from now) I’m correcting that oversight.

To be honest, this Rule is so important, I’m not sure why I didn’t make it the third one. Rule #1 and Rule #2 are definitely more important, but the ones currently listed as #3 – #5 are not as important as today’s (they are very important, though).

Continue reading →

Bloom Filters in Python

19 Monday Aug 2024

Posted by Wyrd Smythe in CS101, Python

≈ 3 Comments

Tags

Bloom filter, computer programming, Python code, software design

I recently learned about Bloom filters (and was then able to fully understand the joke in this xkcd comic). While I don’t have a good application for them myself, I found them interesting enough to play around with a little.

Python uses them under the hood in a way that has some potential for other applications. In this post I’ll explain Bloom filter basics and go over some simple implementations.

Continue reading →

Why 1s and 0s?

11 Wednesday Oct 2023

Posted by Wyrd Smythe in CS101

≈ 4 Comments

Tags

binary, computer, number bases, one, zero

Quite some time ago, I posted about this on my main blog, but it has occurred to me that, firstly, it might be time for an update, and secondly, that a post about why computers use 1s and 0s is better suited here on my programming blog. (Especially as this is the 101st post!)

It turns out there is a very good reason computers use 1s and 0s, and while it is possible to use other numbers, the 1s and 0s are all that is needed.

Continue reading →

Regular Expressions

23 Thursday Jun 2022

Posted by Wyrd Smythe in CS101

≈ 3 Comments

Tags

computer languages, computer programmers, real programmers, regular expressions, strings

There are many general skills a programmer should have to be effective and valuable. Some are very general — for instance, the ability to learn and to think abstractly — but some are more specific — various tools and tricks of skilled programming.

Among those tools are several non-programming languages all programmers should know. Those include HTML, XML, SQL, and an old one whose name doesn’t end with “L” — Regular Expressions (aka REs, aka RegEx or RegExp).

Continue reading →

Naming Things (redux)

27 Monday Dec 2021

Posted by Wyrd Smythe in CS101

≈ 1 Comment

Tags

code clarity, computer code, computer programming, readable code

The first article (long, long ago) about naming things only scratched the surface. Even with company and language guidelines (or other rules) to help, with so many things to name it’s easy to lose control. Even now, after 44 years of writing code, I still sometimes find myself staring at the screen trying to think of what to name some object.

It’s understandable; there are a lot of things to think about when it comes to a name.

Continue reading →

The Synchronization Problem

29 Monday Nov 2021

Posted by Wyrd Smythe in CS101

≈ 4 Comments

Tags

code clarity, computer code, computer programming, readable code, synchronization

One of the great battles programmers fight involves synchronization between two different parts of the code. The most common example of this is what the comments say versus what the code really does. Another common example is the structure of data stored somewhere (like a database) and the code that manipulates it.

A lot of the programmer’s effort and technique is devoted to managing, if not preventing, synchronization issues. The rules encouraging encapsulation, or against global objects, have a lot to do with this goal.

Continue reading →

The Blessing of Unicode

15 Monday Nov 2021

Posted by Wyrd Smythe in CS101

≈ 3 Comments

Tags

strings, text, text file, Unicode, UTF-8

Computers process numbers using arithmetic and logic (which amount to the same thing). Processing text, however, requires at least two levels of abstraction. Firstly, a definition of a textual atom — informally a character. Secondly, a definition of a textual unit — typically called a string. A string is an ordered list of characters.

Therein lies a whole field of computer science. From a practical point of view, implementing text has become much easier with Unicode. Different character sets was one of the more awful aspects of dealing with text. (Remember CP-1252?)

Continue reading →

Always Implement toString

02 Tuesday Nov 2021

Posted by Wyrd Smythe in CS101

≈ 7 Comments

Tags

code clarity, computer code, computer languages, computer programming, Java, Python code, readable code, toString, __str__

Although I’m categorizing this one as really good advice, rather than as a rule, I think it should be viewed as basically a rule. I think it should be a rule in any object-oriented language that supports it natively (Java and Python, for example).

The advice (rule of thumb, say) is to always create a useful implementation of toString when you create a class. It makes your development and maintenance life ever so much better.

Continue reading →

Tabs or Spaces?

19 Tuesday Oct 2021

Posted by Wyrd Smythe in CS101

≈ 1 Comment

Tags

code clarity, computer code, computer programmers, readable code, space character, tab character, text file

There are many issues that divide programmers: operating systems and editors being two huge ones. I’ve worked on too many platforms to care much about the first one, but I’m a lifelong gvim user.

One of the lesser dividing issues involves the crucial source coding choice: Tabs or Spaces? The issue is both less and more important these days. Less because editors are very capable; more because Python is popular.

Continue reading →

← Older posts
Follow The Hard-Core Coder on WordPress.com

The Posts

  • Python Tk Calculator App
  • Tk Windows in Python
  • Dual Numbers in Python
  • Python Decorators, more
  • Python Decorators, redux
  • Byte Multiplication Trick
  • Parsing Multipart Form Data
  • Simple Python Tricks #18
  • Simple Python Tricks #17
  • Simple Python Tricks #16

The Topics

  • Blog (4)
  • CS101 (37)
  • Fun (36)
  • Interesting (5)
  • Opinion (12)
  • Python (59)
  • Stories (15)

The Month

December 2025
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  
« Nov    

The Past

Posts

RSS Feed

Comments

RSS Feed

The Main Blog

Visit Logos con carne

Lots of wyrds... with meat!

The Author

Wyrd Smythe

Wyrd Smythe

The canonical fool on the hill watching the sunset and the rotation of the planet and thinking what he imagines are large thoughts.

View Full Profile →

Create a website or blog at WordPress.com

  • Subscribe Subscribed
    • The Hard-Core Coder
    • Already have a WordPress.com account? Log in now.
    • The Hard-Core Coder
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar