On
Software Engineering

SOFTWARE
Engineering

  • The obvious stuff
    • Maintainability
    • Building
    • Developer Workstation
  • Interrupt anytime

Version Control

Version Control

  • always
  • no generated assets
  • app should be valid after every commit
    • must build
    • should be able to start
  • small commits
  • meaningful commit messages
  • diff friendly formats (eg. Markdown)
5ba3db6 Fix failing CompositePropertySourceTests
84564a0 Rework @PropertySource early parsing logic
e142fd1 Add tests for ImportSelector meta-data
887815f Update docbook dependency and generate epub
ac8326d Polish mockito usage

Do

the

Diff

Building

+

Building

mvn clean verify

DEV ➠ UAT ➠ PROD

 v.1.5-37-g2dfbd8d

GENERATE

.gitignore

dev env

README.md
<project xmlns="http://maven.apache.org/POM/4.0.0">
  <!--...-->
  <profiles>
    <profile>

      <id>dev</id>

      <activation>
        <property>
          <name>!env.BUILD_NUMBER</name>  <!-- deactivate on Jenkins -->
        </property>
      </activation>

      <properties>
        <run.profiles>dev</run.profiles>
        <skipFrontend>true</skipFrontend>
        <skipTests>true</skipTests>
        <env.BUILD_NUMBER>dev</env.BUILD_NUMBER>
      </properties>

      <dependencies>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-devtools</artifactId>
        </dependency>
      </dependencies>
$ mvn spring-boot:run   # will run in dev
$ mvn package -P-dev    # disable dev profile

continuous integration

  • Purpose:
    • everything is commited
    • no uncommited files
      end up in the build
  • repeatable builds

CONTINUOUS INTEGRATION

IS free

  • Free build minutes on
    • gitlab.com
    • bitbucket.com
  • Including private repos

The source code is the ultimate truth,
the best and most definitive and
up-to-date documentation you're likely to find

Jeff Atwood

Who to you write the code for?

Target audience

  • Your fellow programmer
  • Future you

 

Optimize for readability first

Valentin Simonov

blogger

The Only Constant Is Change

 

Herakleitos;

c. 535 BC - 475 BC

Keep It Simple Stupid (KISS)

 

Kelly Johnson

Lockheed, 1960

/* COMMENTS */

BAD Comments

// convert float to string
String value = String.valueOf(price);    


/** Always returns true */
public boolean isAvialable() {
    return false;
}


// Author: Krzysiek Rzymkowski (28-11-2017)

GOOD Comments

/**
 * WebLogic workaround: the server does not set the proper 
 * content type headers on these files.
 * Note: content type is set for all url that match 
 * the pattern - even when the response is 404 not found.
 */
addMimeMapping(servletContext, "svg", "image/svg+xml;charset=utf-8");


return '\u221e'; // u221e = ∞ (infinity)


if (_.isEmpty(this.state.value)) {
    // https://github.com/facebook/react/issues/1549
    // chrome tries to omit change of value in input when value is null
    (this.refs.input as any).value = '';
}

Documentation

Developer docs

  • README.md

Markdown

  • VCS friendly
  • viewable everywhere

Testing

  • Infrastructure
    • easy to write and run tests
    • fast - should be run often
  • Start small
    • util functions
    • new non-trivial code

The pleasure of having a tested codebase

TESTING

  • dev friendly
    • easy to run single test
    • from IDE
  • CI friendly
    • run all tests with one command
    • reports

Why bother?

Painless OWNERSHIP TRANSFER

Imagine

  • Taking over a project that:
    • does not compile
    • does not build
    • does not start 
  • Introducing new person

Pleasure of Development

On Software Engeneering

By Krzysztof Rzymkowski