ProceduralOCR J277
DashboardCoursePracticeReviewProgressGlossary
Saved on this deviceContinue learning

Procedural · OCR J277 programming practice

Progress stays in this browser unless you export it.

Course/Robust programs/Defensive design and authentication
J277 · 2.3.1

Unit 10 · Lesson 1

Defensive design and authentication

Lesson progress0 / 7

Build the idea

Start with the concept and its key vocabulary.

Key idea

Explain defensive design and implement a simple username-and-password authentication check.

Defensive design anticipates what could go wrong and makes the program respond safely rather than crash or grant access incorrectly. Authentication checks identity so only authorised users proceed. In a simple programming exercise, both the username and password must match their stored values. Real systems do not store visible plain-text passwords, but the small example teaches the selection logic.

Defensive design

Designing a program to handle misuse and unexpected input safely.

Authentication

Verifying a user's identity, commonly with a username and password.

Authorised

Given permission to access a system or resource.

Input sanitisation

Removing invalid or dangerous characters from input before it is processed.

Keep these in mind

  • Authentication verifies identity and limits access to authorised users.
  • Both username and password must match, so the condition uses AND.
  • Defensive design also includes validation, anticipating misuse and input sanitisation.
  • A failed check should produce a controlled response.
  • A loop can limit the number of authentication attempts.

Learning objective

Explain defensive design and implement a simple username-and-password authentication check.

Exam tip

Name the defensive method and apply it to the context: authentication ensures only authorised users gain access, for example by checking a username and password.

Common mistake

Using OR grants access when only one credential matches. Authentication requires the username AND the password to be correct.

PreviousNext