Know when software complexity arises and how to handle it

ruins of a stone building overlooking a bay
ruins of a stone building overlooking a bay
Photo by Flo P on Unsplash

Why Is Code Complexity an Important and Serious Topic?

If it’s complex, it’s incomprehensible. If it’s incomprehensible, it’s unexplainable. If we can’t understand and explain the code, we can’t extend or change it. …


A visual introduction to functional programming

Building photographed from a sideways angle
Building photographed from a sideways angle
Photo by Jackson Jost on Unsplash.

What’s Functional Programming?

Functional programming is a pipeline of pure functions.

What does that mean?

To understand this definition, we will use a real-life example. Let’s assume that we have a shipping warehouse and a large store containing a variety of products (books, clothes, certain canned food products, household appliances, etc.).

How do things work inside our warehouse?


What is modularity, and what metrics are available to measure modularity?

Diagram showing dependence on outside or external coupling.
Diagram showing dependence on outside or external coupling.
Dependence on outside or external coupling. Image by the author.

Introduction

In this article, I’ll talk about modularity: What is modularity? Why is it important? And how can we measure modularity?

Modularity consists of dividing a system into separate and independent parts called groups or modules.


Design and code for the future

Introduction

A day in the life of developers

Developers diaries. Image by the author.

Testimonials from code reviewers


What we will do ?

Project

We will try to make an Online Bookstore.

Possible use cases

  • get all books
  • get a book details
  • get all categories
  • get all authors
  • get books by category
  • get books by author
  • search a book by its name or author
  • add a review : comment and rating
  • update a review : comment and rating
  • user can order one or many books

Constraints

  • a book can have only one author
  • a book can be associated only one category
  • a book can have zero to many reviews
  • an order can contains the same book only once time but with quantity from one to max
  • user can…


In this story, we will see together the different aspects of Elixir Pattern Matching: tuples, list, map and multiclause function.

Image taken from : http://ravindranaik.com/pattern-matching-in-c-8/

Tuples

Let’s assume that we have a function that return the gps coordinates (latitude, longitude) for a given country : get_gps_coordinates.

defmodule ElixirPatternMatching.Examples do
def get_gps_coordinates(country) do
%{
France: {46.71109, 1.7191036},
Spain: {40.2085, -3.713},
Italy: {41.29246, 12.5736108}
}[country]
end
end

Let’s call this function to get the gps coordinates for ‘France’ :

defmodule ElixirPatternMatching do
import ElixirPatternMatching.Examples,
only: [get_gps_coordinates: 1]


{latitude, longitude} = get_gps_coordinates(:France)

IO.inspect("latitude : #{latitude}")
IO.inspect("longitude : #{longitude}")
end


WASM (WebAssembly) or not in frontend projects ?

What I want to do ?

I’m trying to find approach to enhance the performance of my frontend projects.

My frontend projects are mostly websites for many and different purposes.

I have always complex logic to do like filtering and transforming big backend response in frontend side. Sometimes I must use the generic Rest response and I can’t use graphql nor adding a BFF.

I add these complexities :

  • supporting multiple browsers.
  • 3G, 4G, …
  • responsiveness and good user experience.

Some technics that I…


What we will do ?

In this story, we will see together how to make a Rust Rest API using :

  • mongo db driver to dialog with mongo database.
  • postman to test our endpoints.
Technical staff

Project configuration

Create & init new project

cargo new rust-rest-api
cd rust-rest-api
cargo init

Project structure


React JS, Apollo Graphql Client

Last time we had seen together how to do a Nodejs graphql server using Apollo :

We continue our trip inside graphql and this time we will focus on client.

We will use :

  • Apollo Graphql Client (hooks version)
  • ant design to have beautiful UI
React — Apollo Graphql Client

Project init

Create project

npx create-react-app react-graphql-clientnpm install apollo-boost @apollo/react-hooks graphqlnpm install antd

index.js

import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import * as serviceWorker from './serviceWorker'; import './index.css'; import 'antd/dist/antd.css'; ReactDOM.render( <React.StrictMode> <App /> </React.StrictMode>, document.getElementById('root') ); // If you want your app to work…


NodeJS, Apollo Graphql Server, Mongoose, Mongo DB

Project setup

Init project

mkdir node-graphql-apicd node-graphql-apinpm init --yesnpm install mongoosenpm install apollo-server graphqlnpm install nodemon dotenv @babel/core @babel/node @babel/plugin-transform-async-to-generator @babel/plugin-transform-runtime @babel/preset-env --save-dev

package.json

"start": "nodemon --exec babel-node index.js",

Babel Config

touch babel.config.js
module.exports = function (api) {
api.cache(true);

const presets = [
"@babel/preset-env"
];
const plugins = [
"@babel/plugin-transform-async-to-generator",
"@babel/plugin-transform-regenerator",
["@babel/plugin-transform-runtime", {
"helpers": true,
"regenerator": true
}]
];
return {
presets,
plugins
};
}

dotenv (.env)

touch .env
DEFAULT_LANGUAGE = en
GRAPHQL_APP_PORT = 5000
GRAPHQL_APP_PATH = /graphql

MONGOOSE_DB_HOST = 127.0.0.1
MONGOOSE_DB_PORT = 27017
MONGOOSE_DB_NAME = local

index.js

touch index.js
//dot env configuration…

Héla Ben Khalfallah

I love coding whatever the language and trying new programming tendencies. I have a special love to JS (ES6+), functional programming, clean code & tech-books.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store