How do I include a Module into another Module (Refactor AASM code and custom states into Module)

You can’t include one module in another exactly, but you can tell a module to include other modules in the class into which it’s included: module Bmodule def greet puts ‘hello world’ end end module Amodule def self.included klass klass.class_eval do include Bmodule end end end class MyClass include Amodule end MyClass.new.greet # => hello … Read more

How to update old C code? [closed]

First, you are fortunate to have a boss who recognizes that code refactoring can be a long-term cost-saving strategy. I’ve done this many times, that is, converting old C code to C++. The benefits may surprise you. The final code may be half the original size when you’re done, and much simpler to read. Plus, … Read more

Is there a more modern, OO version of “Let’s Build a Compiler”? [closed]

It sounds like you completely missed the point of Crenshaw’s tutorials. LBC isn’t about writing pretty, clean, or efficient code. It’s all about bringing something that’s steeped in formal theory down to a level where the casual coder can easily and rapidly hack out a rudimentary (but working!) compiler. When I read through LBC years … Read more

Unit testing: Is it a good practice to have assertions in setup methods?

Instead of assertions in the setup to check the result, I used a simple test (a test method along the others, but positionned as first test method). I have seen several advantages: The setup keeps short and focused, for readability. The assertions are run only once, which is more efficient. Usage and discussion : For … Read more