V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Feiox
V2EX  ›  编程

如何写一个真正面向对象的类?

  •  
  •   Feiox · Sep 18, 2014 · 2969 views
    This topic created in 4247 days ago, the information mentioned may be changed or developed.
    比如,
    * 封装:具体粒度?封装的接口?
    * 继承:抽象?多继承?接口的继承?
    * 多态:????????
    (不严格区分语言,但只是也应该是完全面向对象类型的语言)

    P.S. 其实比较想问:方法中使用的参数(在类实例中共享),是应该从方法形参中取得,如:
    def do_somethin(self, param_1,param_2): # 定义
    pass

    do_something(self.p1, self.p2) # 在同一个类的其他方法中使用

    还是应该以类似以 self. attr 形式使用? 如:
    def do_somethin(self):
    key = self.attr # 在同一个类的其他方法中使用
    1 replies    2014-09-18 13:35:21 +08:00
    jsonline
        1
    jsonline  
       Sep 18, 2014 via Android
    函数式编程有没这个问题了。
    func.call(object)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2898 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 07:17 · PVG 15:17 · LAX 00:17 · JFK 03:17
    ♥ Do have faith in what you're doing.