Need of a self explanatory method like toString(): Your Opinion?

Hi All,
If including a method like showHelp() is recommended as
java programming standard like incorporating toString() in
a class, it will serve as an online help mechanism for
developers using the class. It will be helpful reference
when the source code or API documentation is not available.
Also it will be a nice mechanism for the coder to give
usage information of his class to a newbie or intermediate java programmer.
Example:
public class MyClass {
public int width;
public MyClass() {
public String toString() {
return "Class:MyClass, width:"+width;
public String showHelp(){
String help;
help = "This class is intended to use for.. \n\n";
help += "Typical Usage is... \n\n";
help += "Sample code as followed...\n\n Thank you.";
return help;
}This is what Sun's reply when I submit the feature.
"If you feel this should be implemented and the need is justified,
please start a topic in the JDC forum to see if there is support, and
email me the link. Thanks."
Please share your views regarding this feature.
Thanks.
-bathra

My question is how would this build over Javadoc standards? With the showHelp() method available, wouldn't this be useful only for the programmer? What about running Javadoc on the class and reading the html produced by it? That's what it's there for.
http://java.sun.com/j2se/1.4/docs/api/index.html
If a closed source class file does not have well written thorough documentation, what good will the showHelp() provide? If the documentation isn't available, the question would be why should the class file even be used if you won't have the documentation to be able to use it properly. If the class file is a purchased 3rd party component, that group is responsible for providing good documentation.
This would dramatically increase the size of the compiled Java Bytecode as most comments I've seen are more than tripple than the source of a .java file. Including the comments as an output method could be overkill. My personal opinion is to follow the Javadoc standard and include the html output. Well written tight code is mainly what I'm after.

Similar Messages

  • I am using numbers in the new iWork. Just bought it 10 days back. I am not able to figure out how to add serial umbers from 1 to 100( for example) also i need to freeze the top header like in windows so that we can browse down without the heading going of

    i am using numbers in the new iWork. Just bought it 10 days back. I am not able to figure out how to add serial umbers from 1 to 100( for example) also i need to freeze the top header like in windows so that we can browse down without the heading going off. Can some one help?

    Hi Jay,
    Be aware that "Freeze Header Rows" and "Freeze Header Columns" apply only to rows and columns that are Header rows or Header columns. You can have up to five Header rows, Five Header Columns (and five Footer rows) on a Numbers Table.
    "Header rows" is a special designation. Besides being able to be frozen, Header and Footer rows are not included in formulas referencing whole columns, making it possible to place formulas such as =SUM(B) at the top (or bottom) of column B without causing a self-reference error, These designated rows are also not included in sorts of the rows in a table.
    Regards,
    Barry

  • [svn] 2622: TextBox and TextGraphic now call applyDisplayObjectProperties() at the end of their draw() method, like all other GraphicElements.

    Revision: 2622
    Author: [email protected]
    Date: 2008-07-24 16:13:32 -0700 (Thu, 24 Jul 2008)
    Log Message:
    TextBox and TextGraphic now call applyDisplayObjectProperties() at the end of their draw() method, like all other GraphicElements. This method handles setting the visibiliy of the GraphicElement's DisplayObject, among other things.
    Note: We should make it unnecessary for each GraphicElement subclass to have to call applyDisplayObjectProperties() at the end of draw(). The GraphicElement base class should ensure that this gets called at the appropriate time.
    Group now calls draw() on graphic elements even if they are invisible, because otherwise applyDisplayObjectProperties() never gets called and the TextLines stay visible. Group was assuming that the only visible stuff in a GraphicElement is drawn with Graphics calls, which isn't the case.
    This change is OK for now because every GraphicElement currently has its own DisplayObject, but it will need to be rethought when GraphicElements share DisplayObjects.
    Reviewer: Chet
    Bug: MXMLG-206 ("Setting visible property on TextGraphic does nothing")
    QA: Peter, please add a Mustella test case for the 'visible property of TextBox and TextGraphic
    Doc: No
    Ticket Links:
    http://bugs.adobe.com/jira/browse/MXMLG-206
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/core/Group.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/TextBox.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/TextGraphic.as

    Changes for spine–aligned head:
    public class StickManTool extends JPanel
        public StickManTool ()
            limbs [16] = new Limb (lankle, lfoot, 1);
            head = new Head2D (limbs[0]);
        protected void paintComponent (Graphics g)
            head.draw(graphics);
        private void updateLimbs (Point start, Point end)
            head.setPosition();
    class Head2D extends Ellipse2D.Double
        public static double width = 30;   // width of head
        public static double height = 40;  //height of head
        Point atlas;
        Point pelvis;
        private AffineTransform xform = new AffineTransform();
        public Head2D(Limb spine)
            super ();
            atlas = spine.movingJoint;
            pelvis = spine.fixedJoint;
            setPosition();
        public void setPosition()
            // Find angle of spine.
            double dy = atlas.y - pelvis.y;
            double dx = atlas.x - pelvis.x;
            double theta = Math.atan2(dy, dx);
            //System.out.printf("theta = %.1f%n", Math.toDegrees(theta));
            // Find center of head as extension along spine from atlas.
            double cx = atlas.x + (height/2)*Math.cos(theta);
            double cy = atlas.y + (height/2)*Math.sin(theta);
            // Move to origin of head.
            xform.setToTranslation(cx-width/2, cy-height/2);
            // Rotate head about its center.
            xform.rotate(theta+Math.PI/2, width/2, height/2);
        public void draw(Graphics2D g2)
            g2.draw(xform.createTransformedShape(this));
        public double getWidth () { return width; }
        public double getHeight () { return height; }
        public void setWidth (double widthIn) { width = widthIn; }
        public void setHeight (double heightIn) { height = heightIn; }
    }

  • I am using iPhone 4s with no sim card. My WiFi turned grey and isn't working. I've tried many methods like freezing and Resetting the network settings, still not working. Now what should I do? (iOS 7.1.2)

    I am using iPhone 4s with no sim card. My WiFi turned grey and isn't working. I've tried many methods like freezing and Resetting the network settings, still not working. Now what should I do? (iOS 7.1.2)

    Put in a micro SIM (SIM need not be active) and
    Restore from backup
    Restore as new
    http://support.apple.com/en-us/HT201252

  • I have copied many photo's from another laptop to my Mac.  The older photo's are in directories with names that help me select what I need to view. I would like to have all my imported new photo's also bee added to the directory structure I have in Finder

    I have copied many photo's from another laptop to my Mac.  The older photo's are in directories with names that help me select what I need to view. I would like to have all my imported new photo's also bee added to the directory structure I have in Finder but my new photo's are all in iPhoto.  I want to use directories for storing and iPhoto for viewing.  Is this possible or do I need to have all my photo's in iPhoto??
    Mitch

    iPhoto is not a Photo Viewer. It's a Photo Manager and designed for looking after the files while you organise the Photos. It really works much better if you let it manage those files. If you use iPhoto you never go near those files because iPhoto is your start point for anything you want to do with your Photos - the point of the pplication.
    You can run iPhoto in Referenced mode, where it does not copy the files to the Library, but I caution you that you are making life a lot more difficult for yourself by doing that.
    How to, and some comments on why you shouldn't, are in this thread
    https://discussions.apple.com/thread/3062728?tstart=0
    Regards
    TD

  • TA24002 My 500 GB can't verify nor repair. I have photoshop work that I need to recover. I would like to know which erase option would be the best solution for this problem.

    My 500 GB can't verify nor repair. I have photoshop work that I need to recover. I would like to know what option would be the best solution for this problem?

    You appear to have two issues: 1) a hard drive that is not working properly and 2) files you wish to recover.
    Re 1) you need to answer Kappy's questions.
    Re 2) does the drive load and can you see your photo files? If so can you copy them to another drive?
    Do you not have a backup of the photo files?

  • I have a MacBookPro6,2 and would like to connect an older Dell flatscreen, model L17BNS. I would welcome any information about the type of cable I need and any settings I might need to change, etc. Thank you for your time.

    I have a MacBookPro6,2 and would like to connect an older Dell flatscreen, model L17BNS. I would welcome any information about the type of cable I need and any settings I might need to change, etc. Thank you for your time! I really appreciate the assistance. Kathy

    According to:
    http://en.community.dell.com/support-forums/desktop/f/3515/p/19351107/19767627.a spx#19767627
    It has DVI ports.  This means you are best to use an adapter that supports DVI.  Note there is no audio that carries over DVI.  What you need is a mini-Displayport to DVI adapter, and the proper DVI cable. Since Dell doesn't have the specs, you'll need to tell us if you have pins or holes, and how many are grouped.

  • Use of bpelx built-in methods like getVariableData in custom java classes

    Hi,
    how can I use bpelx built-in methods like getVariableData ...
    inside custom java classes embedded with BPEL project?
    I have large java code to embed with BPEL process
    and it will be very useful ....
    It is possible to access these methods like static methods of some class?
    import com.xxx.yyy.class;
    class.getVaribleData("inputVariable","payload","/ns1:mailMessage/ns1:content/ns1:multiPart");
    Regards
    Karel

    you can access them from <bpelx:exec> activity and you can pass these returned document to underlying java class.
    Re: getVariableData in Java Exec

  • Need to Hide Objects Default method in Approval Task

    Dear All,
      I have a requirement, where I need to hide the default method that is getting displayed in the approval task of the workflow.
    The employee object and Trip objects default method are getting displayed in the preview of approval task. And same is getting displayed in the universal worklist in the columns of attachments.
      There is an option in univesal worklist configuration where we can remove the attachments for display.
      But to our requirement , only certain objects and attachments should be shown in portal and R/3 of the approval task.We need to restrict the employee object and trip object which is shown in objects and attachments column of the standard descision task.
    Let me have any suggestion on this.
    Thanks in advance.
    regards,
    Sabari Prabhu.

    Hi,
    I took a look into this same issue some time ago, and at least I didn't find a way to restrict only certain attachments for displaying in UWL. If the attachments cannot be hidden, I have tried to avoid using the business objects as much as possible. For example the employee object is many times binded to the task only because you want to display certain attributes in the task description. Then I have just binded the needed attributes into separate container elements. Of course this will not solve all the cases.
    Then other useful options are that you change the default method, and this method is implemented in a way that it either does not display anything, or displays something (maybe just an error message etc.) that makes more sense than the default method that SAP delivers. Or then you can implement for example your own web dynpro application that will be launched when you click the attachment.
    Regards,
    Karri

  • Need Help with a getText method

    Gday all,
    I need help with a getText method, i need to extract text from a JTextField. Although this text then needs to converted to a double so that i can multiply a number that i have already specified. As you may of guessed that the text i need to extract already will be in a double format.e.g 0.1 or 0.0000004 etc
    Thanks for your help
    ps heres what i have already done its not very good though
    ToBeConverted.getText();
    ( need help here)
    double amount = (and here)
    total = (amount*.621371192);
    Converted.setText("= " + total);

    Double.parseDouble( textField.getText() );

  • Need to know of a method / process that can be used to send the same msg to all those appearing in my email listings with the same extension after the "@" sign in their address(es) on my macbook [e.g., with "@gov.ca"; Snow Leopard].

    Need to know of a method / process that can be used to send the same msg to all those appearing in my email listings with the same extension after the "@" sign in their address(es) on my macbook [Snow Leopard].

    If you simply want to send the exact same message to everyone in your address book with emails ending in "@whatever.com", you can do the following:
    Create an email with subject, message and attachments but no addresses
    Open Address Book, All Contacts
    Search in Address Book for @whatever.com
    Select the results and drag them into the To: or Bcc: field of the email. If Bcc: then put your email address in the To: field.
    Send the email
    This will not personalize the emails (such as with "Dear firstname:" at the top of the message) but it will let you send an idential message to everyone who meets your criteria.

  • In which case we need a class with all methods defined as abstract ?

    In which case we need : A class with all methods defined as abstract (or should we go for Interface always in this case)

    The concept of interface and abstract class overlaps sometime, but we can have the following thumb rule to use them for our specific need:
    1) Interface: This should be use for code structuring. They standardize your application by providing a specific contract within and outside. If you think abstract class also provide structure, then reconsider as it limits the structure re-usability when there are many super-classes to inherit from. Java allow multiple inheritance by interface and not by Abstract class.
    2) Abstract Class: This should be use for code-reusability. Interface doesn't have any code so can't be used for code-reusability.
    Actually we can use both to provide the best.Taking a refernce to J2EE framework, the "Servlet" is an interface. It laids down the contract/structure for any code to be a servlet.
    But the "GenericServlet" class is an abstract class which provides implementation of some of the methods defined in the "Servlet" interface and leave some method abstract.
    Thus we see that the "Servlet" interface standardise the structure and the "GenericServlet" abstract class gives code re-usability.
    Original Question:
    In which case we need a class with all methods defined as abstract ?To this question, as all methods are abstarct we don't have option for code-reusability. so why not add standard structure concept to your application. So if there is not any restriction on making the field variable(if any) as final, we should go with the interface concept.

  • I need block a particular site, just like in IE when i goto Privacy option I can specify and site & say Block - where can i find thi s in firefox?

    I need block a particular site, just like in IE when i goto Privacy option I can specify and site & say Block - where can i find thi s in firefox?
    I've been getting some junk websites while I am working. I need to block them completely.
    Please advise. Thanks,

    There is no equivalent in Firefox. You can use the [https://addons.mozilla.org/en-US/firefox/addon/3145/ BlockSite] extension to add a similar feature.
    If the junk sites are coming up whilst you are browsing, this may be caused by malware. You should consider scanning your computer with some malware programs. It is best to run several as each will pick up things that the others miss. Some scanners you can try are:
    * [http://www.malwarebytes.org/mbam.php Malwarebytes]
    * [http://www.superantispyware.com/ SUPERAntiSpyware]
    * [http://www.lavasoft.com/products/ad_aware_free.php Ad-Aware]
    * [http://www.microsoft.com/windows/products/winfamily/defender/default.mspx Windows Defender]
    * [http://www.safer-networking.org/en/home/index.html Spybot S&D]

  • Error: Permission denied for (document.domain has not been set) to call method Location.toString on (document.domain=).

    Why am I getting these errors Error: Permission denied for (document.domain has not been set) to call method Location.toString on (document.domain=).
    == URL of affected sites ==
    http://

    HOW DO YOU SET THIS??? I'M FRUSTRATED OVER THIS. ITS BEEN 2 MONTHS SINCE I HAVE BEEN ABLE TO PLAY ANY GAMES IN FACEBOOK DUE TO THIS PROBLEM! IT DOES NOT MATTER WHAT BROWSER I USE I STILL GET THIS SAME MESSAGE.

  • Do i need to reinstall programs and applications like FCP after upgrading to the new Lion OS?

    Do i need to reinstall programs and applications like FCP after upgrading to the new Lion OS?

    I've installed Lion over Snow Leopard and all my non Apple software is still here - you may want to check if your software will work with Lion and I would definately recommend having a bootable backup in case anything goes wrong
    Regards,
    Colin R.

Maybe you are looking for