Suns standard classes use of constants - bad coding convention

Wasn't sure where to post this, it didn't quite fit into Java Runtime Environment or Java Virtual Machine forums.
I was browsing through The Java Standard classes and was amazed by their use of constants. Throughout the codes there is inserted direct constants in the code without any use of global constant declarations.
Eg: java.lang.StringCoding:
All over the code is inserted "ISO-8859-1" (used as default encoding) directly instead of using a declared constant DEFAULTENCODING. What if Sun want to change default encoding?
Seems strange to me that such coding conventions are used by Sun. Any reason for this or just sloppy programing?
Gil

Looks like sloppy programming to me. I see no possible
reason for it. You're not the first person to
criticise Sun's source code. Maybe they outsourced it
to http://www.newtechusa.com/PPI/main.asp (I can never
remember how to format links, no matter how often
people tell me!)
RObinThere's logic in getting primates to program.
Based on the popular theory that an infinite number of monkeys could
randomly produce the works of Shakespeare, they could also produce the perfect software implementation of any given problem. The downside being that the printed documentation will be smeared liberally with faeces.
regards,
Owen

Similar Messages

  • What is the standard class used to create SALES ORDER in SAP CRM?

    Hello Experts,
    Can anyone suggest me what is the standard class used for creating sales order.
    I have created sales order using the BAPI 'BAPI_SLSTRANSACT_CREATEMULTI' in my report program.
    Now, I have to create sales order using standard classes and methods(my assignment).
    Please suggest the suitable class.
    Regards
    DNR Varma

    Hi Varma,
    You can create crm documents like sales order using BOL interfaces.
    You can check one example at the following thread:
    Create OrderThro BOL
    Check if it helps you a little more.
    Kind regards,
    Garcia

  • How to debug Sun's classes using Eclipse

    Sometimes happens to me during the debugging of my application to have the necessity to "step into"
    in some Sun's classes (java.lang.String, or swing classes or something else).
    Even if Sun provide us the sources, I have not found a way to debug Sun classes because the Sun
    classes are shipped in jars without the debug informations.
    Eclipse open correctly the Sun's source but, without the debug informations into Sun's jars, is impossible
    to proceed with debugging.
    Does anyone can help me?
    Thanks.

    I have not used Eclipse but I think this may do it. While u are build' ing ur project can u place the jar files in the source path so that their classes also get compiled! If u can do then u can step into sun's code.
    s

  • Use of Standard Class in Material Master classification

    Hello Experts,
    Can you please explain me the significance of 'Standard Class' option in classification view of material master?
    When I click on F1 it gives following info (which I can't understands completely)
    A standard class allows you to access all the information on classification and characteristics for an object when you use the object, without having to select one of the classes it is assigned to.
    Can you please elaborate more on this?
    Thanks in advance,
    Vijay.

    Hi Anamika,
    Thanks for your feedback.
    Actually my question is why there is option of 'Standard Class' provided in classification view. If multiple classes are assigned to given material then we can select only one class as a standard class. What is the use of selecting a class as a standard class??
    Thanks in advance,
    Vijay.

  • How to use standard classes to create custom modulepool program like ME21N

    I am at the Starting Point of doing a classical dynpro program via Abap Objects which address all controls with MVC Architecture .So i debugged the standard ME21n transaction to find out how i can start with. I came across this interface which has no Attributes and Methods.I wondered y .Thats y i posted a Question .I also seen a lot of Standard classes
    CL_TABLE_VIEW_MM
    CL_BASIC_MODEL_VIEW_MM
    CL_COMPOSITE_SCREEN_VIEW_MM
    CL_SCREEN_VIEW_MM
    CL_TABLE_VIEW_MM
    CL_TABSTRIP_VIEW_MM
    CL_TC_BUTTON_VIEW_MM
    CL_TC_ITEM_VIEW_MM
    CL_TOGGLE_VIEW_MM
    CL_VALUE_MODEL_VIEW_MM
    and much more for Model and Controllers ..Can u plz guide me how i can make use of this classes effictively in my custom module pool programming

    I think all these classes serve the purpose of embracing the basic ones and are used specificalty in MM module.
    If you want to create similar module pool program with nice expand/collapse buttons in relation to subscreens please refer the some tips [here|expand/collapse button functionality on module pool screen;
    Also there are transactions like BIBS, DWDM which you can follow the examples from. I think SAP has covered all GUI controlls there so you can create really complex programs with various GUI controlls independently of module used for.
    Of course you can still stick to classes you mentioned but I think the better is to learn some standard approach of creating such screens, then if you feel more advanced go for using module specific ones if you really need that.
    Regards
    Marcin

  • Is it possible to use Global class variable in a  BAdi

    Hello Experts,
      I have a requirement wherein ,
             I need the Reference of the Class Object to be used in a BAdi. The class object is defined as a global variable.
    By any means can I use the reference variable inside the BAdi.
    thanks

    Hi Hari,
    U can access any objects or variables in BADI only if they are used as parameters in it.
    So please check whether that global object is declared as parameters in the corresponding BADI.
    If so, you can surely use it.
    Reward points if this is useful.
    Regards,
    kamalapriya

  • How to use method of Standard Class

    Hi all,
                  I want to call a pop up in pcui screen in some standard application with some text. I have made Zclass of  standard SAP class which i am using (cl_bsp_accmod_contact in CRM system).
    I think i have to call 'PRINT_STRING' method of  standard class CL_BSP_ELEMENT.
    <i>I am trying to use this code: </i>
    <b>
    data: lr_data type ref to cl_bsp_element.
      concatenate html 'rohit' into html.  (html is a string)
      lr_data->print_string( html ).</b>
    <u>but it gives a dump:</u>
    You attempted to use a 'NULL' object reference (points to 'noth
    access a component (variable: "lr_data").
    An object reference must point to an object (an instance of a class)
    before it can be used to access components.
    I dont know how to assign object reference to an object???
    Plz help me in this regard,
    Thanks in advance,
    Rohit

    Hi ,
    try and use :
    data: lr_data type ref to cl_bsp_element.
    concatenate html 'rohit' into html. (html is a string)
    lr_data->print_string( html = html ).
    You are creating a variable...but not passing the value to the parameter...it is exactly like callin get_data or get_cell_value...!!
    Hope this helps.
    <i><b>Do reward each useful answer.</b></i>
    Thanks,
    Tatvagna.

  • [svn:osmf:] 14357: Moved constants for namespace ( also added a version number to the namespace) and the metadata key to the MASTPluginInfo class so these constants can be used from player code .

    Revision: 14357
    Revision: 14357
    Author:   [email protected]
    Date:     2010-02-23 09:41:57 -0800 (Tue, 23 Feb 2010)
    Log Message:
    Moved constants for namespace (also added a version number to the namespace) and the metadata key to the MASTPluginInfo class so these constants can be used from player code.
    Modified Paths:
        osmf/trunk/plugins/MASTPlugin/org/osmf/mast/MASTPluginInfo.as
        osmf/trunk/plugins/MASTPlugin/org/osmf/mast/media/MASTProxyElement.as

    Revision: 14357
    Revision: 14357
    Author:   [email protected]
    Date:     2010-02-23 09:41:57 -0800 (Tue, 23 Feb 2010)
    Log Message:
    Moved constants for namespace (also added a version number to the namespace) and the metadata key to the MASTPluginInfo class so these constants can be used from player code.
    Modified Paths:
        osmf/trunk/plugins/MASTPlugin/org/osmf/mast/MASTPluginInfo.as
        osmf/trunk/plugins/MASTPlugin/org/osmf/mast/media/MASTProxyElement.as

  • Finding the standard class name using methods

    hi experts,
                     How to find out the standard class if you have methods.for example i know a method name, so i want to know its class name.How to achieve that??

    Hi ,
    Go to transaction SE84. Repository Info system.
    CLASS LIBRARY -> METHODS .  Search as you like.

  • What's up with the Sun Java coding convention

    I thought Sun leading the Java development should also be a better example on the Java coding convention.
    They do publish a coding convention guide, I believe. But looking at Java core library's source code, so long, coding convention! :(
    Just looked at ArrayList.java source for the version 1.4.2. There are method names like RangeCheck(). Shouldn't a method start with lowercase? Shouldn't a method be verb first like checkRange() instead?
    And there are statements like this all over the place:
    if (foo)
    bar();
    shouldn't that be:
    if (foo) {
    bar();
    man, I thought this golden version of the Java Foundation Library code should be almost perfect by this time now. :(
    --

    if (foo)
    bar();
    // I think the most important part of the if statement
    is the condition for executing the following
    statement(s).
    // Using this style the condition is separated from
    the code by white space which I find easier to read
    // It's also easier to maintain as you don't have to
    remember to add {} if you need to add additional
    statements.I follow camickr's example. I think it's more readable. Whitespace is a good thing, IMO, and not used enough. Putting the brace on the next line down not only makes it easier to associate opening and closing braces visually but it sets the block of code off visually from the rest. Personally, I get a gestalt effect from that.
    I don't worry about a byte here or there. It might sound like heresy, but Moore's Law makes memory and disk space cheaper and more plentiful all the time. I think maintainability and readability trumps being miserly about bytes in my thinking these days. ;)
    Spare me the "inefficiency" lectures. I know - performance matters. The 80/20 rule says that byte won't be killer.
    It's too bad that Sun doesn't follow their own conventions. Don't they do code review there?
    Joshua Bloch didn't follow the standard? Too bad - he did a great job on the collections design. Maybe he delegated it to a younger coder and missed that during the code review. Yeah, that's it! ;)

  • How do I write an external class with global constants?

    Hi you all !
    First I want to explain what exactly I want to do:
    I have an application that should run in different resolutions. The app runs fullscreen, and I don't use Layouts or something, just a single Frame with a Graphics Object.
    Now to handle the different resolutions, I want to write an external class with some constants to use. The usage in my main Class should be something like this:
    public
    class blah
    private Constants myConstants;
    public blah()
    if (highResolution)
    myConstants = new hiResConstants();
    else
    myConstants = new loResConstants();
    System.println(String.valueOf(myConstants.SCREEN_WIDTH);
    }or somthing like that. The important fact is that I can choose the constants at runtime and that I am NOT forced to use methods to get the values, cause something like
    System.println(String.valueOf(myConstants.getScreenWidth());sux if you have methods using 5 or more parameters.
    Anybody out there who understood my problem and can help me??? PLEASE?
    best regards,
    Skippy

    First, what's so much worse about
    System.println(myConstants.getScreenWidth());
    than
    System.println(myConstants.ScreenWidth);
    Is the extra five characters really that bad? (Note
    you don't need the String.valueOf method call.)Well actually it was a wrong example I gave here, but it's not the call that makes me shake but the implementation:
    public int screenWidth = 1024;vs.
    public
    int getScreenWidth()
    return 1024;
    }Here it makes a bigger difference, even when you think of managing about 100 or even more constants.
    Second, why do you have methods that take five or more
    parameters!?Well, maybe this example show up what I mean:
    if (cursorIsInArea(100,100,200,200,areaId))
    doSomeStuff();Ok, I could use Rectangles here, but if you think of the timing here (I draw 30 frames / sec and this check comes about every frame or the animation would be choppy) I refuse to create an Object everytime I make this call.
    Btw: Is it worth thinking about the time of execution like I did in this example? OO is a neat thing, but is it that fast?
    I don't think isCursorInArea(new Rectangle(100,100,200,200),areaId) is such a great idea, but I might be wrong.
    It sounds like you're trying to compound a bad design
    with an even worse design for no good reason!Well, I'm not that experienced Java programmer to judge about that, but I (and my profs at university too) found my codes well structured and designed so far.
    Skippy
    PS: the string.valueOf(123) call came from cut&paste:
    system.out.println(string.valueOf(number1)+string.valueOf(number2));Try this without the function.... ;-)

  • Using Java constant in JSF

    Hello!
    I�m new in JSF and I want to use a constant into a jsf tag but I don�t know how to do it. I know in JSTL but not in FSF.
    This is what I want:
         <h:outputText id="test"     value="<%Constantes.DOCUMENT%>"/>     I have tried so many things to use my constant in the value element but I don�t know the way                    
    Thanks.

    first off Scriplets are bad practice in JSF and should be avoided.
    I use this workaround for constants in jsf. Create a my constant as properties on a FacesConstants class, which is defined as a Managed Bean with scope of none and having getters for each property.
    public class FacesConstants implements MyConstants{
    public String document = DOCUMENT;
    public String getDocument(){
    return document;
    <managed-bean>
         <description>used to get faces constants for refereing in EL Expresssions</description>
              <managed-bean-name>constants</managed-bean-name>
              <managed-bean-class>com.myproj.faces.util.FacesConstants</managed-bean-class>
              <managed-bean-scope>none</managed-bean-scope>
    </managed-bean>
    so in the jsf code just say #{constants.document}
    Not sure if this is best practice? in fact I'd prefer a more elegant solution
    Edited by: scottyb on Apr 8, 2008 5:10 AM
    Edited by: scottyb on Apr 8, 2008 5:12 AM

  • Can not locate Java class using JNI within C++ DLL

    I am using trying to use JNI to call a Java class from C++. The Java class uses JMS to send messages to a JMS message queue. At first I coded the C++ in a console application that created the JavaVM and used JNI to access the Java class. All worked fine. Then I called the Java class using JNI from threads and ran into the problem of the Java class not able to locate the JMS related classes. This was solved by placing the following line in the constructor of the Java class.
    Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
    Then I moved the JNI code from a console application to a DLL in specific an extension DLL that is called by SQL Server or Oracle server. The DLL will use JNI to call the Java class and send messages to a JMS message queue.
    The problem I am having now when the DLL code is called by SQL Server the call to
    JNI_CreateJavaVM
    appears to work correctly but the call to find the Java class using
    jvmEnv->FindClass(pName)
    fails. It appears the is a class loading problem which occurs due to the fact JNI is called from a DLL. When the VM is created I pass the class path information using the statement
    -Djava.class.path=
    And as I stated before it all works when running from a console application. I am new to JNI and really need help in the form of some sample code that will solve this problem. I believe I need to somehow load the classpath information from the DLL but I can not find examples on how to do this using JNI. I have tried several ways using URLClassLoader and getSystemClassLoader from JNI and either it does not work or it crashes very badly.
    I used the following code to determine what the existing class path is and the string returns empty.
    jcls = jvmEnv->FindClass("java/lang/System");
    jmid = jvmEnv->GetStaticMethodID(jcls, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
    jstrClassPath = jvmEnv->NewStringUTF("java.class.path");
    jstr = (jstring)jvmEnv->CallStaticObjectMethod(jcls, jmid, jstrClassPath);
    m_jstr = (jstring)jvmEnv->NewGlobalRef(jstr);
    pstr = jvmEnv->GetStringUTFChars(m_jstr, 0);
    Can anyone please help with example code that will solve this problem. Thanks in advance for any help.
    Charles�

    I have determined the problem occurs when the application/component is compiled using VC 6.0. The test application was compiled using VC 7.1 and works correctly by locating the class path information. If the test application is compiled using VC 6.0 it has the same problem.
    The jvm.dll I am using is version 1.4.2.80. Currently this is not an option to compile all the applications that use JNI using VC 7.1 so can someone please tell me how to solve this problem.

  • Enhance Standard class attributes

    Hi ,
    I have a Standard class of method A and B . The requirement is like i need to create a global attribute in a class so that i copy certain values from method A to global attibute  in order fill certain values in B from tha same global attribute..
    Is this possible to create global attribute?
    Thanks
    Vijay

    Sorry - I am confused about your problem.
    I do know you have a standard class and want to enhance it to add the public attribute.
    You can create the public attribute using the Enhance menu option
    I
    After you have created the attribute(s) you need - how will you set it? in your own code externally to the class or within a method that you call of the class? I assume the latter - well I would suggest try using an implicit enhancement at the end of the method to write the value to the attribute.
    You can read that back in your external coding...for the lifetime of your session

  • Tools to list classes used in the project/

    Hi
    is there any tool that would list all the classes and packages used in my project. the tools must be something like getting input as a main class and list all the other classes used in the project. ?
    -- MJ

    Hi,
    This forum is exclusively for discussions related to Sun Java Studio Creator. Please post your question at :
    http://forum.java.sun.com/forum.jspa?forumID=54
    Thanks,
    RK.

Maybe you are looking for

  • How To Guide on ABAP mapping (How to Use ABAP-Mapping in XI 3.0).

    Hi, I am looking for this document: How To Guide on ABAP mapping (How to Use ABAP-Mapping in XI 3.0), and not able to find it. Can anybody please point me the location, to look for, or post the document. Thanks, Namadev

  • Offline program for google apps

    Hello guys, I'm using the google apps gmail, calendar and docs very intensively and would like to have an offline copy on my system. Is there a program that synchronises those data, primary my calendar? Regards Last edited by orschiro (2010-12-13 07:

  • About OLS integration with OID whitepaper on OTN...

    My OID Support customer tried to follow the steps in this how-to but it failed: http://www.oracle.com/technology/deploy/security/db_security/howtos/ols_oid-how-to.html PROBLEM: Encountered an error at step 13. on page 6. If the DB had OLS the error s

  • Material pricing group

    Dear Guru's, Sales 2 view, we have material pricing group field, where can i find the same, pls tell me d path B/regds, CB

  • Idm-Vaau Rbac role creations and mapping

    Hi All, I'm working on the integration between Idm and Vaau's Rbacx (role based access control) tool for role creation and provisioning...I've imported the spml.xml and SPMLGetObjectsform.xml into Idm for the SPML calls between Rbacx and Idm. The cha