engineering
engineering
cupid
CUPID - is SOLID slowly becoming obsolete?
CUPID challenges SOLID with properties instead of rules: composable, Unix philosophy, predictable, idiomatic, domain-based. Where the decades-old principles show their age in the cloud era, what 'joyful software' means, and whether SOLID is really done.
ruby
How to create a custom rubocop rule to improve code quality?
Custom RuboCop cops let you enforce your project's own conventions. Step by step: how cops inspect the abstract syntax tree, writing a cop that bans hardcoded phone numbers, wiring it into your RuboCop config, and watching it flag offenses in action.
Latest
Understanding the Singleton Pattern in Ruby
The Singleton pattern in Ruby, shown two ways: a hand-rolled class using private_class_method :new with a self.instance accessor, then a cleaner refactor with the built-in Singleton module. What the pattern guarantees and when one shared instance is worth it.
What is instance and class variable in Ruby?
Instance variables versus class variables in Ruby: what @ and @@ actually mean, why an @ variable set at the class level stays empty when read from an instance, and how @@ values are shared by every instance. Short code samples make each behavior easy to verify.
Ruby Hash destruction like from Javascript world (and reconstruction)
Ruby hash destructuring can feel as smooth as JavaScript: the rightward pattern matching syntax extracts values from a hash in one line, renames them, destructures arrays, groups elements, and rebuilds hashes afterwards. Practical examples for cleaner Ruby code.
Powerful switch statement with pattern matching in Ruby
Pattern matching in Ruby turns case statements into a precise switch over data shapes: match and destructure hashes from an API response, combine several patterns in one branch, capture values across patterns, and validate configuration. Ruby 2.7+ syntax examples.
How to simplify TypeScript types and reduce documentation overhead
TypeScript types with many optional fields need comments to explain what goes together. Discriminated unions fix that: split a Task type into per-status variants so invalid combinations fail to compile and the type documents itself. Before and after code included.
Monkey patching in Ruby done right - refine method with prepend and include
Monkey patching in Ruby without global damage: why reopening a class like DateTime directly backfires, how prepend and include change the ancestor chain safely, and how refine limits your patch to a single scope so the rest of the codebase stays untouched.
Multiple ways to execute a shell command via Ruby
Running shell commands from Ruby: system, backticks, exec, the IO class, spawn, and Open3.popen3 compared with pros and cons, from quick one-liners to capturing stdout, stderr, and exit status, so you can pick the right method for scripts and production code.
Solutions to paginate data in your databse and which one is the best
Database pagination goes beyond LIMIT and OFFSET: ROW_NUMBER(), the FETCH clause, and keyset pagination each behave differently as tables grow. SQL examples for every approach, why offsets get slow on big datasets, and a verdict on which method scales best.
Sidekiq basic_fetch and super_fetch differences
Sidekiq basic_fetch vs super_fetch: open source Sidekiq fetches jobs with BRPOP and loses them when a process crashes, while Sidekiq Pro's super_fetch uses RPOPLPUSH with private per-process queues to recover orphaned jobs. What that means for queue reliability.
Understanding generic types in Typescript
Generic types in TypeScript let one function, class, or interface work safely with many data types. What generics are, how a type parameter beats hardcoding a concrete entity type in a validation helper, and honest pros and cons before you use them everywhere.
Sample DDD explanation in Ruby with Event-sourcing and Event-driven development
Domain Driven Design in Ruby with a working example: aggregates, entities, value objects, and repositories built around a ProductCatalog, then extended with event-driven design and event sourcing, where projections rebuild state from events instead of a database.
Rails optimistic locking, pessimistic locking and how to solve StaleObjectError
Rails locking strategies for concurrent updates: optimistic locking with a lock_version column that works out of the box, pessimistic locking with lock! and with_lock, and practical ways to rescue and resolve the StaleObjectError that optimistic locking raises.
Enums with Typescript - why it's bad? Possible solutions
TypeScript enums generate extra JavaScript at compile time and numeric enums are not even type-safe. Why enums can hurt bundle size and correctness, and two safer alternatives: assigning explicit string values or replacing enums with plain objects.
Solutions for const and enums per class in Ruby
Three ways to define constants and enums per class in Ruby: the ActiveRecord enum macro, a mixed style combining frozen constants with enum, and a dependency-free PORO version. Code for each solution and a comparison to help you pick the right one.
Factory Pattern with auto-detecting classes in Ruby
The Factory Pattern in Ruby, then a step further: using naming conventions and regular expressions so the factory auto-detects which notification class to instantiate. Complete code for both versions, plus when strict class listing is the safer choice.
Ruby SOLID in practice with minimizing nesting rule
SOLID in Ruby with working code for every principle: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion, plus a bonus rule on minimizing nesting and a fair look at the criticisms of SOLID.