Boaz Berman
Developer
3.5 years in Shavit
Dominates the market.
Fast, lightweight, has wide indestry support.
Repository, Branch, Commit
git reset --soft HEAD~3
git commit -m "New message for the combined commit"
git push --force
Merge vs Rebase
Git Workflow
Short Lived Feature Branches
Trunk Based Development
origin
local
(Go) Migrate
mongodb-migrations
Add column, n versions later remove old column.
Single Responsibility
Open/Closed Principle
Liskov Substitution
Interface Segregation
Dependency Inversion
function reticulateSplines(){
// current implementation lives here
}
function reticulateSplines(){
var useNewAlgorithm = false;
// useNewAlgorithm = true; // UNCOMMENT IF YOU ARE WORKING
// ON THE NEW SR ALGORITHM
if( useNewAlgorithm ){
return enhancedSplineReticulation();
}else{
return oldFashionedSplineReticulation();
}
}
function oldFashionedSplineReticulation(){
// current implementation lives here
}
function enhancedSplineReticulation(){
// TODO: implement better SR algorithm
}
Push state to the boundaries (Databases)
Server must sustain:
Each session is carried out as if it was the first time and responses are not dependent upon data from a previous session.
public class GoogleSearch {
static WebDriver driver = new FirefoxDriver();
static Wait<WebDriver> wait = new WebDriverWait(driver, MAX_30_SECONDS);
public static void main(String[] args) {
boolean result;
driver.get("http://www.google.com/");
try {
result = firstPageContainsQAANet();
} catch(Exception e) {
result = false;
} finally {
driver.close();
}
System.out.println("Test " + (result? "passed." : "failed."));
}
private static boolean firstPageContainsQAANet() {
//type search query
driver.findElement(By.name("q")).sendKeys("qa automation\n");
// click search
driver.findElement(By.name("btnG")).click();
// Wait for search to complete
wait.until(webDriver -> {
System.out.println("Searching ...");
return webDriver.findElement(By.id("resultStats")) != null;
});
// Look for QAAutomation.net in the results
return driver.findElement(By.tagName("body")).getText().contains("qaautomation.net");
}
}
@Test
public class SomeKeyGoogleService {
public SearchServiceConnection searchService;
@Before
public void init() {
// Initialize service
searchService = ...;
}
@After
public void clean() {
// Do some cleaning
}
@Describe("Given Youtube service has results and there are existing indexed pages " +
"When a phrase searched Then return Youtube with indexed results")
public void usuallyThisWillBeAMeaningfullName() {
// given
youtubeMock.when("/searchResults?search=my%20search%20phrase")
.thenReturn("{video: \"http://youtube.com/v?asd123@!ASd2134=\"}");
db.insert(new IndexedPage("Welcome to my search phrase"));
// when
var returnContent = searchService.call("/search?s=my%20search%20phrase").result().asJson();
// then
expect(returnContent).toConsistOf(youtubeVideo("http://youtube.com/v?asd123@!ASd2134="),
pageInfo("Welcome to my search phrase"));
}
}
public class AlertAdderTest
{
public SlackAlertAdder slackAlertAdder = mock(SlackAlertAdder.class);
public FacebookAlertAdder facebookAlertAdder = mock(FacebookAlertAdder.class);
public AlertAdder alertAdder = new AlertAdder(slackAlertAdder, facebookAlertAdder);
@Test
public void whatAnAlertIsAddedThenSlackAlertIsAdded()
{
Alert anAlert = new Info("Holy shit, watch out");
alertAdder.add(anAlert);
verify(slackAlertAdder).add(anAlert);
}
}
Logs are the stream of aggregated, time-ordered events collected from the output streams of all running services
Produce -> Collect -> Index -> Use
Service-wise
Fluentd/ Logstash
Elasticsearch
Kibana
12Factor: Logs
Also: Correlation Ids, Schema
Using correlation Ids we can create a flow of the data:
Counter counter = Counter
.builder("instance")
.description("indicates instance count of the object")
.tags("dev", "performance")
.register(registry);
counter.increment(2.0);
assertTrue(counter.count() == 2);
counter.increment(-1);
assertTrue(counter.count() == 2);
SimpleMeterRegistry registry = new SimpleMeterRegistry();
Timer timer = registry.timer("app.event");
timer.record(() -> {
try {
TimeUnit.MILLISECONDS.sleep(1500);
} catch (InterruptedException ignored) { }
});
timer.record(3000, MILLISECONDS);
assertTrue(2 == timer.count());
assertTrue(4510 > timer.totalTime(MILLISECONDS)
&& 4500 <= timer.totalTime(MILLISECONDS));
A Key Performance Indicator (KPI) is a measurable value that demonstrates how effectively a company is achieving key business objectives.
Business Metrics are used to track all areas of business.
Mean time to failure (MTTF) is the length of time a device or other product is expected to last in operation. MTTF is one of many ways to evaluate the reliability of pieces of hardware or other technology.
Mean Time to Repair (MTTR) is a measure of how long it takes to get a product or subsystem up and running after a failure.
Practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.
Designed to ensure that code can be deployed to production by delivering every change to a production-like environment and ensuring business applications and services function as expected.
Every change that passes the automated tests is deployed to production automatically.
pipeline {
agent any
tools {
maven 'Maven 3.3.9'
jdk 'jdk8'
}
stages {
stage ('Initialize') {
steps {
sh '''
echo "PATH = ${PATH}"
echo "M2_HOME = ${M2_HOME}"
'''
}
}
stage ('Build') {
steps {
sh 'mvn -Dmaven.test.failure.ignore=true install'
}
post {
success {
junit 'target/surefire-reports/**/*.xml'
}
}
}
}
}
version: 2
jobs:
build:
docker:
- image: circleci/<language>:<version TAG>
steps:
- checkout
- run: echo "hello world"
deploy:
docker:
- image: java:8-jre-alpine
steps:
- run: java -jar my-app-*.jar
A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Available for both Linux and Windows based apps, containerized software will always run the same, regardless of the environment. Containers isolate software from its surroundings, for example differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure.
FROM alpine/git
WORKDIR /app
RUN git clone https://github.com/spring-projects/spring-petclinic.git
FROM maven:3.5-jdk-8-alpine
WORKDIR /app
COPY --from=0 /app/spring-petclinic /app
RUN mvn install
FROM openjdk:8-jre-alpine
WORKDIR /app
COPY --from=1 /app/target/spring-petclinic-1.5.1.jar /app
CMD ["java -jar spring-petclinic-1.5.1.jar"]
Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.
An approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deploy-able by fully automated deployment machinery.
Separate database per service
Collaborate on api with consumers
Past & Future compatible api (Objects)
Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization's communication structure.
-- Melvyn Conway, 1967
Is about designing software based on models of the underlying domain. A model acts as a Ubiquitous Language to help communication between software developers and domain experts. It also acts as the conceptual foundation for the design of the software itself - how it's broken down into objects or functions. To be effective, a model needs to be unified - that is to be internally consistent so that there are no contradictions within it.
Value objects, which represent a value that might have sub-parts (for example, a date may have a day, month and year)
Entities, which are objects with identity. For example, each Customer object has its own identity, so we know that two customers with the same name are not the same customer
Aggregate roots are objects that own other objects. This is a complex concept and works on the basis that there are some objects that don't make sense unless they have an owner.
Code - code development and review, source code management tools, code merging
Build - continuous integration tools, build status
Test - continuous testing tools that provide feedback on business risks
Package - artifact repository, application pre-deployment staging
Release - change management, release approvals, release automation
Configure - infrastructure configuration and management, Infrastructure as Code tools
Monitor - applications performance monitoring, end–user experience
DevOps aims at shorter development cycles, increased deployment frequency, more dependable releases, in close alignment with business objectives.
shifted the focus from individual machines and their utilization, to the flow of the product through the total process. Toyota concluded that by right-sizing machines for the actual volume needed, introducing self-monitoring machines to ensure quality, lining the machines up in process sequence, pioneering quick setups so each machine could make small volumes of many part numbers, and having each process step notify the previous step of its current needs for materials, it would be possible to obtain low cost, high variety, high quality, and very rapid throughput times to respond to changing customer desires.
Unnecessary code or functionality
Starting more than can be completed
Delay in the software development process: Delays time to customer, slows down feedback loops
Unclear or constantly changing requirements
Bureaucracy
Slow or ineffective communication
Partially done work
Defects and quality issues
Task switching
Pair programming: Avoid quality issues by combining the skills and experience of two developers instead of one
Test-driven development: Writing criteria for code before writing the code to ensure it meets business requirements
Incremental development and constant feedback
Minimize wait states: Reduce context switching, knowledge gaps, and lack of focus
Automation: Automate any tedious, manual process or any process prone to human error
Pair Programming
Code reviews
Documentation
Wiki – to let the knowledge base build up incrementally
Thoroughly commented code
Knowledge sharing sessions
Training
Use tools to manage requirements or user stories
This Lean principle encourages team to demonstrate responsibility by keeping their options open and continuously collecting information, rather than making decisions without the necessary data.
Build a simple solution, put it in front of customers, enhance incrementally based on customer feedback.
Common culprits