Posts in the “programming” category

An article on the problems with OOP

There seems to be a lot of OOP-bashing lately, which I’m not a fan of, but this article titled Goodbye, OOP makes decent points about the problems with inheritance, encapsulation, and polymorphism. IMHO, OOP still makes sense in certain areas, including GUIs like Java Swing and JavaFX, so I’m not ready to throw it out completely or bash it.

How to use `curl` scripts to test RESTful web services

There may be better ways to do this, but when I was writing a mobile app, with the JavaScript client written in Sencha Touch and the server written with the Play Framework, I wrote some curl scripts to simulate GET, POST, DELETE, and PUT request (method) calls to my Play Framework REST/RESTful web services.

GET, POST, DELETE, and PUT examples

The following examples show the code for each of these scripts. First, here’s get.sh:

curl --request GET http://myhost/notes/rest

Quotes from Clean Code

Back in 2013 I read the book Clean Code by Robert C. Martin, and in an effort to keep that book alive with me a little while longer, I decided to make my own “Cliffs Notes” version of the book on this page. One of my favorite notes from below is that a language named LOGO used the keyword to in the same way that Scala uses def, so a method named double would be defined as to double... instead of def double..., which seems like it would help developers name methods better.

Martin Fowler on lambdas, circa 2004

I ran across this historical tidbit from Martin Fowler a few days ago. It’s interesting to see that in 2004, lambdas weren’t too well known, and they’re associated here with dynamic languages. With a degree in aerospace engineering, I only knew of them from in interest in Lisp, and then Ruby around this time.

Higher order functions *are* the Haskell experience

This is a great way to put this: “Higher-order functions aren’t just a part of the Haskell experience, the pretty much are the Haskell experience.”

(A “higher-order function” is generally defined as (a) a function that can take a function as an input parameter, or (b) returns a function as a return value.)

The quote and image come from this LYAHFGG page.

A Markdown cheat sheet

This is a simple Markdown cheat sheet. I created it for my own needs, so I can find what I use and need quickly. If it’s a helpful resource for you too, cool.

[toc hidden:1]

The meaning of the word “reify” in programming

I don’t recall hearing of the words “reify” or “reification” in my OOP years, but that may be because I studied aerospace engineering in college, not computer science. Since learning functional programming (FP) I often see those words, so I thought I’d try to understand their meaning.

Background

I ran into the word “reify” when I saw code like this:

trait Foo {
    //...
}

object Foo extends Foo

I’d see that code and eventually saw that someone described that last line as a “reification” process.

What “reify” means

The short answer is that the main definition of reify seems to be:

“Taking an abstract concept and making it concrete.”

For the longer answer, I found the following definitions and examples of reification.

How to use SQL SELECT, GROUP BY, ORDER BY, and COUNT (all in one)

Don’t tell anyone, but my SQL skills are pretty average these days, at best, mostly because I haven’t had to do anything hard in a while. But just now I was happy to write this little SQL SELECT query that does a GROUP BY, an ORDER BY, and a COUNT, yielding the results shown in the image:

select nid, count(nid) from term_node
where tid in (3,1,11,10,9,8,7)
group by nid
order by count(nid) DESC

I’m going to use this query — or one very similar to it — to get a list of nodes (nid) that have the most tag ids (tid) from the list of tid in the query. In theory, the nodes (blog posts) that have the most tags in common should be the most related to each other. So, in my Scrupal6 replacement for Drupal 6, this query is a way to get “related” content for a given blog post. (The tid list shown comes from node id 4, so I need to also exclude nid=4 from the results. I also need to add a limit clause to the query.)

If you ever need to do a group by, order by, and count in one SQL query, I hope this example is helpful.

An offer to write open source documentation for a modest fee

Have you often looked at the documentation for an open source project and thought, “If that documentation was better, I’d be glad to give this project a try. The problem is, it’s like an expert wrote these docs, and I have no idea where to even start.”

Solution: Starting in July I’ll have some free time, so I’m offering my technical writing services for the low, low price of $30/hour. I’ve charged 7x that for programming; this is a bit of an exploration to see if there’s a market here.

Caveat: I can only work ~10-15 hours/week. Things I can write about easily are Scala, functional programming, Flutter, Dart, and Java. Other things I have some knowledge of are Android, Kotlin, Rust, and TypeScript. Email “al at valleyprogramming dot com” if interested.