Dial M for Maintainability

Part I

Let's get acquainted!

Let's get acquainted!

First Name: Azat
Last Name: Davliatshin
Experience: 9 years in JS development
Life Science & Healthcare
Expertise: FE, BE, Clouds, Mobile, Legacy
Criminal Records: Had to force push changes into production branch

Agenda

Agenda

  • The task definition
  • Straightforward solution: pros and cons
  • Maintainability <- QA <- ASR
  • Maintainability Tactics
  • Design
  • Tools

The task definition

Straightforward solution

import { json2csv } from 'json-2-csv';
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";

const urlAPI = "...";
const tokenAPI = "...";
const options = {
	headers: '' // use tokenAPI
};

const fetchResponse = await fetch(urlAPI, options);
const data = fetchResponse.json();

const csv = await converter.json2csv(data);

const client = new S3Client({});
const command = new PutObjectCommand({});
await client.send(command);
							
import { json2csv } from 'json-2-csv';
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";

const urlAPI = "...";
const tokenAPI = "...";
const options = {
	headers: '' // use tokenAPI
};

const fetchResponse = await fetch(urlAPI, options);
const data = fetchResponse.json();

const csv = await converter.json2csv(data);

const client = new S3Client({});
const command = new PutObjectCommand({});
await client.send(command);
							
import { json2csv } from 'json-2-csv';
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";

const urlAPI = "...";
const tokenAPI = "...";
const options = {
	headers: '' // use tokenAPI
};

const fetchResponse = await fetch(urlAPI, options);
const data = fetchResponse.json();

const csv = await converter.json2csv(data);

const client = new S3Client({});
const command = new PutObjectCommand({});
await client.send(command);
							

PROS

  • Quick
  • Simple
  • Plain

CONS

  • Change request is time consuming
  • Code duplication
  • Poor error handling

Change request is time consuming

							import { json2csv } from 'json-2-csv';
...
// This package is deprecated, it should be replaced
const csv = await converter.json2csv(data);
...

						

Code duplication

Additional functionality request: launch task manually from UI, there are options for storages

Poor errors handling

							try {
...
}
catch (exception) {
	//TODO: try to understand what exactly throws this exception
}

						

Solution is not maintainable

Maintainability

ASR

Architecturally significant requirements

Click here to watch short video about ASR

ASR

QA

Quality attributes

QA

A QUALITY ATTIRBUTE (QA) is a measurable or testable property of a system that is used to indicate how well the system satisfies the needs of its stakeholders

QA

  • Performance
  • Security
  • Scalability
  • Availability
  • Reliability
  • Usability
  • Maintainability
  • ...
Click here to read ISO standard

Maintainability

(Modifiability)

Maintainability

QA deals with change and the cost in time or money of making a change, including the extent to which this modification affects other functions or quality attributes.

Maintainability Tactics

Maintainability Tactics

Software Architecture in Practice (SEI Series in Software Engineering)

Defer Binding

							//no magic values! ❌ 🧙 🔤
const urlAPI = "...";
const tokenAPI = "...";

// much better :) ✅ 
const urlAPI = process.env.managementToolApiUrl;
const tokenAPI = process.env.token;

Split the code

							// API
const fetchResponse = await fetch(urlAPI, options);
const data = fetchResponse.json();

// Converter
const csv = await converter.json2csv(data);

// Storage
const client = new S3Client({});
const command = new PutObjectCommand({});
await client.send(command);

Cohesion & Coupling

Click here to read of Cohesion & Coupling

Design

Design Principles

  • SOLID
  • IoC

Patterns, Techniques

  • DI

"Tools"

Development Guidelines

Static code analysis

  • ESLint
  • Prettier
  • SonarQube
  • ...
  • Typescript*
Добавление TypeScript в легаси проекты, Спикер: Александр Канунников

Tests

Tests

Click here to get article on the Maintainability topic from SEI

Рәхмәт!

To be continued

Presentation

Telegram

LinkedIn