|
|
Writing 20 or 30 get/set methods is bad
I find it a pain when writing java code to type out 20 or 30 get set methods (since you sould use get and set in java instead of referring straight to the variable) so i wrote a perl scrpt that does this for me. If you have classes with 20-30 get/set methods then your design is clearly wrong. There's no reason for other classes to need access to all the internal variables of a class. You should do an actual design and only allow access to things that external classes need access too. Remeber the point of abstraction is that the external interface does not have to resemble the internal structure of a class. /me thinks you are using the C-struct mentality, in which case you would be better off just using public variables. Making all the varables private and creating get/set methods doesn't make your code any better. Data Flow Diagrams (DFD) and Class Reponsibility Cards (CRC) are a great way to find out just what needs to be shared between classes. Remember, the goal of OO programming is to increase cohesion in classes and decrease coupling between classes
Writing 20 or 30 get/set methods is bad
I do understand this, all the script does is do the basic get/set method i usually have a couple of extra lines of code that converts or changes the data in some way so i don't have to remember to do this every time. also i use them mostly for internal class' and set as private or protected. as i said, this just does the grunt work.
Writing 20 or 30 get/set methods is bad
Encapsulation (or -for others who perhaps don't know-preventing access to the internals of a class from outside and requiring accessor functions) is a good thing.
Writing 20 or 30 get/set methods is bad
Yawn. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.06 seconds |
|