Capstone C++ Workflows
Release Score
A capstone workflow can combine several measurements into one release signal.
scoring
A scoring helper keeps the release rule in one place while main prepares the inputs.
readiness
The final boolean is easier to inspect than repeating the score threshold everywhere.
Release Score
release_score.cpp
Replay: real traced execution (multi-file project)
#include <iostream>
struct ReleaseStats {
int tests;
int warnings;
int blockers;
};
int scoreRelease(const ReleaseStats& stats) {
return stats.tests * 10 - stats.warnings * 2 - stats.blockers * 25;
}
int main() {
int warnings = 3;
ReleaseStats stats{12, warnings, 1};
int score = scoreRelease(stats);
bool ready = score >= 80;
std::cout << "warnings=" << warnings << std::endl;
std::cout << "score=" << score << std::endl;
std::cout << "ready=" << ready << std::endl;
return 0;
}
#include <iostream>
struct ReleaseStats {
int tests;
int warnings;
int blockers;
};
int scoreRelease(const ReleaseStats& stats) {
return stats.tests * 10 - stats.warnings * 2 - stats.blockers * 25;
}
int main() {
int warnings = 0;
ReleaseStats stats{12, warnings, 1};
int score = scoreRelease(stats);
bool ready = score >= 80;
std::cout << "warnings=" << warnings << std::endl;
std::cout << "score=" << score << std::endl;
std::cout << "ready=" << ready << std::endl;
return 0;
}
#include <iostream>
struct ReleaseStats {
int tests;
int warnings;
int blockers;
};
int scoreRelease(const ReleaseStats& stats) {
return stats.tests * 10 - stats.warnings * 2 - stats.blockers * 25;
}
int main() {
int warnings = 8;
ReleaseStats stats{12, warnings, 1};
int score = scoreRelease(stats);
bool ready = score >= 80;
std::cout << "warnings=" << warnings << std::endl;
std::cout << "score=" << score << std::endl;
std::cout << "ready=" << ready << std::endl;
return 0;
}
warnings ← 3, stats ← (empty)
13int main() {14 int warnings→ 3 = 3; //@warnings=0, 81516 ReleaseStats stats→ (empty){12, warnings3, 1};17 int score = scoreRelease(stats(empty));18 bool ready = score >= 80;int scoreRelease(const ReleaseStats& stats)
9int scoreRelease(const ReleaseStats& stats(empty)) {10 return stats.tests12 * 10 - stats.warnings3 * 2 - stats.blockers1 * 25;11}score ← 89, ready ← 1
16 ReleaseStats stats{12, warnings, 1};17 int score→ 89 = scoreRelease(stats(empty));18 bool ready→ 1 = score89 >= 80;1920 std::cout << "warnings=" << warnings3 << std::endl;21 std::cout << "score=" << score89 << std::endl;22 std::cout << "ready=" << ready1 << std::endl;23 return 0;24}outputwarnings=3 score=89 ready=1
warnings ← 0, stats ← (empty)
13int main() {14 int warnings→ 0 = 0;1516 ReleaseStats stats→ (empty){12, warnings0, 1};17 int score = scoreRelease(stats(empty));18 bool ready = score >= 80;int scoreRelease(const ReleaseStats& stats)
9int scoreRelease(const ReleaseStats& stats(empty)) {10 return stats.tests12 * 10 - stats.warnings0 * 2 - stats.blockers1 * 25;11}score ← 95, ready ← 1
16 ReleaseStats stats{12, warnings, 1};17 int score→ 95 = scoreRelease(stats(empty));18 bool ready→ 1 = score95 >= 80;1920 std::cout << "warnings=" << warnings0 << std::endl;21 std::cout << "score=" << score95 << std::endl;22 std::cout << "ready=" << ready1 << std::endl;23 return 0;24}outputwarnings=0 score=95 ready=1
warnings ← 8, stats ← (empty)
13int main() {14 int warnings→ 8 = 8;1516 ReleaseStats stats→ (empty){12, warnings8, 1};17 int score = scoreRelease(stats(empty));18 bool ready = score >= 80;int scoreRelease(const ReleaseStats& stats)
9int scoreRelease(const ReleaseStats& stats(empty)) {10 return stats.tests12 * 10 - stats.warnings8 * 2 - stats.blockers1 * 25;11}score ← 79, ready ← 0
16 ReleaseStats stats{12, warnings, 1};17 int score→ 79 = scoreRelease(stats(empty));18 bool ready→ 0 = score79 >= 80;1920 std::cout << "warnings=" << warnings8 << std::endl;21 std::cout << "score=" << score79 << std::endl;22 std::cout << "ready=" << ready0 << std::endl;23 return 0;24}outputwarnings=8 score=79 ready=0