Problem 1: Reflecting on Constraints in Programming
Norman introduces four kinds of constraints in the reading: physical, cultural, semantic, and logical. He then goes to describe how these constraints manifest themselves in everyday objects.
Let’s turn our focus towards programming. For each of the constraint kinds, give two examples of how these constraints manifest themselves in specific programming languages or development tools that you know of. Describe each of these examples in a sentence or two.
Problem 2: Mini-Case Study: Sealed Classes
While browsing Hacker News yesterday, I ran across a fun article detailing the evolution of Java from version 8 up to 17:
One of the newest features of Java 17 is the introduction of sealed classes to the language:
Sealed classes are a fresh example of a linguistic constraint in the language. However, it has not been met with some trepidation. For example, from this comment thread from the Hacker News post:
Using these links as starting points, do some research on your own to learn about sealed classes, what they are and their intended purpose, and some of the reasons why people do not want them in the language. Then answer the following questions about the language feature in a few sentences each:
- How do sealed classes function as a constraint? What kind of constraint are they?
- Constraints serve the purpose of restricting potential behaviors so that it is clear how something operates with little-to-no prior knowledge of how it operates. How do sealed classes serve as constraints in this sense? Think broadly about which “users” are being served by such a constraint. It isn’t just the programmer that writes down the
sealedkeyword that (potentially) gains benefit from the constraint…!
- What are the objections against sealed classes in Java? Are any of these problems legacy problems as described by Norman (pp. 127)?