ruby
# Simple mixin
module Loggable
  def log(message)
    puts "[#{Time.now}] #{self.class.name}: #{message}"
  end
end

Module mixins and concerns for code reuse

ruby modules mixins
by Sarah Mitchell 3 tabs
ruby
# BAD: N+1 query problem
@users = User.all
@users.each do |user|
  puts user.posts.count  # Fires query for each user!
end

ActiveRecord query optimization and N+1 prevention

ruby rails activerecord
by Sarah Mitchell 3 tabs
ruby
class Timer
  def self.measure
    start_time = Time.now
    yield if block_given?
    end_time = Time.now
    end_time - start_time

Blocks, Procs, and Lambdas for functional programming

ruby blocks procs
by Sarah Mitchell 3 tabs
ruby
class UserNotificationJob < ApplicationJob
  queue_as :default

  # Retry up to 5 times with exponential backoff
  retry_on StandardError, wait: :exponentially_longer, attempts: 5

Background jobs with Sidekiq and ActiveJob

ruby rails sidekiq
by Sarah Mitchell 3 tabs
ruby
require 'rails_helper'

RSpec.describe User, type: :model do
  subject(:user) { build(:user) }

  describe 'validations' do

Advanced RSpec testing with shared examples

ruby rspec testing
by Sarah Mitchell 3 tabs
ruby
class UserRegistrationService
  class Result
    attr_reader :user, :errors

    def initialize(success:, user: nil, errors: [])
      @success = success

Service objects for business logic encapsulation

ruby rails service-objects
by Sarah Mitchell 2 tabs
ruby
class DynamicFinder
  def initialize(records)
    @records = records
  end

  def method_missing(method_name, *args, &block)

Metaprogramming with method_missing and define_method

ruby metaprogramming method_missing
by Sarah Mitchell 3 tabs
yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: user-service
  labels:
    app: user-service

Kubernetes deployment configuration

java kubernetes k8s
by David Kumar 5 tabs
java
package com.example.demo.service;

import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
import io.github.resilience4j.ratelimiter.annotation.RateLimiter;
import io.github.resilience4j.retry.annotation.Retry;
import io.github.resilience4j.bulkhead.annotation.Bulkhead;

Resilience with Resilience4j

java resilience4j circuit-breaker
by David Kumar 2 tabs
java
package com.example.demo.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;

Aspect-Oriented Programming with AspectJ

java aop aspectj
by David Kumar 3 tabs
java
package com.example.demo.multitenancy;

public class TenantContext {
    private static final ThreadLocal<String> CURRENT_TENANT = new ThreadLocal<>();

    public static void setTenantId(String tenantId) {

Multi-tenancy for SaaS applications

java multi-tenancy saas
by David Kumar 4 tabs
java
package com.example.demo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.context.annotation.Bean;

Event-driven architecture with Spring Events

java spring-events event-driven
by David Kumar 4 tabs