Encapsulating functionality behind a well-defined interface


Most traditional programming languages provide several ways to abstract away complexities of code, and instead present a well defined interface.

What does that mean? Well, in simple terms it’s a restricted set of entry points into that code that make it clear how you can interact with it.

Was this email forwarded to you?


Take, for example, a web page with a form that takes your username and password. The interface is made up of the username field, the password field, a ‘forgot my password’ link and perhaps a few other links. Other than that, you don’t really have any other access to what’s going on behind the scenes.

You can do the same over a piece of code - for example in many languages you would define a module or class that processes someone’s login information. You might expose a function for setting the username and password, something like:

login.request(username, password)

and perhaps a way to ask whether login was successful, and perhaps a ‘key’ to access the user’s information in other parts of the code once they have been confirmed.

Apart from these exposed functions, the rest of the encapsulated code is usually hidden away from the other parts of the program. Typically the developer’s tools will help out by listing the functions that are exposed as you write the program. Something like this:

You can also define your own restricted interfaces around parts of spreadsheets as well - though it takes a little bit of knowledge of how a few features work together.

Later on we’re going to go through three examples based on the scenarios we talked about earlier:

  1. Blocking out and even restricting navigation to data input areas.
  2. Encapsulating a lookup table for reference data.
  3. Encapsulating calculations, and using named ranges as the interface.

Until next time, thanks for reading!

– Brendan

p.s. Enjoy this message? Read more at the Hyland Quality Systems website.

The Daily HaiQu

I'm Brendan Hyland. I help regulated facilities transform their software, spreadsheets, workflows and documents from time-consuming, deviation-invoking, regulatory burdens, to the competitive advantage they were meant to be. Join me every week as we take a few minutes to explore, design, test and improve the critical systems we use in our facilities.

Read more from The Daily HaiQu

It’s the first step of the problem solving framework that I was taught back in Engineering school. Not ‘Plan’. Not “Define”. “I want to and I can”. That particular framework - the McMaster Six Step - never gained the popularity of the ones now used today, but in the end they all contain the same basic elements - research, planning & design, implementation, evaluation and iteration - just stated in different ways. However I’ve never really seen this particular element called out explicitly...

Black music production equipment with headphones on desk

My eight year old son figured out a hack to make the music service work better for him. The kids have a Google smart speaker that is attached to a Spotify account so they can just ask for any of their favourite music. Anyone who has pre-teens in the house probably knows how much such a setup is used - all day every day. Coming from someone who had to run to the double-cassette boom box to press the record button any time a new favourite song came on the radio just so I could listen to it...

A reporter interviews a smiling man holding a book.

I’ve seen several quality leaders complain this week about their disappointment with generative AI - they’re not getting the results they expected. And I understand why - context is king! If you just ask AI to write a procedure or generate a quality document, you’ll get generic, mediocre output. Without enough context, AI can only produce something generic based on its training data. But how do you give it that context? By the time you’ve gone back and forth trying to “engineer the prompt” to...