Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am reading about Alistair Cockburn's Hexagonal Architecture with interest.

One claim he makes is: "Finally, the automated function regression tests detect any violation of the promise to keep business logic out of the presentation layer. The organization can detect, and then correct, the logic leak."

I do not understand this point. Is he saying that because the test is headless, then calls to a ui layer will throw exceptions? That doesn't seem to be a very sound test!

share|improve this question

migrated from Oct 10 '12 at 18:08

This question came from our site for professional and enthusiast programmers.

His point is that having a suite of automated tests exercising all the business logic without a UI will make it clear if you have any business logic in the UI.

To make such a test suite, you essentially have to create a very thin testing-only "non-user" interface to supply data and check results. If any of your business logic is actually in the UI, you'll find yourself replicating that logic in this testing interface, and realize your mistake.

share|improve this answer
I kind of see. But what happens if the developer augments the published API by introducing business logic in the presentation tier? That would not get picked up, correct? – Victor Grazi Oct 10 '12 at 20:32
Nothing will protect from a rogue developer adding things where they don't belong without tests. – Don Roby Oct 10 '12 at 21:28
So the pattern protects against someone who is stupid enough to move business logic to the presentation tier, but not against someone who is so stupid that they would introduce new business API's in their presentation code. – Victor Grazi Oct 11 '12 at 4:20
"you'll find yourself replicating that logic in this testing interface" or you might write your tests to use the UI logic, right? – Daniel Kaplan Mar 14 '15 at 0:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.