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
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...

I'm presenting!

I'm excited to be presenting at the 2025 SQA Annual Meeting next week - "Is it the Right Tool for the Job? How QA and Regulatory Professionals can Guide Software Decisions in Regulated Environments" As our familiar software tools become more feature-laden and generalized, it's critical to ensure that software meets clear use cases and basic user requirements. And with generative AI being shoehorned into every platform, defining if and how software is appropriate for the intended use has never...

Last time we left off with a cliff-hanger of a question: How do you prove you're you when signing a document? There are several ways I've seen that the 3rd party providers prove that it's you who's signed the document: You clicked a link from an email. You paid for the service with a credit card. You provided some government issued photo ID. Someone, such as a notorized public or your HR department, has verified it's you in person. Obviously these are very different levels of assurance. Then...