SOLID - Single Responsibility Principle YAGNI - You Ain’t Gonna Need It KISS - Keep it Simple Stupid Some clean code principles https://www.amazon.es/Wenger-19201-Navaja-suiza/dp/B000R0JDSI
Single Responsibility Principle Do’s Don’ts * - Input validation - Business logic - Transform data - Return result - Event/Input Filtering - Transport data - Orchestration & long transactions * Most of the time
Single Responsibility Principle Do’s Don’ts * - Input validation - Business logic - Transform data - Return result - Event/Input Filtering - Transport data - Orchestration & long transactions * Most of the time
Orchestration – the wrong way invoke invoke if (… ) invoke // else if (success) Notify with SNS n * invoke if (failure) Enqueue error notify with SNS need approval App…
Simple orchestration with Lambda destinations invoke invoke if (… ) invoke // else if (success) Notify with SNS n * invoke if (failure) Enqueue error notify with SNS need approval App… Lambda Destinations https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-async-destinations
Simple orchestration with Lambda destinations Amazon SNS Amazon EventBridge Amazon Cloudwatch Logs Amazon S3 Amazon SES AWS Config Amazon CloudFormation AWS CodeCommit A S Y N C "DestinationConfig": { "onSuccess": { "Destination": "arn:aws:sns:..." }, "onFailure": { "Destination": "arn:aws:sqs:..." } } Cloudformation template Amazon SNS Amazon EventBridge Amazon SQS AWS Lambda if success: return {...} else: raise Exception(‘Failure', {...}) function code Lambda function A S Y N C
Advanced orchestration with AWS Step Functions invoke invoke if (… ) invoke // else if (success) Notify with SNS n * invoke if (failure) Enqueue error notify with SNS need approval App… https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html
Amazon API Gateway Service Proxy Amazon API Gateway Amazon DynamoDB https://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started-aws-proxy.html
Keep it Simple Simpler functions = Easier to test and maintain Faster to start: less cold start More scalable: higher throughput More secure: less permission needed
Keep your code focused on the business Keep it Stupid Business code is the clever part of the function Orchestration is not the responsibility of a Clever