Register to get access to free programming courses with interactive exercises

Interfaces Python: Building data abstractions

The term interface is widespread in IT and everyday life. For example, a user interface can be a set of controls for a Web site, an ATM, or a telephone. The interface of a TV remote control is the buttons. The interface in a car would be the levers, buttons, and steering wheel. In summary, the interface determines how you interact with a given system.

Designing interfaces isn't as easy as it might seem. We encounter inconvenient interfaces — when we open doors or use elevators. The more complex the system, the more possible states, the more difficult it is to make the interface. Even in a primitive example of a TV power button with two states — on/off.

You can implement one or two buttons that behave differently depending on the current state.

Programming is similar. An interface is a set of functions with names and signatures that specify the number and types of incoming parameters and the return value, which doesn't depend on any particular implementation. This definition corresponds to the concept of abstract data types. For example, for points, all the functions we have implemented in practice and described in theory are interface functions.

How are the concepts of abstraction and interface related? Abstraction is a word that primarily describes the data we work with. For example, almost every web application contains a user abstraction. Hexlet has the abstractions course, project, and others. An interface is a set of functions helping to interact with data.

But there aren't just interface functions, but also helper functions that are not designed for calling code and are used exclusively within the abstraction:

Sign up

Programming courses for beginners and experienced developers. Start training for free

  • 130 courses, 2000+ hours of theory
  • 1000 practical tasks in a browser
  • 360 000 students
By sending this form, you agree to our Personal Policy and Service Conditions

Our graduates work in companies:

<span class="translation_missing" title="translation missing:">Bookmate</span>
<span class="translation_missing" title="translation missing:">Healthsamurai</span>
<span class="translation_missing" title="translation missing:">Dualboot</span>
<span class="translation_missing" title="translation missing:">Abbyy</span>
Suggested learning programs
Developing web applications with Django
10 months
from scratch
under development
Start at any time

Use Hexlet to the fullest extent!

  • Ask questions about the lesson
  • Test your knowledge in quizzes
  • Practice in your browser
  • Track your progress

Sign up or sign in

By sending this form, you agree to our Personal Policy and Service Conditions
Toto Image

Ask questions if you want to discuss a theory or an exercise. Hexlet Support Team and experienced community members can help find answers and solve a problem.