Luokat: Kaikki - complexity - design - principles - metrics

jonka Igor Polishchuk 8 vuotta sitten

349

Architecture principles

The document discusses various software architecture and design principles, focusing on the Law of Demeter (LOD) and its implications for code safety and maintainability. The LOD emphasizes minimal interaction between units, advocating communication only with closely related entities to reduce dependencies and facilitate safer code changes.

Architecture principles

We can have ~7 entities in same time in mind

Architecture principles

Metrics

Optimal values: http://stackoverflow.com/questions/2033743/code-metrics-calculation-in-visual-studio
Metrics types
Weighted Methods per Class (WMC)

Sum of complexity of all class methods

http://staff.unak.is/andy/StaticAnalysis0809/metrics/wmc.html

Response for Class (RFC)

lower RFC - lower bugs

inokation complexity on message

http://staff.unak.is/andy/StaticAnalysis0809/metrics/rfc.html

What is metrics: https://msdn.microsoft.com/en-us/library/bb385914.aspx

Design Patters

Command
Chain of responsibility
wiki(ru): https://ru.wikipedia.org/wiki/%D0%A6%D0%B5%D0%BF%D0%BE%D1%87%D0%BA%D0%B0_%D0%BE%D0%B1%D1%8F%D0%B7%D0%B0%D0%BD%D0%BD%D0%BE%D1%81%D1%82%D0%B5%D0%B9
Relay messages

Principles

Law of Demetr (LOD)
Layer architecture is an implementation of LOD
Cons

Wrappers time & space overhead

Pros

Potentialy lower Response for Class (RFC) Metric

Lower dependencies between classes

Safer code change

Links

Why its needed (ru): https://toster.ru/q/44822

Wiki (en): https://en.wikipedia.org/wiki/Law_of_Demeter

Base postulates

Only talk to your immediate friends

Each unit should only talk to its friends; don't talk to stangers

Every unit should have limited knowledge about other units: only "closely" related to the current unit