Loading ...
Sorry, an error occurred while loading the content.
 

Re: [XP] refactoring my way out of an Open-Closed violation

Expand Messages
  • Carfield Yim
    What language are you using? If it is Java then sound like it can be solved by generic.
    Message 1 of 5 , Dec 20, 2007
      What language are you using? If it is Java then sound like it can be
      solved by generic.


      On Dec 11, 2007 1:18 AM, D. André Dhondt <d.andre.dhondt@...> wrote:
      >
      >
      >
      >
      >
      >
      > Hi all,
      >
      > Today my pair and I noticed a code smell that we weren't sure how to
      > refactor--I think it's an OCP violation--how would you clean it up? (Or
      > what should I read to learn more about this)? Please note we're using a
      > static-typed language (I think the duck-typed solution is so
      > straightforward
      > that it's not even a problem):
      >
      > We have a base class, Presenter_Base, that refers to Model_Base. We have
      > multiple subclasses of Presenter_Base that each refer to yet other classes
      > that implement Model_Base. Presenter_Base gets extended into, say,
      > SQLPresenter, and there is a new method, say, SQLPresenter.IsSQLValid, that
      > downcasts the private property _model to a SQLModel. Now, semantically, I
      > think this is a violation of OCP or encapsulation since we're overriding
      > the
      > signature of this private _model property. How do I clean it up?
      >
      > --
      > D. André Dhondt
      >
      > If you're a software developer in the area, join Agile Philly (
      > http://groups.yahoo.com/group/agilephilly/)!
      >
      > [Non-text portions of this message have been removed]
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.