1/50
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
robustness, adaptability, reusability
In object-oriented programming (OOP) and software development, ______, ______, and _______ are core design principles that describe the quality of well-designed software.
Robustness
_________ is the ability of the software to handle errors, invalid input, and unexpected situations without crashing or behaving incorrectly.
Adaptability
_______ is the ability of software to change or be extended easily when requirements evolve, without rewriting large parts of the code.
Reusability
_________ is the ability to use the same code in multiple programs or parts of a program without duplication.
classes, objects
In object-oriented programming, you write _____ that represent real-world things and situations, and you create _____ based on these classes.
When you write a class, you….
define the general behavior that a whole category of objects can have.
automatically equipped withe the general behavior;
When you create individual objects from the class, each object is…. you can then give each object whatever unique traits you desire.
instantiation
Making an object from a class is called ______.
instances
You can work with _____ of a class.
information that can be stored, actions that can be taken
In classes, you’ll specify the kind of …. in instances, and you’ll define …. with these instances
Principles of OOP
Encapsulation
Inheritance
Polymorphism
Abstraction
Encapsulation
Bundles data (attributes) and methods (functions) into a single unit — the class.
Protects internal state by using private variables and methods
Example: You can hie details and expose only what’s necessary
Inheritance
Allows one class to inherit properties and methods from another
Promotes code reuse and logical hierarchy
Example: A Dog class can inherit from an Animal class.
Polymorphism
Let's different classes respond to the same method name in different ways
Abstraction
Hides complex implementation details and shows only essential features.
Helps simplify code and focus on what an object does, not how it does it.
Method
A function that is a part of a class
It is a constructor/special method that Python runs automatically whenever we create a new instance of a class.
What is the __init__ method?
object attribute, specific object
An _____ ______ belongs to a ______ _______. It is usually defined in the init using self.
Every method call associated with an instance automatically passes self, which is a reference to the instance itself; it gives the individual instance access to the attributes and methods in the class.
True
Any variable prefixed with self is available to every method in the class, and we’ll also be able to access these variables through any instance created from the class.
True
Use an object attribute when the value:
Belongs to the object
Doesn’t change often
Describes the object’s state or identity
Use a method parameter when the value:
Is temporary
Changes each time the method is called
Describes how the action is performed, not what the object is
Polymorphism
Different objects can use the same method name but behave differently
Python supports it because it’s dynamically typed
Inheritance
A fundamental concept in OOP that allows a class (called a child or subclass) to programming inherit properties and behaviors (methods and attributes) from another class (called a parent or superclass).
Inheritance enables…
Code reuse: Common functionality can be written once in the parent class and reused by child classes.
Hierarchy modeling: You can represent real-world relationships (ex. Dog is an Animal)
Extensibility: Child classes can add or override functionality without modifying the parent class
Method Overriding
When a subclass provides its own implementation of an inherited method so that the subclass version is used instead of the parent’s version when the method is called.
Method extension
When a subclass overrides a method but still calls the parent class’s version.
Key Characteristics of Method Extensions
You can override the method in the subclass
You can call the method super().method()
You can add new behavior before or after that call
LIFO
Last-In First-Out
LIFO principle
A stack is a collection of objects that are inserted and removed according to the _____ _______.LI
most recently inserted object
You can insert objects into a stack at any time but may only access or remove the _____ _____ _____ _____.
Stack examples
Internet web browsers store the addresses of recently visited sites in a stack
Text editors “undo” button
Implementation of recursion in programming languages.
push(e)
Adds element e to the top of the stack
pop()
Removes and returns the top element from the stack (or null if the stack is empty)
peek() or top()
Returns the top element of the stack. It doesn’t remove the element.
size()
Returns the number of elements in the stack.
isEmpty()
Returns a Boolean indicating whether the stack is empty.
Encryption & Decryption
Some encryption algorithms use stacks to reverse data or manage operations in a specific order.
For example, reversing a message before encryption or during decryption can be done using a stack.
Parsing & Validation
Stacks are used in validating expressions, such as checking for balanced parentheses in code or data formats
This is useful in input validation, which is a key part of preventing injection attacks.
Log File Analysis
Cybersecurity professional often analyze logs to detect anomalies, intrusions, or failures. Since logs are typically appended chronologically.
Reading in reverse allows you to quickly access the most recent events.
Useful for incident response, where time is critical and you want to see what happened just before a breach
Crash or Error Diagnostics
If a system crashes or an application fails
The last few lines of a log file often contain the error messages or stack traces
Reverse reading helps isolate the root cause quickly.
Queue Characteristics
It is a relative — cousin of stack data structure
FIFO principle — first in, first out
We usually say that elements enter a queue at the back and are removed from the front.
enqueue(e)
Adds element to the end (rear) of the queue.
dequeue()
Removes and returns the element from the front of the queue
peek(), first()
Returns the first element of the queue. It doesn’t remove the element.
size()
Returns the number of elements in the queue.
isEmpty()
Returns a Boolean indicating whether the queue is empty.
Examples of Queues
Scheduling processes in multitasking systems
Managing requests in print or disk queues
Queues in call centers or ticket booking system to ensure first-come, first-served service.
Packeting Processing
Network packets arrive continuously
A queue helps store packets temporarily before inspection
This ensures orderly processing an avoids packet loss during high traffic
Email or Message Filtering
Incoming messages are queued for spam or phishing analysis
This helps prevent malicious content from reaching users
deque
_____ is a special type of data structure. It’s prefered over a list for queues because both append() and popleft() run in O(1) time. No shifting needed
append()
adds an element to the right end of the deque.
popleft()
removes and returns the element from the left end of the deque