...
Sign in
Computer Science

Interface design

Interface design

Share:

Interface design

Introduction / Definition

An interface defines how clients use a component without exposing its internal representation. A good interface is small, consistent, and predictable. It specifies operations, inputs, outputs, and errors. This reduces coupling and makes implementations replaceable.

Syntax / Structure / Formula

interface ADT { operation signatures }

Detailed Explanation

A stack interface can expose push, pop, peek, and isEmpty while hiding whether storage uses an array or linked nodes.

Example

Example: Stack<T>: push(T), pop(), peek(), isEmpty().

Output / Result

Client code depends on the contract rather than storage.

Important Points / Notes

  • Hide implementation details.
  • Document contracts and errors.

Mini Practice Question

List four stack interface operations.


CheckpointTest Yourself

In software architecture and modular design, what is the primary advantage of programming against an Interface rather than a concrete class?

Lesson Milestone

Finished Reading This Lesson?

Mark this lesson complete. A chapter counts as done once all its lessons are, and that adds to your course progress.

TH

Written by

ThinkWisely Team

Have a Question or Suggestion?

We'd love to hear from you. Drop your thoughts below to help us improve ThinkWisely!