Christopher R. Bilger
October 15th, 2025
But they can't judge whether code is understandable or maintainable.
This code passes all linting checks:
function processUserData(u: any) {
if (u.s === 'active') {
if (u.r === 'admin') {
if (u.p && u.p.length > 0) {
...
}
}
}
return { access: 'limited', features: ['dashboard'] };
}
✅ Spell-checker: No errors!
❌ Reader: This makes no sense.
Linters check grammar. They don't check for meaning.
How fast you can write code now
How easy it is to read, maintain, and test later
Optimizing for speed today creates maintenance debt tomorrow.
Poorly designed code has higher interest:
Long Parameter List: This is hard to call, hard to test, and hard to change.
async function createAppointment(
patientId: string,
providerId: string,
appointmentType: string,
startTime: Date,
endTime: Date,
timezone: string,
...
) {
...
Every "quick fix" makes the tower more unstable.
This is caused by high coupling.
Code should communicate intent clearly.
Code should adapt to change easily.
Code should be verifiable in isolation.
These pillars are supported by time-tested design principles:
Replace complex logic blocks with well-named functions.
function handleRefund(userId: string, orderId: string) {
const user = await getUser(userId);
const order = await getOrder(orderId);
// Check if user is eligible
if (
order.status === 'completed' &&
order.purchaseDate > Date.now() - 24 * 60 * 60 * 1000 &&
user.refundCount < 3 &&
!order.isDigitalProduct
) {
await processRefund(order);
}
}
function handleRefund(userId: string, orderId: string) {
const user = await getUser(userId);
const order = await getOrder(orderId);
if (isEligibleForRefund(user, order)) {
await processRefund(order);
}
}
function isEligibleForRefund(user: User, order: Order) {
const withinRefundWindow =
order.purchaseDate > Date.now() - 24 * 60 * 60 * 1000;
return (
order.status === 'completed' &&
withinRefundWindow &&
user.refundCount < 3 &&
!order.isDigitalProduct
);
}
Replace conditional complexity with polymorphism.
function processPayment(method: string, amount: number, details: any) {
if (method === 'credit_card') {
return stripePay(details.cardToken, amount);
} else if (method === 'paypal') {
return paypalPay(details.email, amount);
} else if (method === 'apple_pay') {
return applePayProcess(details.token, amount);
}
throw new Error('Unknown payment method');
}
interface PaymentStrategy {
process(amount: number, details: PaymentDetails): Promise<PaymentResult>;
}
class CreditCardStrategy implements PaymentStrategy {
async process(amount: number, details: PaymentDetails) {
return stripePay(details.cardToken, amount);
}
}
class PaymentService {
constructor(private strategies: Map<string, PaymentStrategy>) {}
async processPayment(method: string, amount: number, details: PaymentDetails) {
const strategy = this.strategies.get(method);
if (!strategy) throw new Error('Unknown payment method');
return strategy.process(amount, details);
}
}
Depend on abstractions, not concrete implementations.
class AppointmentService {
async scheduleAppointment(data: AppointmentData) {
// Hard-coded dependencies - can't test without hitting real APIs
const smsClient = new TwilioSmsClient();
const calendar = new GoogleCalendarClient();
const appointment = await this.createAppointment(data);
await smsClient.sendSms(appointment.patientPhone, 'Confirmed!');
await calendar.addEvent({ title: 'Appointment', start: appointment.startTime });
return appointment;
}
}
interface INotificationClient {
sendSms(phone: string, message: string): Promise<void>;
}
interface ICalendarClient {
addEvent(event: CalendarEvent): Promise<void>;
}
class AppointmentService {
constructor(
private smsClient: INotificationClient,
private calendar: ICalendarClient
) {}
async scheduleAppointment(data: AppointmentData) {
const appointment = await this.createAppointment(data);
await this.smsClient.sendSms(appointment.patientPhone, 'Confirmed!');
await this.calendar.addEvent({ title: 'Appointment', start: appointment.startTime });
return appointment;
}
}
Beyond "does it work?", ask:
Small, intentional improvements compound into enduring systems.
Enduring code is a fundamental investment in:
Try applying one of these refactorings (if it makes sense to do so):