Author Archives: minmay

What I would change if I saw your database

This post briefly covers the history of databases, transaction fundamentals, and then proceeds to explain what I would change if I saw your database. It is highly-opinionated, and based on decades of experience in working with relational databases.

History

The term relational database was Invented by E. F. Codd at IBM in 1970 in his paper “A Relational Model of Data for Large Shared Data Banks.” The first commercially available RDBMS was Oracle, released in 1979 by Relational Software, now Oracle Corporation. Currently, the most popular relational databases are: Oracle, MySql, Microsoft SQL Server, PostgreSQL, DB2, SQLite, Sybase. They all use a variant of SQL. My personal favorite database is PostreSQL. It is free, open-source, and most faithfully implements ANSI-SQL.

Relational Databases Today

The relational database can provide the right persistence solution for most business needs. They are extraordinarily fast and reliable. They can manage petabyte scale data. There are plenty of tools written for them. They are simple to use. Right or wrong, they are also one of the most common enterprise integration patterns.

Continue reading

Bad Things Happen – Recognizing Common Pitfalls in Java Concurrency Programming

The rules in concurrency programming are different. Single threaded code is easily understood as deterministic. However, deterministic rules can change when multiple threads are reading and writing to the same memory space. It has been my experience that these rules for writing deterministic thread-safe code are often misunderstood. Bad things that we never expect to happen, happen.

Concurrency programming is mostly about ensuring that your system remains deterministic when multiple threads read and write to the same memory space.

Introductory Concurrency Problem

Let’s take one of the simplest concurrency problems and I will describe what can go wrong.

Let’s say that there exist an Account object in memory with a balance of $500.00, and two threads are reading and writing to it. Thread 1 wants to add $25000 to the balance. Thread 2 wants to withdraw $300 from the balance. If the code is not thread safe, then it will be quite possible for an execution of this scenario to yield a balance of $200.00.

Continue reading

Steal this Architecture – Attribute Drive Design

I often ask myself, “What is software architecture?” I asked this same question to all of my co-workers. I struggled defining what is software architecture, and what is it that a software architect actually delivers.

A typical answer to that question is that a software architect designs the interfaces of a software system and the important decisions made to complete it. They will understand the how and the why.

This definition makes perfect sense during a conversation, but I find that definition has less impact when written down, although there is some truth to the above definition.

Is a software architect just a bad ass developer that is good at making sketches on a white board?

I have walked away from many meetings that had architectural sketches in it thinking that although it was a step in the right direction, it was useless as a software architecture deliverable. Quite often, that informal sketch was often the only software architecture guidance.

In this post, I’ll do a deep deep-dive into software architecture in order answer “What is software architecture?”

Continue reading

Free HTTPS Setup on EC2 with Certbot

Setting up HTTPS was very easy. It was just a matter of upgrading to Amazon Linux 2 AMI. Follow the Install a LAMP Web Server on Amazon Linux 2 instructions. Follow the Configure Apache Web Server on Amazon Linux 2 to Use SSL/TLS instructions.

Thank you to Let’s Encrypt for providing their free service which will save me thousands of dollars, and the Electronic Frontier Organization for setting up CertBot.

The Layered Architecture Pattern

Len Bass, Paul Clements, and Rick Kazman best explain the Layered Architecture as, “The Layered Architecture Pattern defines layers as a grouping of modules or services and a unidirectional allowed-to-use relation among layers. Layers must have a strict-ordering relation, in which a layer can only use public interfaces of a layer below,” in the book Software Architecture in Practice1.

The benefit of the layered-architecture is that it allows for a separation of concerns, allows for a division of labor, and it is typically easy to refactor a top layer.

Its drawback is that there is a performance cost for each layer, and it can be very expensive to refactor lower layers.

Continue reading

Map as Class Anti-Pattern

Today, I will write about a Map anti-pattern that I have sometimes observed.

I have come across code as follows from time to time:

I suggested to the developer who wrote similar code to use a class instead of a Map.  I explained that a Map should be used for mapping problems, such as associating data with key value pairs.

The developer was upset, and argued back that using a class instead of a map is over-engineering. I interpreted this as some sort of logical fallacy “Ad Hominem” attack against classes. I exclaimed “Using a map is under-engineering! At the very least, we can introduce an interface that functions a marker class, and let Jackson perform the transformations?” This developer would not budge, and stated that she did not want to write a class for everything that will become serialized as JSON. I stepped back, gave her the benefit of the doubt, looked further at the code, noted the pervasiveness of this anti-pattern, and now I am writing this.

Continue reading

Bash Script to Issue a Command in Sub-Directories

The way projects are organized at my current employer often requires me to run the same command in within the first level of sub-directories.

For example, maybe I have to issue this command in ten sub-directories:

This little script I wrote helps.

 

Getting Started with WordPress

This WordPress site was setup on an Amazon AMI micro-instance using the instructions at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html

However, the latest version of WordPress required httpd 2.4 and PHP 7.0. To install these versions substitute the following commands: