week 7 Flashcards
What does tactical programming prioritise?
speed
What is complexity
hard to understand and modify system
What does strategic programming prioritise
design
what are the advantages / features of tactical programming
. we need features or the task to be working as fast as possible
. working code alone is fine
Work on code without considering:
. design / improvements for design
. unit tests
. Leads to code with High complexity ( hard to understand and modify)
. Productivity will waver in long term
what are the features of strategic programming
working code is not enough and we need to focus on design
. pay time on :
- finding best design
- unit tests
.
.
.
compare the progress over time with tactical and strategic programming
Long term strategic progress is smaller ( due to inital time costs when dealing with design)
However will have more productivity than tactical in long term as tactical is complex
design principles are general guidelines offering flexibility in their application.
vfjg
what is the is one of the design principles ( deals with efficiency)
KISS
Keep it simple , straightfoward
Always pick most efficient ,simple approach
Loose coupling
Avoid tight coupling where 2 or more components are highly related to each other
High cohesion
elements of a cetain module are highly related
What is the S in Solid
Single responsibility principle
Class should have only one reason to change
O in SOLID
Open and Closed principle
open for extenstion and closed for modification :
L in solid
Liskov substitution principle
If s is a subtype of T , objects of type t can be replaced with s whilst STILL ACHIEVING DESIRED FUNCTIONALITY
eg an array (1,2,3,4)
desired functionality -> sorts in ascending order
(T -> Sorter class which sorts the array)
subtypes (s)
bubble sorter Adheres to liskov - sorts in asc
quick sorter Adheres to liskov - sorts in asc
random sorter does not adhere to likov as sorts in random order ( doesnt achieve desired functionality when sorter is replaced with random sorter)
. polymorphsm
Consistency and Predictability: Clients interacting with objects through base class interfaces can rely on consistent behavior across different derived classes.
Code Understanding: Developers can reason about the behavior of objects based on their common interface without having to worry about unexpected behavior in derived classes
just read
Interface segregation :
Reduced Dependencies: By breaking down large interfaces into smaller, more focused ones, classes become less
dependent on methods they don’t use. This reduces unnecessary dependencies and minimizes the impact of changes in
one part of the system on unrelated parts.
Enhanced Readability and Comprehensibility: Smaller interfaces with specific responsibilities are easier to read and
understand. Developers can quickly grasp the purpose of an interface and the methods it contains, leading to better overall
code comprehension.
Encourages Single Responsibility Principle (SRP): ISP is closely related to the Single Responsibility Principle (SRP).
Breaking down interfaces into smaller ones often aligns with the idea of each class having a single responsibility. This
separation of concerns makes code more modular and easier to manage.
just read