Home » Archives for Ashley Frieze

Author Archives: Ashley Frieze

Software developer, stand-up comedian, musician, writer, jolly big cheer-monkey, skeptical thinker, Doctor Who fan, lover of fine sounds

Queue Processing Considerations

Overview We may choose to use a queue to link parts of our process together. There are a few reasons for that: Delay non-urgent processing until laterAttempt to guarantee the execution of an action that may failScale the processing of a source of work by having multiple executors consuming the queueDecouple an action from the event that triggers it There ...

Read More »

Functional Decomposition

Why Do I Have To Have A Function? function giveBonus(currentYear, price) { if ((currentYear % 4 === 0) && price > SUPER_THRESHOLD) { return SUPER_BONUS; } return price > BASIC_THRESHOLD ? NORMAL_BONUS : 0; } The above is a small function that gives a bonus. So why should I need more sub-functions? Personally, I’d probably hope to make the above ...

Read More »

React Version Stamping Recipe

My view on version numbering is that we should take the build time and git SHA of our code and pass it through to the build as a version identifier. Then we can easily look at any stamped version of our application and find where it came from. To me, this is more powerful than stamping an arbitrary release number ...

Read More »

Serverless Spring is Quite Bouncy

I’ve written a couple of articles about AWS Lambda I showed how to use Hibernate in AWS Lambdas over on BaeldungI also showed a full alternative to Spring for an enterprise-grade set upThen I’ve discussed how the size of Log4j can make a Lambda start up more slowlyI’ve even complained about Oracle making a huge Java library for MySQL It’s ...

Read More »

The Chimera Function

I’ve written before about a function that essentially does two different versions of the same thing. It’s sort of cute to think that we can pass a boolean into a function to control whether it uses variant A or variant B of the algorithm. There can be milder forms of this too. Perhaps we pass in a boolean to ask the ...

Read More »

Comments Suggesting Refactoring

Allow me to share with you one of my favourite refactorings. This comment in the code indicates a missing extract method refactor A simple example: const customer = getCustomer(); // find the customer's discount rate const customerPoints = customer.loyaltyPoints + customer.weeklyPoints; const discountRate = customerPoints > 100 ? 0.1 : 0; return price - (price * discountRate); The interesting part ...

Read More »

Insane AWS Lambda Speed Up

java-interview-questions-answers

What makes this post annoying is that we’ve suffered from a slow Lambda cold start for a very long time, and the solution was literally a few seconds’ work. I’ve written before about reducing bloat in Lambdas, especially the MySQL driver. However, the JVM is still quite slow to start. I’ve learned to package AWS Lambdas using ZIP, rather than ...

Read More »

Oh TypeScript!!!

I’ve written before about the weirdness of TypeScript and instance functions of classes. To summarise. Let’s say we’re using map on an array of strings, and we therefore need to give it a function (item: string) => Something – and maybe we have a SomethingFactory which can use its internal state to make our things from the item: export default ...

Read More »

Not Another Opinion

Sometimes we have some data and we need to draw some conclusions about it. E.g. const customer = { tier: GOLD, points: 12345, }; ... // meanwhile in the business logic // shall we give the customer a discount? if (customer.tier === GOLD && points > 10000) { giveDiscount(); } In the above, the function deciding to give a discount ...

Read More »