Category Archives: Software Development

Layer vs Tier

Some architects use the term “layer” when they to refer to logical grouping of components and “tier” to refer to their physical grouping. However Mark Cede and Humphrey Sheil, in their book on the SCEA exam, define layer and tier somewhat differently. They define tier as … logical or physical organization of components into an ordered chain of service providers and consumers. They refer to client, web/presentation, business, integration, and resource as traditional tiers in architecture. Makes sense.

Then they define a layer as a piece of the hardware and software stack that hoses services within a given tier. This definition of layer is different to other definitions I’ve seen so far. They list virtual platform, application, infrastructure, enterprise services, compute and storage, and networking structure as typical layers of an architecture.

While this definition is somehow different, it makes total sense to consider all these aspects when designing an architecture: Are we going to deploy to Weblogic or JBoss? Are we deploying to Windows or Linux? Will we deploy the application on one or more many-core servers or cheaper multi-core systems? Will we use a high performance PCI-e based solid state storage as our storage system or are we going to use traditional rack-based NAS storages? What DBMS are we going to choose and why?

Decomposition, coupling and cohesion, and volatility

Decomposition by “coupling and cohesion” and “volatility” are two architectural decomposition methods that are unlikely to be used together in the same project. However it’s possible to first decompose by CoC and identify the parts of the system that should be kept together, and then use decomposition by volatility to isolate the parts that are likely to change in the future. This means that we might need to reduce the cohesion of the system to some extent, but it should make changing or replacing the volatile parts of the system less of a hassle.

Three tools for testing email sending using SMTP

Email1: smtp4dev: Windows 7/Vista/XP/2003/2010 compatible dummy SMTP server. Sits in the system tray and does not deliver the received messages. The received messages can be quickly viewed, saved and the source/structure inspected. Useful for testing/debugging software that generates email. I have been using this for quite some time now and it is working seamlessly.

2: MockSMTP.app: MockSMTP is a native Mac application that embeds its own SMTP server. It also features an e-mail client browser, enabling instant viewing of both raw content and HTML rendering, so you can see how your mail looks when delivered. A nice product overall but is buggy.

3: Dumbster: The Dumbster is a very simple fake SMTP server designed for unit and system testing applications that send email messages. It responds to all standard SMTP commands but does not deliver messages to the user. The messages are stored within the Dumbster for later extraction and verification. The best option among the three for unit testing Java applications.

MySQL, Foreign Keys, InnoDB, and ERROR 1005

For quite some time I had faced this mysterious problem with MySQL where it was refusing to create a new table in our application’s database with a foreign key relationship to one of its existing tables. The error message MySQL was displaying was not very helpful:
[cc]ERROR 1005 (HY000): Can’t create table ‘DB_NAME.TBL_NAME’ (errno: 150)[/cc]
[cci lang="sql"]SHOW INNODB STATUS[/cci] was not helpful either:
[cc lang="sql"]
LATEST FOREIGN KEY ERROR
————————
100716 1:27:25 Error in foreign key constraint of table DB_NAME/TBL_NAME:
foreign key (COL_NAME) references ANOTHER_TBL_NAME(ID_COL_NAME)) default charset=’UTF8′ engine=InnoDB:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint.
Note that the internal storage type of ENUM and SET changed in
tables created with >= InnoDB-4.1.12, and such columns in old tables
cannot be referenced by such columns in new tables.
See http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
for correct foreign key definition.
[/cc]
Oddly enough MySQL had no problem creating two new tables with a foreign key relationship between them. Well, long story short, it turned out that the old tables were using latin1 charset whereas the default charset for my MySQL installation was UTF8 and also the columns that had a foreign key relationship between them were varchar columns*.

The solution was quite easy: explicitly setting the charset to latin1 in create table statements (or alternatively changing the default charset of the database to latin1).

*Use of VARCHARS should be avoided in primary key columns.

Programmer’s Drinking Song

Programmer’s Drinking Song (sung to the tune of “100 Bottles of Beer”)
99 little bugs in the code,
99 bugs in the code,
fix one bug, compile it again
101 little bugs in the code.
101 little bugs in the code…
(Repeat until BUGS = 0)

Well, this one was quite funny. Probably one more reason to write tests? Also, in Java and a number of other languages, Repeat until BUGS = 0 is just one little bug in the code ;-) .

Software Projects, Explained

I had originally posted this about 7 years ago on my old blog at JRoller. Looks like some of the files I had uploaded to JRoller have been deleted since then, and as a result the image is not showing up there anymore, but I was able to find another copy of this image using Google’s image search. Credit is due to the original author who is unknown to me.

Software Projects, Explained

Software Projects, Explained