Chapter 5.5-Architecture, Implementation, and Testing
Chapter 5.5-Architecture, Implementation, and Testing
5: Architecture,
Implementation, and Testing
© Len Bass, Paul Clements, Rick Kazman, distributed under Creative Commons Attribution License
Architecture and Implementation
© Len Bass, Paul Clements, Rick Kazman, distributed under Creative Commons Attribution License
Embedding the Design in the Code
© Len Bass, Paul Clements, Rick Kazman, distributed under Creative Commons Attribution License
Code Templates
• Process:
– Use the code template for every critical
component that must have a hot standby.
– Place application specific code in fixed places
within the template.
© Len Bass, Paul Clements, Rick Kazman, distributed under Creative Commons Attribution License
Advantages of Code Templates
• Components with similar properties behave in
a similar fashion.
• Template only needs to be debugged once.
• Complicated portions can be completed by
skilled personnel and handed off to less skilled
personnel.
© Len Bass, Paul Clements, Rick Kazman, distributed under Creative Commons Attribution License
Keeping Code and Architecture Consistent
© Len Bass, Paul Clements, Rick Kazman, distributed under Creative Commons Attribution License
Preventing Architecture Erosion
• Use tools to enforce architectural constraints.
– can have architecture rules added that are
enforced during a build or check in.
• Mark documentation as out of date when
erosion occurs. Will give more credence to
remaining portion.
• Schedule documentation/code
synchronization times.
© Len Bass, Paul Clements, Rick Kazman, distributed under Creative Commons Attribution License
Architecture and Testing
• Unit test
• Integration test
• Network effects
• Test activities
© Len Bass, Paul Clements, Rick Kazman, distributed under Creative Commons Attribution License
Unit Test
• Architecture defines the units that are to be tested. They are
components or modules.
• Architecture defines the responsibilities and interactions of
the units.
• Test harness will drive the element to be tested. The test
harness can test:
– Responsibilities for functional correctness
– Performance through synthetic loads
– Availability through fault injection. i.e. what happens if a
component on which the component being tested does not
respond.
• Modifiability requirements can also be tested by assigning
changes to test teams.
© Len Bass, Paul Clements, Rick Kazman, distributed under Creative Commons Attribution License
Integration Test
• As with unit test, integration test can test
functionality, performance, availability, and
security.
• Security can be tested by having the test
harness execute various attack scenarios.
• Systems may degrade after being run for a
long time if resources are not freed or a
configuration is incorrectly specified.
© Len Bass, Paul Clements, Rick Kazman, distributed under Creative Commons Attribution License
Network Effects
• Suppose an error causes a 2% performance degradation.
– This is within normal variation if using one server
– May cause severe degradation if system is deployed to
thousands of servers.
• Configuration errors are common during installation and
can lead to network effects. i.e. routing a message
through an intermediary rather than directly will
introduce latency.
• In Chapter 10 we saw the Latency Monkey and the Chaos
Monkey as testing techniques for running systems.
• Network effects are best found through self-aware
systems, i.e. system monitors itself and makes values
available externally.
© Len Bass, Paul Clements, Rick Kazman, distributed under Creative Commons Attribution License
Test Activities
• The architect should be actively involved in
– Test planning, since the architect knows the sensitive
areas of the system.
– Test development. Test driven development is a
technique where the next increment of the system is
developed to satisfy a predetermined test.
– Test interpretation. The architect knows what various
monitored values should be and is best equipped to
interpret test results.
– Test harness creation. The test harness has to intimately
interact with the system and this requires architecture
knowledge.
© Len Bass, Paul Clements, Rick Kazman, distributed under Creative Commons Attribution License
Summary
• Implementation
– Implementation activities can embed architecture knowledge in
the code
– Templates can be used for critical sections that reoccur
– Architecture erosion can be prevented through use of tools and
management processes
• Testing
– Unit and integration tests depend on architectural knowledge
and a test harness.
– Network effects are difficult to discover when deploying a
system to 1000s of servers.
– The architect should be involved in a wide variety of test
activities.
© Len Bass, Paul Clements, Rick Kazman, distributed under Creative Commons Attribution License