Software Engineering Principles

Why is well designed software important???

When you only do this loop (SDLC) once, writing bad code has minimal impacts. But when we complete this "cycle" many times, modifying bad code comes at a high cost :(

Why do we write bad code???

1. Design Smells - smell that bad things :)

Rigidity: Tendency to be too difficult to change Fragility: Tendency for software to break when single change is made Immobility: Previous work is hard to reuse or move Viscosity: Changes feel very slow to implement Opacity: Difficult to understand Needless complexity:  Things done more complex than they should be Needless repetition: Lack of unified structures Coupling: Interdependence between components

2. Design Principles

Often, this is achieved through abstraction.

1. DRY

"Don't repeat yourself" (DRY)

DRY is about reducing repetition in code.

Example 1:

import sys

if len(sys.argv) != 2:
	sys.exit(1)
	num = int(sys.argv[1])

if num == 2:
	for i in range(10, 20):
		result = i ** 2
		print(f"{i} ** 2 = {result}")

elif num == 3:
	for i in range(10, 20):
		result = i ** 3
		print(f"{i} ** 3 = {result}")

else:
	sys.exit(1)