software taxonomies patterns, styles, tactics,
TRANSCRIPT
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo
Software taxonomiesPatterns, styles, tactics,...
Jose E. Labra GayoCourse 2020/2021
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Software taxonomies
Building & MaintenanceConfiguration management
Modularity Decomposition at building time
Runtime Components and connectors
IntegrationAllocation
Packaging, distribution, deploymentBusiness and enterprise environment
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo
Software construction & maintenance
Jose E. Labra GayoCourse 2018/2019
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Software construction & maintenance
Configuration management
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Software: product or service
Software as a Product (SaaP): Software deliverable
Commercial model: software is sold to clientsSoftware distributed or downloaded
Example: Microsoft OfficeSoftware as a Service (SaaS):
Software deployedCommercial model: clients subscribe to itSoftware usually available at some URL
Example: Google docs
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Software configuration management
Managing the evolution of softwareManages all aspects of software constructionEspecially, how software evolves and changes
Aspects:Identifying baselines and configuration items
Baseline: A work product subject to managementIt contains configuration items: documents, code files, etc...
Configuration control & auditingVersion control systems
Building management and automationTeamworkDefect and issues tracking
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Software construction
Overview of methodologiesTraditional, iterative, agile
Construction toolsLanguages, tools, etc.
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Incremental piecemeal
Development by needCodification without following the architectureThrow-away softwareBudget constraints
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo
Software development life cycle (SDLC)Waterfall model identified as antipattern in 1970s
Waterfall
Requirements
Design
Implementation
Verification
Maintenance
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo V Model
Requirements
Analysis
Design
ObjectDesign
UnitTesting
IntegrationTesting
SystemTesting
AceptanceTesting
Time
DetailLevel
Low
High Implementation
Project Definition
Project Test and
Integration
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Big Design Up Front
Anti-pattern of traditional modelsToo much documentation that nobody readsDocumentation different from developed system
Architecture degradationSoftware implemented but unused
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Iterative Models
Based on PrototypesRisk assessment after each iteration
InitialPlanning
Planning
Requirements Analysis & Design
Implementation
Deployment
TestingEvaluation
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Agile methodologies
Lots of variantsRAD (www.dsdm.org, 95)SCRUM (Sutherland & Schwaber, 95)XP - eXtreme Programming (Beck, 99)Feature driven development (DeLuca, 99)Adaptive software development (Highsmith, 00)Lean Development (Poppendieck, 03)Crystal Clear (Cockburn, 04)Agile Unified Process (Ambler, 05). . .
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Agile methods
Agile Manifesto (www.agilemanifesto.org)
Individuals and interactions
overProcesses and
Tools
Working Software
ComprehensiveDocumentation
over
CustomerCollaboration
over ContractNegotiation
Respondingto change
over Following aPlan
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Agile methods
FeedbackChanges of code are OK during development
Minimize riskSoftware in short intervalsIterations of daysEach iteration takes all the development cycle
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Some agile principles (XP)
1. Adapt to change2. Testing3. Pair programming4. Refactoring5. Simple design6. Collective code ownership7. Continuous integration8. On-site customer9. Small releases10.Sustainable pace11.Coding standards
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Adopt change
After each iteration, update plansRequirements through user stories
Short descriptions (size of a card)Goals ordered by usnig according to priorityRisk and resources estimated by developers
User stories = acceptance testingWelcome changing requirements
Original plan
Current plan
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo TDD - Test driven development
Write a test before codingInitially, code will failGoal: pass the testResult:
Automated set of testsEasier refactoring
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Different types of testing
Unit testingCheck each unit separately
Integration testingSmoke testing
Acceptance testingCheck with user stories
Performance/capacity testing:Load testing
Regression testingCheck that new changes don’t introduce new bugs, or
regressions
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Types of testing
Functional Acceptance Testing
ShowcasesUsability testing
Exploratory testing
Nonfunctional Acceptance testing
(capacity, security,…)
Unit testingIntegration testing
System testing
Automated Manual
Automated Manual/ Automated
Supp
ort p
rogr
amm
ing C
ritique projectBusiness facing
Technology facing
Source: Continuous delivery, J Humble, D. Farley, 2010
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Acceptance testing
Behavior-driven development (BDD)Tests come from user storiesThey can be written collaboratively with the client
Tools: Cucumber, JBehave, Specs2,...Tests act as contractsCan also be used to measure progress
Feature: Buscar cursosPara mejorar el uso de los cursosLos estudiantes deberían ser capaces de buscar cursos
Scenario: Búsqueda por asuntoGiven hay 240 cursos que no tienen el asunto “Biología”And hay 2 cursos A001, B205 que tienen el asunto “Biología" When Yo busco el asunto “Biología"Then Yo debería ver los cursos:
| Código || A001 || B205 |
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Testing: FIRST Principles
F - FastExecution of (subsets of) tests must be quick
I - Independent: No tests depend on others
R - Repeatable: If tests are run N times, the result is the same
S - Self-checkingTest can automatically detect if passed
T - TimelyTests are written at the same time (or before) code
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Test doubles
Dummy objects: Objects that are passed but not used
Fake objects: Contain a partial implementation. Stubs: contain specific answers to some requestsSpies: stubs that record information for
debuggingMocks: mimic the behavior of the real object
Mocks may contain assertions about the order/number of times methods are called
Fixtures: Tools that support testsTesting databases, some files, etc.
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Environments
A staging environment is also used
Developmentenvironment
TestingEnvironments
ProductionEnvironment
TestingServer
IntegrationServer
VersionControl
ProductionServer
Server farm
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Pair programming & Code reviews
2 software engineers work togetherDriver manages keyboard and creates
implementationObserver identifies failures and gives ideas
Roles are exchanged after some timePull requests: Before accepting changes, code
can be reviewed
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Simplicity
Favor Simple designReaction to Big Design Up FrontObtain the simpler design that works
Automated documentationJavaDoc and similar tools
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Refactoring
Improve design without changing functionalitySimplify code (eliminate redundant code)Search new opportunities for abstraction
Regression testingBased on the test-suite
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Collective ownership of code
Code belongs to the project, not to some engineerEngineers must be able to browse and modify any
part of the codeEven if they didn't wrote itAvoid code fragments that only one person can
modify
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Continuous Integration
Frequently integrating one's new or changed code with the existing code repositoryRunning all unit and integration testsMerge all developer working copies
GoalsHelp Test Driven DevelopmentMaintain all programmers code up to dateAvoid integration hell
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo
Continuous IntegrationBest practices:
Maintain code repositoryAutomate the buildMake the build self testingEveryone commits to the baselineEvery commit should be builtKeep the build fastTest in a clone of the production environmentMake it easy to get the latest deliverablesEveryone can see the results of the latest buildAutomate deployment
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Continuous integration
Continuous integration toolsHudson, Jenkins, Travis, Bamboo
ContinuousIntegration
WebInterface
Reports
checkout/commit
Central Coderepository
DevelopmentTeam
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo On-place customer
Customer available to clarify user stories and help taking critical business decisions
AdvantagesDevelopers don't do guessesDevelopers don't have to wait for decisionsImproves communication
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Continous delivery
Small releasesSmall enough while offering value to the user
Obtain feedback soon from clientDelivery models
Try to release something every night/week...Continuous and automated delivery
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Sustainable pace
Avoid extra-work loads40h/week = 40h/week
Tired programmers write bad codeIt will slow the development at long time
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Clean code & code conventions
Facilitate code refactoring by other peopleUse good practices
Code styles and guidelinesAvoid code smells
software craftmanship manifestClean Code (Robert C. Martin)
Fuente: Clean Code. Robert Martin
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Some agile methods
VariantsScrum
Project/people managementDivide work in sprints
15' daily meetingsProduct Backlog
KanbanLean model
Just in Time DevelopmentLimit workloads
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Configuration Management
Different software versionsNew or different functionalitiesIssues and bugs managementNew execution environments
Configuration managementManage software evolutionSystem changes = team activitiesImply cost and effort
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Version control
Systems that manage different code versionsBe able to Access all the system versions
Easy to rollbackDifferences between versions
Collaborative developmentBranch managementMetadata
Author of a version, update date, who to blame, etc.
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Baseline
Baseline: Software which is the object of configuration management
Version1.0
Windows
Version1.5
Sun
Version1.5
Linux
Version2.0
Windows
Version2.5 desktop
Linux
Version2.5 desktop
Servidor
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Releases and versions
Version: instance of a system which has a different functionality to other instances
Release (deliverable): instance of a system which is distributed to external people outside to development team.It can be seen as a final product at some point
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Version naming - some conventions
Pre-alphaBefore testing
AlphaDuring testing
Beta (or prototype)Testing made by some users
Beta-tester: user that does the testingRelease-candidate
Beta version that could become final product
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Other schema namings
Using some attributesDate, creator, language, client, state,...
Recognizable Names Ganimede, Galileo, Helios, Indigo, Juno,...Precise Pangolin, Quantal Quetzal,...
Semantic Versioning (http://semver.org)MAJOR.MINOR.PATCH (2.3.5)
MAJOR: changes incompatible with previous versionsMINOR: new functionality compatible with previous versionsPATCH: Bugfix compatible with previous versions
Version 0 (inestable)Pre-releases (names added at the end): 2.3.5-alpha
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Publishing releases
A release implies functionality changesPlanning
Publishing a release has costsUsually, current users don't want new releasesExternal factors:
Marketing, clients, hardware, ...Agile model: frequent releases
Continuous integration minimizes risk
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Publishing Releases
A release is more than just softwareConfiguration filesSome needed data filesInstallation programsDocumentationPublicity and packaging
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Continuous delivery
Continuous deliveryFrequent releases to obtain feedback as soon as possible
TDD & continuous integrationDeployment pipeline
Advantages: Embrace changeMinimize integration risks
Wabi-sabi philosophyAccept imperfectionSoftware that is not finnished: Good enough
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo DevOps
Merge development and operationsCultural change where the same team participates in:
Code: Development and code review, continuous integrationBuild: Version control, building and integrationTestPackage: Artifact managementRelease: version automationConfiguration and managementMonitorization: performance, user experience
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Construction languages
Configuration languages Resource definitions (Json, XML, Turtle)
Examples: .travis.yml, package.json, pom.xmlScripting languages
Shell/batch scriptsProgramming languages
Examples: Java, Javascript,...Visual languages
Examples: scratch, blender, ...Formal
Examples: B-trees, Z language, OCL, ...
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo
Program
Coding aspectsNaming conventions
Important for other programmers, maintainers...Classes, types, variables, named constants, ...Error handlingSource code organization
Packages, folders, ...Dependencies
Libraries importedCode documentation
Javadocs, jsdoc...
Programmer
Program
Computer
Other programmers& maintainers
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Testing
Unit testingIntegration testingLoad testingRegression testing. . .Best practice:
Separate testing code and dependencies from production code
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Construction for reuse
ParameterizationAdd parameters
Common error: magical numbers in codeConfiguration/resource files
Conditional compilationEncapsulation
Separate interface from implementationCommon error: internal parts public in libraries
PackagingCommon error: manual tasks for packaging
DocumentationAPI documentation
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Construction with reuse
Selection of reusable unitsExternally developed components (COTS, FOSS)
Handling dependencies<See later>
Handling updatesWhat happens when other libraries are updated?
Legal issuesCan I really use that library?
For commercial software?Be careful with GNU libraries
Is the library well maintained?
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Construction tools
Text editorsvi, emacs, Visual Studio Code, Sublime,....
Integrated Development Environments (IDEs)Examples: IntelliJ, Eclipse
Graphical User Interface (GUI) buildersAndroid Studio UI Editor, QtEditor,...
Quality assurance (QA) toolsTest, analysis, ...<See next slide>
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Software Quality Assurance
TestsxUnit, test frameworks (mocha)Assertion languages (chai)Test coverage tools
AssertionsPre-conditions asserted on methods
Inspections & code reviewsPull requests with code reviews
Code Analysis tools<See next slide>
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Code analysis tools
Static vs dynamic code analysisWithout running the code (or at runtime)Examples: PMD, SonarCube,... (Codacy)
DebuggersInteractive vs static, Tracers & logging
ProfilersInformation about resource usage
Memory, CPU, method calls, etc.Test coverage tools
Report which lines of code have been run during testsProgram slicing
Program fragment (slice) that has been run Examples: CodeSurfer, Indus-kaveri,...
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Version control
DefinitionsRepository: where changes are
storedBaseline: Initial versionDelta: changes from one version
to otherTrunk (master): Main branch in a
systemBranch: deviation from main
branchTag: Marks a line of versions
1
Baseline
4
Trunk
2
3Branchs
5
6
9
7
T1
T2
8
10
Tags merge
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Version control
DefinitionsCheckout: Working Local copy from a
given branchCommit: Introduce current changes in
the control version system.Merge: Combine two sets of changesBranching styles: by feature, by team,
by version
1
Baseline
4
Trunk
2
3Branchs
5
6
9
7
T1
T2
8
10
Tagsmerge
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Version control
2 typesCentralized
Centralized repository for all the codeCentralized administrationCVS, Subversion, ...
DistributedEach user has its own repositoryGit, Mercurial
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Git
Designed by Linus Torvalds (Linux), 2005Goals:
Applications with large number of source code filesEfficiency
Distributed workEach development has its own repository
Local copy of all the changes historyIt is possible to do commits even without internet connection
Support for non-lineal development (branching)
More information:http://rogerdudler.github.com/git-guide/
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Local components
3 local components:Local working directoryIndex (stage area). Also called cacheProject history: Stores versions or commitsHEAD (most recent version)
ProjectHistory
Commits
commitadd
rm
HEADLocal
workingdirectory
Indexstagearea
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Remote repositories
Local workingdirectory
HistoryCommits
Indexstagearea
Remoterepositoryorigin
push
clonefetchpull
commitadd
rm
Local Machine
HEAD
Connect with remote repositoriesorigin = initial
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Branches
Git facilitates branch managementmaster = initial branch
Operations:Create branches (branch)Change branch (checkout)Combine (merge)Tag branches (tag)
1
Baseline
4
Trunk
2
3Branchs
5
6
9
7
T1
T2
8
10
Tagsmerge
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Branching patterns
Git-flowDevelop branch as mainline
Github-flowEverything in master is deployableNo hotfix branchPromotes pull-requests
Trunk-based developmentEverything in trunk (master)Short-lived feature branching
masterdevelop hotfix-1feature-1feature-2
0.1
1.0
0.2
tags
Branches
https://martinfowler.com/articles/branching-patterns.html
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Dependency management
Library: Collection of functionalities used by the system that is being developedSystem depends on that library
Library can depend on other librariesLibrary can evolve
Incompatible versions appearDependency graph
Mozilla Firefox dependency graphSource: The purely functional deployment model. E. Dolstra (PhdThesis, 2006)
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Dependency graph
Graph G = (V,E) whereV = Vertex (components/packages)E = Edges (u,v) that indicate that u depends on v
CCD metric (cumulative component dependency)
Sum of every component dependencyEach component depends on itself
A
B C
D E G
In the example:CCD=7+3+4+1+1+1+1=18
F
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Cyclic dependencies problem
The dependency graph should not have cyclesAdding a cycle can damage CCD
Example:
CCD = 7+7+7+1+7+1+1=31
A
B C
D E GF
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Dependency management
Different modelsLocal installation: libraries are installed for all the system
Example: Ruby GemsEmbed external libraries in the system (version control)
Ensures a correct versionExternal link
External repository that contains the librariesDepends on Internet and on library evolution
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Build automation
Tools that automate building and deploymentOrganize different tasks
Compile, package, install, deploy, etc.Dependencies between tasksMust check:
Run all prerequisitesRun them once
Initialize
Prepare Testdata
CompileSource
code
CompileTestcode
Runtests
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Build automation
Automate building tasksSome quality attributes:
Correctness: Avoid mistakes (minimize "bad builds")Eliminate repetitive and redundant tasks
Simplicity: Handle complexityAutomation & releasability
Have history of builds and releasesContinuous integration
CostSave time & money
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo When to build?
On-demandA user running a script at the command line
ScheduledAutomatically run at certain hoursContinuous integration serverExample: nightly builds
TriggeredAt every commit to a version control systemContinuous integration server linked to version
control system
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Build Automation Tools
Makefile (C world)Ant (Java)Maven (Java)SBT (Scala, JVM languages)Gradle (Groovy, JVM languages)rake (Ruby)npm, grunt, gulp (Javascript)etc.
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Automate building
make: Included in UnixProduct orientedDeclarative language based on rules
When the Project is complex, configuration files can be difficult to manage/debug
Several versions: BSD, GNU, MicrosoftVery popular in C, C++, etc.
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Automate building
ant: Java PlatformTask orientedXML syntax (build.xml)
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Automate building
maven: Java PlatformConvention over configurationManage project lifecycleDependency managementXML syntax (pom.xml)
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Automate building
Embedded languagesDomain specific languages embedded in higher level
onesGreat versatilityExamples: gradle (Groovy)sbt (Scala)rake (Ruby)Buildr (Ruby)gulp (Javascript)…
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo New tools
Pants (Foursquare, twitter)https://pantsbuild.github.io/
Bazel (Google)http://bazel.io/
Buck (Facebook)https://buckbuild.com/
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Maven
Build automation toolDescribes how software is builtDescribes software dependenciesPrinciple: Convention over configuration
Jason van ZylCreator of Maven
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Maven
Typical development phases:clean, compile, build, test, package, install, deploy
Module identification3 coordinates: Group, Artifact, VersionDependencies between modules
Configuration: XML file (Project Object Model)pom.xml
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Maven
Artifact repositoriesStore different types of artifacts
JAR, EAR, WAR, ZIP, plugins, etc.Every interaction is made through the repository
No relative pathsShare modules between development teams
Local ArtifactRepository
RemoteArtifact
Repository
<user>/.m2/repository Maven Central
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Maven Central
Public repository of projectsOver 1 mill GAV≈ 3000 new projects each month (GA)≈ 30000 new versions each month(GAV)*
http://search.maven.org/
* Source: http://takari.github.io/javaone2015/still-rocking-it-maven.html
Other repositories:https://bintray.com/
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo POM - Project Object Model
XML syntaxDescribes a project
Name and versionArtifact type (jar, pom, ...)Source code localizationsDependenciesPluginsProfiles
Alternative build configurationsInheritance structureReference: https://maven.apache.org/pom.html
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo POM - Project Object Model
Inheritance structureSuper POM
Maven's default POMAll POMs extend the Super POM unless explicitly said
parentDeclares the parent POMDependencies and properties are combined
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Maven
Project identificationGAV (Group, Artifact, Version)
Group: grouping identifierArtifact: Project nameVersion: Format {Major}.{Minor}.{Maintenance}
It is possible to add "-SNAPSHOT" (in development)<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>es.uniovi.asw</groupId><artifactId>censusesN</artifactId><version>0.0.1</version><name>censusesN</name>...
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Maven
Folder structureMaven uses a conventional structure
src/mainsrc/main/javasrc/main/webappsrc/main/resourcessrc/test/src/test/javasrc/test/resources. . .
Output directory: target
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Maven Build life cycle
3 built-in lifecyclesdefault
Project deploymentclean
Project cleaningsite
Project's site documentationEach life cycle has some specific phases
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo clean
Clean compiled code and other stuff3 phases
pre-cleancleanpost-clean
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo default lifecycle
Compilation, testing and deployingSome phases validate
initializegenerate-sourcesgenerate-resourcescompiletest-compiletestpackageintegration-testverifyinstalldeploy
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo site lifecycle
Generates Project's site documentationPhases
pre-sitesitepost-sitesite-deploy
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Maven
Automatic dependency managementGAV identificationScopescompile testprovide
Typejar, pom, war,...
...<dependency><groupId>commons-cli</groupId><artifactId>commons-cli</artifactId><version>1.3</version></dependency>...
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Maven
Automatic dependency managementDependencies are downloadedStored in a local repositoryWe can create intermediate repositories (proxies)
Examples: common artifacts for some companyTransitivity
A depends on B B depends on C⇒ If a system depends on A
Both B and C are downloaded
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Maven modules: aggregation
Big projects can be decomposed in subprojectsEach Project creates one artifact
Contains its own pom.xmlParent Project groups modules
<project>...<packaging>pom</packaging><modules>
<module>extract</module><module>game</module>
</modules></project>
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Maven Plugins
Maven architecture based on plugins2 types of plugins
buildreporting
List of plugins: https://maven.apache.org/plugins/index.html
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo Maven
Other phases and pluginsarchetype:generate - Generates Project archetypeeclipse:eclipse - Generates eclipse projectsite - Generates Project web sitesite:run - Generates Project web site and starts serverjavadoc:javadoc - Generates documentationcobertura:cobertura - Reports code executed during testscheckstyle:checkstyle - Check coding stylespring-boot:run - Run a spring application
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo npm
Node.js package managerInitially create by Isaac Schlueter
Later became Npm inc.Default package manager for NodeJs
Manages dependenciesAllows scripts for common tasks
Software registryPublic or paid packages
Configuration file: package.json
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo npm configuration: package.json
Configuration file: package.jsonnpm init creates a simple skeleton
Fields: {"name": "...mandatory...","version": "...mandatory...","description": "...optional...","keywords": "...","repository": {... },"author": "...","license": "...","bugs": {...},"homepage": "http://. . .","main": "index.js","devDependencies": { ... },"dependencies": { ... }"scripts": { "test": " ... " },"bin": {...},
}
Note: Yeoman provides fully featured scaffolding
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo npm packages
Repository: http://npmjs.orgInstalling packages:
2 options:Localnpm install <packageName> --save (--save-dev)
Globalnpm install -g <packageName>
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo npm dependencies
Dependency managementLocal packages are cached at node_modules folderAccess to modules through: require('...')
Global packages (installed with --global option)Cached at: ~/.npm folder
Scoped packages marked by @
Software ArchitectureS
choo
lof C
omp
ute
rS
cien
ceU
niv
ersi
tyof
Ovi
edo npm commands and scripts
Npm contains lots of commandsstart ≈ node server.jstest ≈ node server.jsls lists installed packages...
Custom scripts: run-script <name>
More complex tasks in NodeJsGulp, Grunt
https://docs.npmjs.com/cli-documentation/