Skip to content

Instantly share code, notes, and snippets.

View tonylampada's full-sized avatar

Tony Lâmpada tonylampada

View GitHub Profile

Plumbing + Intelligence: A Practical Mindset for Software Architecture

1. Introduction

As I gained experience in building software, I realized a fundamental distinction between two types of code, which in my mind, I refer to as:

  • "plumbing" code, vs
  • "intelligence" code.

I want to explain this duality because I believe it assists in cultivating a programming mindset that tends to produce quality software (*).

Encanamento + Inteligência: um mindset prático para arquitetura de software

1. Introdução

À medida que eu fui ganhando experiência construindo software, percebi uma distinção fundamental entre dois tipos código, que, na minha cabeça, eu chamo de:

  • código de "encanamento", vs
  • código de "inteligência".

Vou explicar essa dualidade porque eu acredito que ela ajuda ter um mindset de programação que tende a gerar software de qualidade (*).

//////////////////////////////////////////////////////////////////////
// surface: handling http requests for login
// "app" is an express application
// "authenticationService" is a service that knows how to authenticate users
app.use(loggingMiddleware);
app.use(handleUnknownErrorsMiddleware);
app.post('/api/login', reqLogin);
function loggingMiddleware(req, res, next) {
// web framework
function webapp() {
return {
handlers: {},
addRoute(route, fn){
this.handlers[route] = fn;
},
exec(route, params){
const handler = this.handlers[route];
// web framework
function webapp() {
return {
handlers: {},
addRoute(route, fn){
this.handlers[route] = fn;
},
async exec(route, params){
const handler = this.handlers[route];
const express = require("express");
const request = require("supertest");
async function sleep(ms) {
return new Promise((r) => setTimeout(r, ms));
}
function _500errosync(req, res) {
throw new Error("Test error");
}
//real api
var api = {
list_cameras: list_cameras,
//other methods…
};
function list_cameras(filters){
return AppAjax.get(‘/api/list_cameras’, {filters: angular.toJson(filters)});
}
//mock api
var api = {
list_cameras: _mockpromise(list_cameras),
//other methods…
};
function list_cameras(filters){
return [
{name: ‘Camera do BBB’},
{name: ‘Camera 17’}
];
@tonylampada
tonylampada / racing.py
Created May 23, 2014 10:28
How to solve racing conditions in python using shared memory
import time
from threading import Thread
import random
d1 = {}
def run(n):
for i in range(3):
c = d1['c']
print('Thread %s read c=%s' % (n, c))
@tonylampada
tonylampada / paypal_portuguese.py
Created December 15, 2012 19:32
Paypal in portuguese
from django.conf import settings
from paypalx import AdaptivePayments
from urllib import urlencode
from urllib2 import urlopen, Request
import logging
paypal = AdaptivePayments(settings.PAYPAL_API_USERNAME,
settings.PAYPAL_API_PASSWORD,
settings.PAYPAL_API_SIGNATURE,
settings.PAYPAL_API_APPLICATION_ID,