- Home
- /
- Computational Thinking
- /
- Software Design & Development
- /
- Interface
Interface
Also known as: module interface, API contract
Grade 6-8
View on concept mapA software interface is the visible contract that tells other parts of a program how to interact with a module, function, or system. Interfaces reduce coupling across a codebase.
Definition
A software interface is the visible contract that tells other parts of a program how to interact with a module, function, or system. It defines the inputs, outputs, and rules of use without exposing the internal implementation.
๐ก Intuition
An interface is like a menu: it tells you what you can ask for without showing the kitchen.
๐ฏ Core Idea
Good interfaces make modules easy to use, test, replace, and understand.
Example
Formula
๐ Why It Matters
Interfaces reduce coupling across a codebase. They let teams work on separate modules at the same time and make later maintenance much safer.
๐ญ Hint When Stuck
When defining an interface, write down the inputs, outputs, possible errors, and any rules the caller must follow. Keep that contract stable even if the internal code changes.
Formal View
Related Concepts
๐ง Common Stuck Point
An interface describes what a module does and how to use it, not how it is implemented internally.
โ ๏ธ Common Mistakes
- Exposing internal details that other modules should not depend on
- Changing an interface without updating the code that depends on it
- Leaving inputs or error cases unspecified so the contract is ambiguous
Frequently Asked Questions
What is Interface in CS Thinking?
A software interface is the visible contract that tells other parts of a program how to interact with a module, function, or system. It defines the inputs, outputs, and rules of use without exposing the internal implementation.
What is the Interface formula?
When do you use Interface?
When defining an interface, write down the inputs, outputs, possible errors, and any rules the caller must follow. Keep that contract stable even if the internal code changes.
Prerequisites
Next Steps
How Interface Connects to Other Ideas
To understand interface, you should first be comfortable with modular design. Once you have a solid grasp of interface, you can move on to unit testing and user interface.