Tag Info

New answers tagged

0

I think in the very most cases (not all?) you can replace a case condition with a hash; at least in OOP. Because what else is the case condition than choosing the right value based on the input parameter? This is exactly what a map does: Based on a key it returns a value. But what if some logic is necessary instead of a value? Well in this case the ...


1

Replacing conditional with polymorphism (see Refactoring, Martin Fowler, page 255) is indeed the refactoring which comes into mind. You've already did it partially, by: Creating classes, one for normal price, another for the promotional one. Moving the business logic to the newly created classes. The remaining part is to: Create the hierarchy. It ...


1

The Language Goals for Crystal: Ruby-inspired syntax. Never have to specify the type of a variable or method argument. - Type inference Be able to call C code by writing bindings to it in Crystal. Have compile-time evaluation and generation of code, to avoid boilerplate code. - Templates in C++ Compile to efficient native code. Why is one language ...



Top 50 recent answers are included