Design Principles and Python Knowledge

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

blue-green deployment

A "change management" strategy for releasing software code. Requires two identical hardware environments that are configured exactly the same way. While one environment is active and serving end users, the other environment remains idle. Good for seamless deploys and rollbacks.

D in SOLID

Dependency inversion principle - 1. High-level modules should not depend on low-level modules. Both should depend on abstractions. 2. Abstractions should not depend on details. Details should depend on abstractions. Often solved by using Dependency Injection (https://itnext.io/solid-principles-explanation-and-examples-715b975dcad4)

What functions does a class need to be an "iterable" in Python.

Either: 1. __iter__ that returns a fresh iterator, which in turn has a __next__ method that: returns the next value in the iteration, updates the state to point to the next value, signals when it is done by raising a StopIteration 2. __getitem__ method suitable for an indexed lookup

I in SOLID

Interface segregation principle - no client should be forced to depend on methods it does not use / Do not add additional functionality to an existing interface by adding new methods (https://itnext.io/solid-principles-explanation-and-examples-715b975dcad4)

L in SOLID

Liskov substitution principle - S is a subtype of T, then objects of type T may be replaced (or substituted) with objects of type S (https://itnext.io/solid-principles-explanation-and-examples-715b975dcad4)

Open/closed principle - software entities (classes, modules, functions, etc.) should be open for extensions, but closed for modification i.e. Use polymorphism/inheritance to extend/override functionality of a parent class. Don't shove a bunch of different conditionals into a single function to get the behavior you need. (https://itnext.io/solid-principles-explanation-and-examples-715b975dcad4)

Open/closed principle - software entities (classes, modules, functions, etc.) should be open for extensions, but closed for modification (https://itnext.io/solid-principles-explanation-and-examples-715b975dcad4)

S in SOLID

Single responsibility principle - every module or class should have responsibility over a single part of the functionality provided by the software. (https://itnext.io/solid-principles-explanation-and-examples-715b975dcad4)

Dependency Injection

a technique whereby one object supplies the dependencies of another object e.g. Don't instantiate a logger class within another class. Pass that logger to the class's constructor. e.g. Don't instantiate a db class within another class, supply the db to that class's functions where needed.

Swap values in-place in python

a, b = b, a

How to use infinity and negative infinity in Python

float("inf"), float("-inf")

Difference between <iterable>.sort and sorted(<iterable>) in Python

list.sort() sorts the list in-place, sorted returns a new sorted list


Ensembles d'études connexes

Media Law Chapter 5: Invasion of Privacy

View Set

Test 1 Pediatric Nursing NCLEX Practice | Quiz #2: 50 Questions

View Set

ECON Lowdown Insurance: Managing Risk and Balancing Responsibility with Affordability

View Set

physics ch 1 and 2 hw and physics primer things to know

View Set

Functional Organization of Nervous Tissue

View Set

Module 2.01 ETHICAL DECISION MAKING PROCESS

View Set

Chapter Exam Review - Attempt #5 - Incorrect Answers

View Set