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;
},
async exec(route, params){
const handler = this.handlers[route];
// web framework
function webapp() {
return {
handlers: {},
addRoute(route, fn){
this.handlers[route] = fn;
},
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");
}
//mock api
var api = {
list_cameras: _mockpromise(list_cameras),
//other methods…
};
function list_cameras(filters){
return [
{name: ‘Camera do BBB’},
{name: ‘Camera 17’}
];
//real api
var api = {
list_cameras: list_cameras,
//other methods…
};
function list_cameras(filters){
return AppAjax.get(‘/api/list_cameras’, {filters: angular.toJson(filters)});
}
@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,
@tonylampada
tonylampada / spiv suggestions on iirc
Created September 12, 2012 05:41
spivs suggestions on iirc
[02:01] == tonylampada [bb026e64@gateway/web/freenode/ip.187.2.110.100] has joined #twisted
[02:01] <tonylampada> Oh boy, do people still use Trac??
[02:04] == Jayrays [~jayrays@unaffiliated/jayrays] has quit [Read error: Connection timed out]
[02:04] <tonylampada> ok, Trac works too :-)
[02:04] <tonylampada> I've made this website for open source projects crowdfunding - http://www.freedomsponsors.org/. Please have a look at it.
[02:04] <tonylampada> Right now I'm trying to get it know by as many developers as I can, so, if you like it, please help spread the word
[02:04] <tonylampada> I think it has a great potential to help free software projects, specially popular ones like twisted
[02:05] == Jayrays [~jayrays@unaffiliated/jayrays] has joined #twisted
[02:06] <spiv> tonylampada: well, good luck, but I haven't seen any other bounty system come even vaguely close to working
[02:07] <spiv> tonylampada: and even though at a glance yours looks like an decent effort I can't see that it's sufficiently brilliant t