Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is this code smell?
#1
Is it considered bad practice to have a higher level code pass messages through one layer of abstraction? Like this:

Code:
class HigherAbstraction:
  def __init__(self):
    self.bar = LowerAbstraction()

  def Spam(self):
    return self.bar.Spam()

class LowerAbstraction:
  def Spam(self):
    return 1

this = HigherAbstraction()
this.Spam()

Is there a way that this can be better factored? Sometimes I have to create several different HigherAbstraction types of classes where all instances of HigherAbstraction also could use functionality from LowerAbstraction.
Reply


Messages In This Thread
Is this code smell? - by Fiel - 2011-01-06, 09:25 PM
Is this code smell? - by Mute - 2011-01-06, 10:24 PM
Is this code smell? - by AngelSL - 2011-01-07, 03:16 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)