Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Getters and setters considered harmful.

Name: Anonymous 2010-05-26 14:10

Getters and setters considered harmful.
Or: How do i broked encapsulation?


Discuss.

Name: Anonymous 2010-05-26 14:21

The solution is attr_accessor

Name: Anonymous 2010-05-26 14:29

Greeks and settlers considered harmful?

Name: Anonymous 2010-05-26 14:30

void * addressOfAttribute (char *attr_name);

Name: Anonymous 2010-05-26 15:11

I don't get wtf anyone uses getters and setters.  Can't you just make the variable public?

Name: Anonymous 2010-05-26 15:21

>>5
No, if you do that then you can't make a meaningful distinction between interface and implementation (at least at a class level).

Name: Anonymous 2010-05-26 15:30

>>6
Poor >>5-san. In many languages access can be controlled implicitly with the effect that the distinction can be made exactly when and where it is desired without any changes to the interface. Just don't try it in C++.

Name: Anonymous 2010-05-26 15:31

>>1
For some reason, OP thinks getters and setters is a consequence of encapsulation when he is mistaking it for data hiding.

Name: Anonymous 2010-05-26 16:06

Actionscript has syntax for getters and setters, which, along with E4X support, makes it possibly the most ENTERPRISE language this side of Java:

package org.4chan.dis.prog {

    public class ScalableEnterpriseSolution extends Solution implements IScalable, IEnterprise {

    private var enterpriseXML:XML = <scalable>
                                          <enterprise>
                         <solution>
                          <spoiler>/prog/</spoiler>
                          leverages core skillsets
                          and world-class team
                          synergy through SICP to
                          provide clients
                          worldwide with robust,
                          scalable, modern turnkey
                          implementations of
                          flexible, personalized,
                          cutting-edge
                          Internet-enabled
                          e-business application
                          product suite e-solution
                          architectures that
                          accelerate response to
                          customer and real-world
                          market demands and
                          reliably adapt to
                          evolving technology
                          needs, seamlessly and
                          efficiently integrating
                          and synchronizing with
                          their existing legacy
                          infrastructure,
                          enhancing the
                          e-readiness capabilities
                          of their e-commerce
                          production environments
                          across the enterprise
                          while giving them a
                          critical competitive
                          advantage and taking
                          them to the next level.
                        </solution>
                      </enterprise>
                                        </scalable>;
   
    public function set enterpriseXML(enterpriseXML:XML) : void {
        this.enterpriseXML = enterpriseXML; }
   
    public function get enterpriseXML() : XML { return
        enterpriseXML;
    }
    }
}

Name: Anonymous 2010-05-26 16:27

>>9
The formatting is probably fucked up because I was switching between actionscript-mode and xml-mode in Emacs, but you get the idea.

Name: Anonymous 2010-05-26 17:42

>Actionscript
It's from Canaduh; nothing good will ever come of it.

Name: Anonymous 2010-11-25 8:12

Don't change these.
Name: Email:
Entire Thread Thread List