Interfaces, Contracts and Protocols Flashcards
What is an interface?
An interface is a description of the actions that an object can do.
A set of behaviours.
A contract between the object & things that are using/implementing that object.
Imagine a vehicle. It can turn left/right & drive forwards/backwards. You don’t care how, just that is does.
In Object Oriented Programming, an Interface is a description of all functions that an object must have in order to be an ”X”
Why should should interface be used?
To organising functionality into relevant and focused behaviours.
It can function as a contract within development teams
- Helps abstracting & generalising your code - for other users/programmers
It makes your code scalable & flexible when coding towards interfaces and not implementation.
To minimise the cost of change & maintenance.
Useful when testing.
- (read first 6 lines if u can’t remember what pros there are about abstraction -
(https: //stackify.com/oop-concept-abstraction/))
What is an interface not?
A class that contains constructors - rather it is implemented by classes.
Able to be instantiated
Able to contain anything else than method signatures
and constants, static, final fields
Able to be extended by a class - it is implemented by other classes/interfaces
Is and interface extended or implemented by a class?
It is implemented.
Mention some main protocols use in the File Transfer pattern.
HTTP/HTTPS, FTP, SFTP/SCP
all based on client/server architecture.
What is HTTP?
Typer Text Transfer Protocol - application layer protocol.
HTTP can fetch resources like HTML, CSS, JSON, XML etc via the request/response pattern.
HTTP is connection-less, mediaindependent & stateless.
HTTPS is the common use for web servers since it adds SSH security.
What is FTP?
File Transfer Protocol.
It is and old protocol & should not be used since it uses “clear text” password (unencrypted).
FTP is stateful meaning that it will maintain state information like a user’s current directory.
What is SFTP?
Secure File Transfer Protocol.
replaces FTP & adds an extra layer of security (through SSH) to FTP.