Upload
zeb-mason
View
101
Download
0
Embed Size (px)
Citation preview
Inside ArchitectureWhat I meant to say at dotnetsheff 2016/08/02
Zeb MasonCopyright © 2016 by Zeb Mason
Triangular numbers•Add 1 + 2 + 3 + … + N•Add N + N-1 + … + 1•So N lots of N + 1
Copyright © 2016 by Zeb Mason
Triangular numbers•Add 1 + 2 + 3 + … + N•Add N + N-1 + … + 1•So N lots of N + 1
•Sum is
Copyright © 2016 by Zeb Mason
Triangular numbers•Add 1 + 2 + 3 + … + N•Add N + N-1 + … + 1•So N lots of N + 1
•Sum is •Schoolboy maths!
Copyright © 2016 by Zeb Mason
Edges in a graph•Undirected graph•N nodes•+1 node => +N edges• i.e. triangular number •Max /2 edges
•Directed graph•Double the sum•Max edges
Copyright © 2016 by Zeb Mason
Edges in a graph•Undirected graph•N nodes•+1 node => +N edges• i.e. triangular number •Max /2 edges
•Directed graph•Double the sum•Max edges
Copyright © 2016 by Zeb Mason
Edges in a graph•Undirected graph•N nodes•+1 node => +N edges• i.e. triangular number •Max /2 edges
•Directed graph•Double the sum•Max edges
Copyright © 2016 by Zeb Mason
MetricsCyclomatic number:
E + P – N Cyclomatic complexity:
E + 2P – Nwhere
E is the number of edgesP is the number of parts
Copyright © 2016 by Zeb Mason
Metric invarianceCyclomatic number:
E + P – N = 2 + 1 – 3+ 1 + 1 – 2 = 0
Copyright © 2016 by Zeb Mason
Spot the difference
3 layer architecture
3 tier architecture
A
B
C
A
B
C
Copyright © 2016 by Zeb Mason
Spot the difference
3 layer architecture
3 tier architecture
A
B
C
A
B
C
using B
Copyright © 2016 by Zeb Mason
Spot the difference
3 layer architecture
3 tier architecture
A
B
C
A
B
C
using C
using B
Copyright © 2016 by Zeb Mason
Spot the difference
3 layer architecture
3 tier architecture
A
B
C
A
B
C
address of B
using C
using B
Copyright © 2016 by Zeb Mason
Spot the difference
3 layer architecture
3 tier architecture
A
B
C
A
B
C
address of B
address of Cusing C
using B
Copyright © 2016 by Zeb Mason
Find architecture patterns in code• Dependency analysis• e.g. Layered architecture
• Heap analysis• e.g. Tiered architecture
• Change in heap• e.g.
Copyright © 2016 by Zeb Mason
Find design patterns in code• Dependency analysis• e.g. Factory method
• Heap analysis• e.g.
• Change in heap• e.g.
Copyright © 2016 by Zeb Mason
Find design patterns in code• Dependency analysis• e.g. Factory method
• Heap analysis• e.g. Composite
• Change in heap• e.g.
Copyright © 2016 by Zeb Mason
Find design patterns in code• Dependency analysis• e.g. Factory method
• Heap analysis• e.g. Composite
• Change in heap• e.g. State machine
Copyright © 2016 by Zeb Mason
Visual Studio 2015
$2999 p.a.
•Create digraphs in Enterprise•Save as a DGML file•Open in Community or Professional
Copyright © 2016 by Zeb Mason
Tools•NDepend•Lattix•structure101•Visual Studio•DeepEnds•NsDepCop
• Visual Studio extension• Listed on Visual Studio gallery
• Input• csproj files
• parsed by Roslyn• .NET assemblies
• decompiled by Mono.Cecil• vcxproj.filter files
• Output• DGML file
• Structured by namespace or filter• Nodes hyperlink to source code files
• HTML report• Cyclomatic number• Underlying dependencies
Copyright © 2016 by Zeb Mason
Tools•NDepend•Lattix•structure101•Visual Studio•DeepEnds•NsDepCop
• Visual Studio extension• Listed on Visual Studio gallery
• Input• csproj files
• parsed by Roslyn• .NET assemblies
• decompiled by Mono.Cecil• vcxproj.filter files
• Output• DGML file
• Structured by namespace or filter• Nodes hyperlink to source code files
• HTML report• Cyclomatic number• Underlying dependencies
Copyright © 2016 by Zeb Mason
Tools•NDepend•Lattix•structure101•Visual Studio•DeepEnds•NsDepCop
• Visual Studio extension• Listed on Visual Studio gallery
• Input• csproj files
• parsed by Roslyn• .NET assemblies
• decompiled by Mono.Cecil• vcxproj.filter files
• Output• DGML file
• Structured by namespace or filter• Nodes hyperlink to source code files
• HTML report• Cyclomatic number• Underlying dependencies
Copyright © 2016 by Zeb Mason
Concrete class inherits interfacenamespace Mono.CompilerServices.SymbolWriter{
public class CompileUnitEntry : ICompileUnit{}
}
Copyright © 2016 by Zeb Mason
Interface returns concrete class!namespace Mono.CompilerServices.SymbolWriter{
public class CompileUnitEntry : ICompileUnit{}
public interface ICompileUnit{
CompileUnitEntry Entry {get;
}}
}
Copyright © 2016 by Zeb Mason
NsDepCop• Some dependency analysis tools enforce design intent by rules• i.e. one component cannot depend on another• e.g. NsDepCop rules on namespace dependencies
• These rules can be run automatically• e.g. NsDepCop is run by MSBuild• Rule violations can be acted upon
Copyright © 2016 by Zeb Mason
The End• Related articles on CodeProject• As-Is Software Architecture• Dive into Architecture with DeepEnds
• Source on GitHub• zebmason/itdepends• zebmason/netdepends
• Extension on Visual Studio gallery• DeepEnds
Copyright © 2016 by Zeb Mason