My previous blog seemed only to continue the confusion regarding classes in Functional Programming. Indeed, many people got quite irate. So perhaps a bit of code will help. Trigger Warning : Object Oriented Terminology. Dynamically Typed Language. Mixed Metaphors. Distracting Animations. To all the adherents of the Statically Typed Functional Programming religion: I know that you believe that…
I recently tweeted the following: Should you subdivide a functional program into classes the way you would an object oriented program? Yes. You should. Because the rules don’t change just because you’ve chosen to use immutable data structures. — Uncle Bob Martin (@unclebobmartin) January 17, 2023 This led to a bevy of interesting responses about the difference between classes and modules. In…
For the last month I've been spending a lot of time working on Space War . I know, I know, I should have been working on Clean Code Episode 67: Legacy Code , and Euler 5 , and Countest and Curmugeon 3 . I should have been working on a blog, or a new book, or... But I couldn't let go of Space War. It kept calling me. The first time I wrote Space War was in 1978. I wrote it in Alcom , which was a…
I broke out my old Space War game a few days ago and decided to make a few changes to speed the game up and make it more fun to play. In so doing I discovered a very interesting bug. One of the changes I made was to populate the initial space with a few random bases scattered here and there. This would allow the player some extra resources with which to battle the Klingons while building up a…
When I was 15 or so, my father would drive me, and my best friend, Tim Conrad, to the Digital Equipment Corporation (DEC) sales office each Saturday. This was a 30 min drive. My father would drop us off in the morning and pick us up in the late afternoon. He spend two hours in his car each Saturday hauling us around. Thanks Dad! Tim and I would spend our day "playing" with the floor model of the…
Recently I wrote a cute little program for doing Turtle Graphics . For those of you who don't know, turtle graphics were originally added to the LOGO language by Seymour Papert in the late 1960s. He built a robot that he called a "turtle" that could hold a pen. The robot had wheels and could move forwards and backwards, and could rotate left and right. It could also raise and lower the pen. When…
I wrote my first program in 1964. The name of the program was: Mr Patternson's Computerized Gate , and it was implemented on a little plastic computer named DIGICOMP-I, which was a cute little three bit finite state machine with 6 AND gates. The first electronic computer I ever wrote a program for was an ECP-18 in 1966. This was a 15 bit wide machine with 1024 words of drum memory. The programs I…
A few days ago someone tweeted a question asking which of the following PHP snippets was better than the others, or whether there might be an even better approach. I tweeted my answer in the following cryptic paragraph. Place the if/else cases in a factory object that creates a polymorphic object for each variant. Create the factory in ‘main’ and pass it into your app. That will ensure that the…
Everybody pairs from time to time. It is a rare programmer who has not sat down with another programmer to look something over or help find a bug. Deep problems, that require much heavy thinking, do not often lend themselves to pairing. The interaction between the programmers tends to disrupt the necessary concentration. On the other hand, it is not uncommon for programmers to get caught in a…
Recently I received a letter from someone with a concern. It went like this: For years the knowledge of the SOLID principle has been a standard part of our recruiting procedure. Candidates were expected to have a good working knowledge of these principles. Lately, however, one of our managers, who doesn’t code much anymore, has questioned whether that is wise. His points were that the Open-Closed…
The following is a segment of a journey. It has no obvious beginning point, nor does it actually end up anywhere. The value, if any, is in the journey itself. The code below is the standard solution to the Prime Factors Kata . public List<Integer> factorsOf(int n) { ArrayList<Integer> factors = new ArrayList<>(); for (int d = 2; n > 1; d++) for (; n % d == 0; n /= d) factors.add(d); return…
It was just a few years ago, at the height of the Me Too revelations, that codes of conduct began to prominently appear in Software Conferences. At the time I felt this was appropriate given the horror stories that had been circulating about sexual harassment and misbehavior at some of those conferences. I wrote a blog about it at the time. Since then I have seen the other side of the coin. Codes…
I have a friend, in the Chicago area, who calls me up two or three times a year to ask me to give a talk at a User Group, or a conference he’s involved with, or something like that. If my schedule is free I always say yes. I don’t charge anything because I enjoy supporting the Chicago software community, and it’s never a bad thing to get my face out in front of new people. I am a consultant, after…
If you follow me on facebook you know that I’ve been publishing daily CoronaVirus statistics. I generate these statistics using the daily updates in the Johns Hopkins github repository . At first I just hand copied the data into a spreadsheet. But that became tedious quite rapidly. Then, in late March, I wrote a little Clojure program to extract and process the data. Every morning I pull the repo,…
So let’s learn just a little bit more of Clojure. Here are a few common utility functions: user=> (inc 1) ; increments argument 2 user=> (dec 3) ; decrements argument 2 user=> (empty? []) ; tests for empty true user=> (empty? [1 2]) false If you know Java or C# you probably know what the map function does. Here’s an example: (map inc [1 2 3]) evaluates to (2 3 4) . The first argument of map is a…
So let’s learn just a little bit of clojure. This expression: (1 2) represents the list containing the integers 1 and 2 in that order. If you want an empty list, that’s just () . And the list of the first five letters of the alphabet is just (\a \b \c \d \e) . Now you know a lot about the syntax of clojure. Perhaps you think there’s a lot missing. Well, there are a few things missing; but far…
…The Year is 2045… Dad, can you help me with my school report? Sure son. What’s it about? We have to do it on the great pandemic of 2020. You were there, right? I was just a little boy. But I know a lot about it. What is it you need to know? We’re supposed to write about the heroes. Ah, yes. A good topic. There were so many. OK, so… Who were they? Well, first of all there were the healthcare…
To: The Linux Foundation Jim Zemlin: Executive Director Angela Brown: VP of Events Andy Updegrove: Legal Council From: Robert Martin (@unclebobmartin) (unclebob@cleancoder.com) Re: Code of Conduct case of Charles Max Wood. Dear Linux Foundation: I am writing to you as a concerned member of the software development community which I have enjoyed serving for the last 50 years. I am writing in public…
It is interesting and educational to go back in time and look at how programmers were represented in popular culture. What did they think of us? Did they know who were? It’s important to remember that prior to 1946 there were no programmers, that computers themselves were virtually unknown until the late ’50s. That virtually nobody lived next door to a programmer back then. Nowadays virtually…
My wife and I both got genetic analyses from 23andMe recently. I discovered that my ancestry comes from Britain and Northern Europe. My wife is Mexican, and she found that her ancestry is very diverse. One of the services of 23andMe is that they offer to connect you to relatives who have also used 23andMe. Using this service my wife found a second cousin whom she had never met, but whose extended…