Lecture 9 - Interfaces Flashcards
(23 cards)
What is an interface?
It just means, “the boundary where two things meet”. Where in software engineer, one face should provide a services
How are interfaces defined (how services are requested and how are they delivered)?
The interface will be defined by
- how and in what format those services are requested:
including, what must be provided when requesting a service,
- and any conditions that must be satisfied
===
how and in what format the services are delivered
- including anything that will be true after they’ve been delivered
REFER TO DoT EXAMPLE
In software engineering what two things do interfaces provide?
The interaction with computer artifact or human
Providing answers to clearly defined questions or needs — through the services they offer.
What is a User Interface?
Is the thing requesting a service a person/human (who are known as users), then it is a user interface
SIGN UP EXAMPLE
REFER TO SLIDES
Asking the same questions as before though:
- How does the user make the request
- Are there any conditions that need to be satisfied?
- How is the service delivered
What are Hardware Interfaces?
If both of the things involved are items of hardware, then the service will be specified both in terms of physical connections, and perhaps what sort of signals are passed through it and what they mean.
What do you need to specify for hardware interfaces?
- The physical characteristics of the port – exactly what dimensions does it have, and what dimensions and configuration must an appropriate plug have to fit into it?
- What signals can be sent across each of the wires the port attaches to, and what they mean.
What is a Software Interface, and what could it be?
Software has interfaces too – well-defined ways of requesting some bit of software perform a service. The software could be:
- a method
- a class
- a set of classes
What are APIs?
A set of rules and protocols that allows different software applications to communicate and exchange data
What are some examples of APIs?
Class-like methods in Java
REFER TO SLIDES FOR EXAMPLES
What are Modules?
If we have a module – a collection of classes – then
- The specification for all the externally accessible classes, methods and so on in a module make up what is called the API of the module – the “Application Programming Interface”
What do you need to consider with APIs?
The API documentation does not normally say how the function is to be implemented – just what its return value and effects are.
- This means that if the library developer decides to reimplement the function in another way (for instance, to improve efficiency), they can, without changing the API.
- Where you can have multiple implementations of the same API by different developers.
What is Specification and how does it link to APIs
This is the promise the API makes to its users.
* It defines:
* What the method does (its effect).
* What inputs it takes (parameters).
* What it returns (output/return type).
* Side effects, if any (e.g., prints to screen, modifies a file).
* It does not define how the task is performed.
Example:
The method int indexOf(char ch) is specified to return the index of the first occurrence of a character — it doesn’t say how it finds that index (e.g., loop, binary search, SIMD…).
What is Implementation and how does it link to APIs?
This is the internal code or logic that performs the work behind the scenes.
* Developers can change the implementation as long as the method continues to behave exactly as described in the specification.
* This might be done to:
○ Fix bugs.
○ Improve performance.
○ Reduce memory usage.
○ Improve security.
Example:
A sorting method like Arrays.sort() could switch from quicksort to mergesort internally, and as long as the result is still a sorted array, the API remains unchanged.
REFER TO JAVA EXAMPLES
What is ‘illities’ in specificationa vs implementation?
Normally:
* Specifications (API documentation) focus only on:
○ What inputs are needed.
○ What output is produced.
○ What the function promises to do.
* Implementation details are hidden so they can be changed freely (as long as the behavior remains the same).
===
But sometimes, “how” it works matters — this is where the “ilities” come in:
The “-ilities” refer to non-functional requirements like:
* Performance
* Scalability
* Maintainability
* Reliability
* Usability
* Portability
What is the overall understanding of APIs?
- The API describes the expected behaviour of a module (or larger system).
- The code constitutes a particular implementation of that API.
What should go in the API documentation?
The preconditions – any conditions which should be satisfied by the parameters or the system state when the function is called.
The postconditions – the return value of the function, and any changes the function makes to the system state (the “side effects” discussed earlier)
===
We often also will document what will happen if the preconditions aren’t satisfied: in many languages, this will typically be an exception being thrown.
- Where once we know the preconditions and postconditions for a function,
we can write tests for it.
What is Top-Down approach in developing systems?
Top-Down (a.k.a. Stepwise Refinement):
* Idea: Start from the big picture (the full system or a high-level goal).
* Process:
○ Break the system into smaller, more manageable components or subsystems.
○ Keep refining until each part is simple enough to implement.
* Analogy: Like designing a building by starting with a floor plan, then breaking it down into rooms, then furniture, and so on.
What is Bottom-Up approach in developing systems?
Bottom-Up:
* Idea: Start with low-level details or known building blocks.
* Process:
○ Identify existing or needed functionalities (like utility functions or individual classes).
○ Build up from these pieces to form the complete system.
* Analogy: Like assembling LEGO pieces to create something larger, figuring it out as you go.
Why is Bottom-Up favoured in object-orientated (OO) system design?
- Classes Come First in OO Design
- Sometimes Top-Down Is Still Needed
- Key OO Design Focus: Grouping
What is Classes Come First in OO Design?
- By the time you start system-level design, you usually already have a bunch of predefined classes (like User, Product, DatabaseManager, etc).
- These classes already encapsulate functionality, and now your task is to assemble them into a coherent system.
What is Sometimes Top-Down Is Still Needed
- You might still need to break classes further if you’re unsure how to implement them internally (e.g., a class may have too many responsibilities).
- This is when top-down decomposition can still be useful.
What is Key OO Design Focus: Grouping
- A major challenge in OO design is figuring out how to group related classes into modules, components, or subsystems.
- This helps with:
○ Maintainability (clear structure)
○ Reusability (modular design)
○ Scalability (easy to add new features)
- This helps with: