I heard today that Hillary Clinton’s only chance to win the Democratic
primary is “to change the way math works”. Change math? Why do that
when she could just use Ruby:
module DemocraticParty
class Primary
def delegate_count
return clinton.delegates, obama.delegates
end
end
end
module ClintonRevisions
def delegate_count
return (clinton.delegates*1.3).ceil, (obama.delegates/1.3).floor
end
end
primary = DemocraticParty::Primary.new(2008)
primary.extend(ClintonRevisions)
primary.delegate_count
The lesson: you may not be able to change the Primary but you can
extend it!
This code is broken.
Why?
Because there’s no tests written for it.
Also, a Primary should be available to not only the DemocraticParty,
but also the RepublicanParty. This is due to the country being a
Democracy. Moving forth, the DemocraticParty should simply be called
“Democrat”, as the RepublicanParty should also be called “Republican”.
Both of these classes should inherit from Party, as they both have the
same core setup. You should not be calling return in the
delegate_count method, since this will already return the last
evaluated statement.
Continuing, the module “ClintonRevisions” should actually be
“Revisions” with sub-modules of Clinton, Obama, Paul, and if necessary
Giuliani (although I’ve heard rumours these last two may be deprecated
in the future).
Glad to assist.