with an automated - coding the architecturestatic.codingthearchitecture.com/presentations/dw... ·...

66
What is software architecture? What is the role of a software architect? How do you define software architecture? How do you share software architecture? How do you deliver software architecture? Software architecture for developers Improving software quality with an automated build process

Upload: others

Post on 26-Jun-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

What is software architecture?

What is the role ofa software architect?

How do you definesoftware architecture?

How do you sharesoftware architecture?

How do you deliversoftware architecture?

Software architecture for developers

Improving software quality with an automated

build process

Page 2: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

[email protected]

@simonbrown on Twitter

Page 3: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Software Architecture for Developers (.com)

What is software architecture?

What is the role ofa software architect?

How do you definesoftware architecture?

How do you sharesoftware architecture?

How do you deliversoftware architecture?

Page 4: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Who should doall of this?It should be the architect

(somebody has to do it and that’s why

we get paid the big bucks)

Definition

Management of non-functional requirements

The role of a software architect

Delivery

Ownership of the bigger picture

LeadershipCoaching and mentoring

Quality assurance

Design, development and testing

Technology selection

Architecture definition

Architecture evaluation

Architecture collaboration

This is what we

write about on our website...

www.codingthearchitecture.com

A hands-on software architect can be

invaluable for preventing

project failure

A hands-on software architect

can be invaluable for driving

project successWebsite

http://www.codingthearchitecture.com

London User Group

Monthly mix of presentation and discussion

Google Group

http://groups.google.com/codingthearchitecture

www.codingthearchitecture.com

Why Software Projects Fail

Simon Brown

Hands-on software

architect

Why software projects fail...

...architects are here

to help, not to hinder

Software projects fail

for a number of reasons

Iterative and agile techniques

solve some problems...

Page 5: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Definition

Management of non-functional requirements

The role of a software architect

Delivery

Ownership of the bigger

pictureLeadership

Coaching and mentoring

Quality assurance

Design, development and testing

Technology selection

Architecture definition

Architecture evaluation

Architecture collaboration

Page 6: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Our system

Page 7: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Internet banking system predominantly built on the

Microsoft .NET platform

C# code on th

e

.NET 3.5 framework

Page 8: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

It provides a

web facade

over existing business systems

Page 9: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Distributed architecture

Page 10: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

ASP.NETwebsites

Page 11: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Windows Communication

Foundationservices in the middle-tier

Page 12: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

SQL Server

database

Page 13: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

XML/TCP

connectivity to theback-end banking system

Page 14: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

80+ASP.NET pages

Page 15: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

30,000+lines of C#.NET code

Page 16: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

650+classes

Page 17: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

4WCF services with

100+service operations between them

Page 18: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

50+SQL stored procedures

Page 19: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

5+ man-yearsof development

(it’s not a massive system but there is some complexity in there)

Page 20: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Why is quality important?

Page 21: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Reputationof the business(e.g. driven by customer satisfaction)

Page 22: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Service level agreements& key performance indicators

(e.g. between suppliers, between systems,non-functional requirements, etc...)

Page 23: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Reputationof the development team

It’s importantthat we know

whatwe’re releasing

It’s important that the

software we release

“works”That’s us!

Page 24: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Our softwaredevelopment tools

and processes

Page 25: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Visual Studio 2008

Page 26: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

AnkhSVNhttp://ankhsvn.open.collab.net

TestDriven.Nethttp://www.testdriven.net

Page 27: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

NCover (& NCoverExplorer)http://www.ncover.com

We use NUnit for

writing our tests

Page 28: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Unit &

integration tests

“Functional” tests across container

boundaries

Low-level tests for classes and components

We have ~3000 automated

tests in total

Page 29: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

System

Container

Container

Container

Component

Component

Component

Class

Class Class

Class

Page 30: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

System

Container

Container

Container

Component

Component

Component

Class

Class Class

ClassWe have

~2800 automated

unit tests in t

otal

Page 31: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

System

Container

Container

Container

Component

Component

Component

Class

Class Class

Class We have ~200 automated

integration te

sts in total

Page 32: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

We’re lucky to have a

dedicatedteam member running the tests

several times a day

Page 33: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

CruiseControl.NET

SubversionSource code repository

Development ServerMiddle-tier

Development ServerWeb-tier

Development ServerDatabase

CruiseControl.NETgets the source code from the repository and

runs the build script; compiling, testing, packaging and

installing the software

Page 34: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Continuous &

nightly builds

Continuous build + longer running

integration tests

Build-Test-Run when we commit code to

the repository

Page 35: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

It’s important that everybody gets

feedback(particularly when the build is broken,

otherwise what’s the point in having all of this automation?)

Page 36: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

This is what happens when we

break something...

Page 37: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

There are other, more extreme feedback devices

Page 38: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

You can also use blogs, RSS and newsreaders

Page 39: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

E-mail build notifications

are not effective

Page 40: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Code branching

Page 41: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

We follow Subversion project

guidelines for

repository layout

Page 42: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

SubversionSource code repository

Internet Banking system/branches

/live bug fixes/work-stream 1/work-stream 2

/tags/trunk

Chapter 5: Reposito

ry

Administration - A

dding

Projects

http://svnboo

k.red-bean.com

/en/1.0/ch05s04.html

This is the main development stream

All work is performed on branches

Page 43: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

SubversionSource code repository

Internet Banking system/branches

/work-stream/source code/tools/build script

External depen

dencies

Subversion clien

t,

VS2008, .NET 3.5 & NAntThe build script lives next to the source code in the project

We check-in the tools used by the project and

build steps

Page 44: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

New projects &

branchesin CruiseControl.NET are managed through a

bespoke interface

Page 45: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

The build process

Page 46: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Things to do when

building a release

1. Compile the code in release mode

2. Publish files to IIS

3. Maybe check it works

Page 47: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Automationis a good thing

Page 48: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Nant is for developers as well as CruiseControl.NET

d:\subversion\ib4\trunk> nantNAnt 0.85 (Build 0.85.2478.0; release; 14/10/2006)Copyright (C) 2001-2006 Gerry Shawhttp://nant.sourceforge.net

Buildfile: file:///D:/subversion/ib4/trunk/ib.buildTarget framework: Microsoft .NET Framework 2.0Target(s) specified: CruiseControlCheckin

[loadtasks] Scanning assembly "NAnt.Contrib.Tasks" for extensions.[loadtasks] Scanning assembly "NCoverExplorer.NAntTasks" for extensions.

...

We also use NAntContrib

for lots of e

xtra

automation goodnes

s!

Page 49: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Release tasks1. Setup the build and get build metadata

2. Create virtual directories on IIS

3. Clean existing binaries and other resources

4. Run a debug build

5. Execute the unit tests

6. Execute the integration tests and diagnostics*

7. Generate a code coverage report

8. Run a release build and create release packages

9. Install the middle-tier applications

10. Install the web-tier application

11. Run a quick smoke test

12. Create the release bundle * nightly build only

Page 50: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Build metadatais generated and included

in the assemblies

<?xml version="1.0" encoding="utf-8" ?><version>

<ib.version>IB4.1.0g</ib.version> <svn.branch.name>@svn.branch.name@</svn.branch.name> <svn.revision>@svn.revision@</svn.revision> <build.datetime>@build.datetime@</build.datetime> <build.hostname>@build.hostname@</build.hostname></version>

Page 51: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

IIS virtual directory creation

is automated

<target name="CreateVirtualDirectories"> <mkiisdir dirpath="${base.dir}/ib.web/ib.web" website="Default Web Site" vdirname="ib.web" /> ...</target>

Page 52: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Database objects are scripted and those scripts are

executed during the integration tests

/// <summary>/// The SetUp method in this class runs before all other tests in this namespace/// to recreate the Banner table and stored procedures./// </summary>[SetUpFixture]public class BannerSetUp : AbstractMessagingIntegrationTests{ [SetUp] public void SetUp() { string path = @"..\..\ib.middletier.messaging.lib\Database\Banners\";

// create tables ExecuteSqlScript(string.Format(@"{0}Tables\Banner.sql", path));

// create stored procedures ExecuteSqlScript(string.Format(@"{0}StoredProcedures\GetBanner.sql", path)); ExecuteSqlScript(string.Format(@"{0}StoredProcedures\GetBanners.sql", path)); ExecuteSqlScript(string.Format(@"{0}StoredProcedures\UpdateBanner.sql", path));

// and load some initial data ExecuteSqlScript(string.Format(@"{0}InitialBanners.sql", path)); }}

Page 53: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Our basic diagnostic checks are

automatedand included in the build

DiagnosticsIs everything installed?

Can we see all of our services?

Are the external systems up and running?

Are all deployed components at the same version?

Do all tiers have the required configuration?

Are all tiers running the correct .NET runtime and framework?

Page 54: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

A quick bit of automated

smoke testing

<target name="SmokeTest"><exec program="jmeter.bat"

basedir="Software\jakarta-jmeter-2.3.2\bin" commandline="-n -t ib.web\ib-smoke-test.jmx -Jib4.users=personal,... -Jib4.numberOfUsers=6 -Jib4.protocol=http -Jib4.host=${ib.servername} -Jib4.context=${ib.context} -Jib4.password=******** -Jib4.memorable=*******" output="${build.dir}\smoketest.log" />

<loadfile file="${build.dir}\smoketest.log" property="smoketestLog" />

<fail unless="${string::contains(smoketestLog, '[personal] Logged off')}" message="Smoke test failed for personal user" />

</target>

Page 55: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories
Page 56: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

How much does this all cost?

Page 57: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

1-2 daysfor a basic automated build script

and continuous integration environment

Virtual machines make

excellent con

tinuous

integration se

rvers

Page 58: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

1-2 weeksfor a comprehensive build script

and continuous integration environment

Page 59: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Is this recommended

for all projects?

Page 60: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

The future?

Page 61: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Keep driving forward,spotting opportunities for

automationwhere it can add

value

Page 62: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

// todo: scriptable re

leases

d:\release> nant installNAnt 0.85 (Build 0.85.2478.0; release; 14/10/2006)Copyright (C) 2001-2006 Gerry Shawhttp://nant.sourceforge.net

Installing web-tier components...Installing middle-tier components...Installing database components...Modifying configuration for live environment...Running post-install diagnostics...Complete; version IB4.1.0.g has been installed.

Automated rollbacks

can be tricky

Page 63: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Let’s wrap up

Page 64: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

Build automation is relatively easyto do and the benefits are

huge

Page 65: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

1. Setup the build and get build metadata

2. Create virtual directories on IIS

3. Clean existing binaries and other resources

4. Run a debug build

5. Execute the unit tests

6. Execute the integration tests and diagnostics

7. Generate a code coverage report

8. Run a release build and create release packages

9. Install the middle-tier applications

10. Install the web-tier application

11. Run a quick smoke test

12. Create the release bundle

1. Compile the code in release mode

2. Publish files to IIS

3. Maybe check it works

From hope to improved software quality

and confidencein our releases

Page 66: with an automated - Coding the Architecturestatic.codingthearchitecture.com/presentations/dw... · Release tasks 1. Setup the build and get build metadata 2. Create virtual directories

[email protected]

@simonbrown on Twitter

http://www.codingthearchitecture.com

Software architecture for developers

Thanks for lis

tening.

Any questions?