WTF: The Mythical Business Layer
Eric Hodel | Fri, 28 Sep 2007 07:11:43 GMT
Worse Than Failure made a post a few days ago about, among other things, built-in complexity, especially where its unnecessary and unsuited for getting things done.
Just look at the dreadful specs we’re given to work with:
When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.I’m sure those of you who managed to make it through that spec did not have visions of IF-ELSE code blocks swirling through your head. I’ll bet some of you, without even seeing the rest of specs, excitedly envisioned a CancelationWorkflowProvider that inherited from the abstract RequestWorkflowProvider and implemented the IPermissionRequired, IPropogationStatusRequired, and IExpenseAllocationTypeRequired interfaces, and was powered by the all-encompassing WorkflowManager. Why? Because that’s so much more challenging than writing a simple IF-ELSE code block.
—The Mythical Business Layer via Worse Than Failure
While the post focuses on the “business layer” of an application, it is applicable to any development. There’s no need to write that extra library! Start with the core of you want to do, and grow, then refactor, then grow again. Reuse what already exists unless it can’t be molded to your will. If your application code gets too big pull a library out. Don’t write the library up-front, you don’t need it and you won’t need it.
RubyGems Tests Pass on 1.9
Eric Hodel | Thu, 20 Sep 2007 10:00:25 GMT
455 tests, 1600 assertions, 0 failures, 0 errors
Wooo!
Here’s some of the changes and notes I made for you:
- Removed some privates, because life is better without privates.
- Added Object#send! stub on 1.8.
- lambda cares about number of arguments now, so add |*a|.
ENV['FOO'] = nilbecomesENV.delete 'FOO'. This is the most annoying change, since restoring defaults is a pain.- WEBrick’s response object’s #code alias is gone, use #status
(i = 0; 5.times do |i| end; i == 4)is false, so use a separate variable like count, and addcount = i- Kernel#require stores the full path to the require’d file now.
- There’s something going on with class variable sharing between a module and its singleton class. See [ruby-core:12200].
- Strings aren’t Array-like anymore, so use things like Kernel#Array instead of String#to_a
- #methods and #instance_variables return arrays of symbols instead of strings now.
Also, the tests run 20-25% faster on 1.9 than 1.8. Look for a beta of RubyGems coming next week!
Firebrigade Home Page Fixed
Eric Hodel | Tue, 18 Sep 2007 02:40:22 GMT
I denormalized a bit and beat the tests back into shape and the Firebrigade home page is back to life! Next I’m going to sand down a few rough edges on RubyGems to get a beta shipped suitable for feedback.
Firebrigade is now fully vladified using perforce.
Here’s the two setup steps you need for perforce:
- Require ‘vlad/perforce’ at the top of config/deploy.rb.
- Your .p4config goes in the scm/ directory of the server’s checkout.
- Run p4 client in the scm/ directory and set your View to //path/to/project/... //clientname/...
Hopefully we can fully automate this so the vlad:setup_app task can handle this automatically.
I also had to do some custom setup for firebrigade because it uses RubyInline and needs the INLINEDIR set. I just added extra stuff to the setup_app task:
namespace :vlad do
remote_task :setup_app do
cmds = [
"mkdir #{inline_dir}",
"sudo chown www:www #{inline_dir}",
]
run cmds.join(' && ')
end
end
Update: Automatic p4 setup is done!

Articles