Java Coding Conventions -  Debugging

I am developing a Coding Convention document for a group of folks that are doing some remote development for me and while I have reviewed the Java coding conventions provided by Sun, I haven't seen anything that talks specifically about debugging. I have been asked to include some recommendation concerning where (and when) to put debuggin messages within the code (i.e. when you enter a method, etc.) Are there any conventions around this? I have my own practices but I am looking to find a commonly used industry approach. Thanks

By debugging messages you mean comments? This is all I found in the doc:
"Use XXX in a comment to flag something that is bogus but works. Use FIXME to flag something that is bogus and broken."
I doubt that helps :P As far as an industry standard, not much out there that I could find.

Similar Messages

  • 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! ;)

  • Java style and coding conventions

    Hello All,
    Most of my programming experience is in Java, and as such, I try to conform to the style and coding conventions that are used in all of the Sun tutorials, and to my understanding, the specification. I'm enrolled in my final semester of a bachelor's of computer science and engineering, and one of my courses is "Software Engineering". Our course assignment is to make a website, written in PHP. I don't really care for PHP, so I volunteered for the Code Quality Assurance team, thinking, I'm fairly consistent when it comes to adhering to the Java conventions, it should be reasonable to determine similar conventions for this project, and give my classmates pointers on how to improve the readability and layout of their source listings.
    The problem is, my professor, absolutely, whole-heartedly hates Java. He despises everything about it. For example, I sent him a source listing that I felt was well written, readable, and adequately documented. Some of the things that I was "doing wrong" were:
    1. Naming Conventions
    All of the Classes were first-letter capitalized, subsequent first-letter of each word capitalized. FormLayoutManager was one particular example. All instance or primitive identifiers were first-letter lowercase, subsequent first-letter capitalized, so an instance of FormLayoutManager could be formLayoutManager, or menuLayoutManager, etc. All constants were all capitals, with underscores separating each word. MAXIMUM_POWER. All methods were first-letter lowercase, subsequent first-letter capitalized, showLoginComponents().
    My Professor insists that the convention I (and most of the Java community as far as I can see) is terribly unreadable, and that all instances variables and method names be first-letter capitalized. I tried explaining that this sacrifices the ability to easily distinguish between a class type or interface, and an instance, and was ignored.
    2. Declaration and Initialization
    Also, supposedly declaring a local identifier and initializing it in the same line is some sort of abomination of everything sacred in programming. So I found myself constantly doing things like
    public String info() {
      StringBuilder info;
      info = new StringBuilder(512);
      // append a bunch of information to info
      return info.toString();
    }3. 80 Character line widths
    He wants me to break any statement that is over 80 characters in width into multiple lines. I know a long statement wrapping around in your editor is a irritating, but 80 characters, seriously, who doesn't have an editor that can't handle more than 80 characters on a line?
    4. this and argument names
    In most of my constructors that accept arguments, I would usually do something like
    public Student(String name, int age) {
       this.name = name;
       this.age = age;
    }Which he thinks is horribly confusing, and should be
    public Student(String n, int a) {
      name = n;
      age = a;
    }5. singular collections / arrays identifiers
    I had something like:
    String[] keywords= new String[] { "new", "delete", "save", "quit" };
    for (int i = 0; i < keywords.length; i++) {
       System.out.println(keywords);
    And he insisted that "keywords" be renamed "keyword", as in, the i-th keyword, which I think is kind of stupid because the array is an array of keywords, and having a singular identifier makes that less obvious.
    It's driving me crazy. It's driving everyone else in the class crazy because they're all mostly used to Java style conventions as well. I've tried pleading my case and I can't even get him to acknowledge the benefits of the "alternative" styles that I've used in my programs up to this point.
    Have any of you had to deal with either professors or bosses who have this type of attitude, whether it be towards Java or any other language? This guy has been involved with computer science for a while. I think he's used to Pascal (which I know nearly nothing about).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    You will find people who will disagree about this stuff all the time. I had a similar course and we read "Code Complete" which offers some style suggestions. Fortunately, my professor was intelligent enough to allow a discussion of these styles and I had a chance to argue against the "bracket every if statement" idea and other little things I didn't agree with. It was insightful conversation, rather than a "I'm the professor, you're a student, so listen to me".
    Here's the important part: It doesn't matter what the standard is, only that there is one.
    Unless I misunderstand, he allowed you to take on the responsibility of QA, so it is ultimately your decision. If the project suffers because of poor quality of code, it will be on your head. If, on the other hand, you give in to him and use a style that makes no sense and the project suffers because of poor code, it will still be on your head.
    So he really has no position in this because he is not a stakeholder in this decision. Tell him that this is your responsibility and you need to make the choices that are right for your group, not right for him. If he's teaching you anything that can reasonably be called software engineering, he should understand that. Otherwise he's just teaching out of a book called "Software Engineering" and doesn't know anything (or so it seems from this small window you've given us).
    caveat: If he's reviewing the code and he's particularly snarky about his "styles", you might want to consider giving in to his demands for the sake of your grade. Sad reality.

  • 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

  • Flex 2.0 Naming an Coding Conventions

    Hello,
    I'm new with Flex 2.0 and Actionscript 3.0.
    They asked me to define naming and coding conventions for
    Flex 2.0 and Actionscript 3.0 for our company.
    I'm looking for documents for naming and coding conventions
    for Flex 2.0 and Actionscript 3.0 so I can make conventions for our
    company.
    Who can help me?
    Thanks in advance.
    Simson

    I think you could do one based on Sun's coding convention for
    Java, since the syntax is similar. Take a look at the Java
    convention and you'll get a pretty good idea

  • JSP coding conventions document?

    All,
    I'm teaching a spring 2004 courses on JSP at Park University and I'd like to have a coding conventions document. I have one for my Java, HTML, and C++ courses and they're very helpful. In doing a Google search, I found this Sun article:
    http://java.sun.com/developer/technicalArticles/javaserverpages/code_convention/
    It looks very promising, but it suddenly stops after only 2 pages. The article says:
    [We'll] address file names and organization, indentation, comments, directives, declarations, scriptlets, expressions, white space, naming conventions, and programming practices. As this is our first attempt at presenting a set of JSP coding conventions, we're quite interested in any feedback you may have on these recommendations. Please send all feedback to [email protected]
    But the article stops after covering opening comments. I've sent an e-mail to the authors, but no reply yet.
    Please help ASAP because I need to get squared away by the end of this coming week (1/9).
    Thanks,
    John

    This article used to be much longer. I read it not long ago.
    There was an original post about it here: http://forum.java.sun.com/thread.jsp?forum=45&thread=363196&tstart=540&trange=15
    Don't know what happened to it. And after a quick google haven't managed to find it mirrored anywhere.

  • Coding conventions for SERVLETS

    Where to find coding conventions for Java Servlets ?

    Why would they be any different from the coding conventions for all of Java?
    http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html

  • Where could I find java coding specification

    Where could I find java coding specification.
    I don't know what it really names for, I think it gives a principle for how to coding java program.
    For example, it will tell us which one is better between "final static" and "static final"

    For example, it will tell us which one is better
    between "final static" and "static final"neither of these, it's
    static public final
    Rules:
    first static as theses are class
    variables/methods that don't need instantiation. Then
    the non-static fields/methods. Therefore, "static"
    should be the first keyword for clean grouping.
    Then the visibility like public, protected,
    private (in this order) should be used. (see
    [url=http://java.sun.com/docs/codeconv/html/CodeConven
    tions.doc2.html#1852]Instance variables).Afterwards use final which should be the last
    keyword before the variable type / method return type
    / method parameter type, e.g.
    static public final doThis(final String key) {
    }If these are the "rules", then why is the convention for the main function
    public static void main(String[] args)?

  • Creating a New Folder in Windows Registry by java coding

    Good morning,
    hi to all,
    how can I create a New folder in Window Registry using Java coding. Can anybody help me out pls.
    I begin waiting for ur reply.
    Thanx

    Why do you feel you need to write to the Windows registry directly? Take a look at the Preferences class.
    {color:#0000ff}http://java.sun.com/javase/6/docs/api/java/util/prefs/Preferences.html{color}
    luck, db

  • How to activate a specific profile of the Firefox using java coding?

    Hi Folks,
    I have some query regarding activating the Profiles of the Firefox. Whenever i open the Firefox, the profile manager will be prompting for the profile to be activated. I want to perform such similar operation through java coding. Let us assume, I have three profiles named default, office and personal. I need to invoke the Firefox with a specific profile, office. How to proceed further? Your suggestion will be highly appreciated...
    Thanks in Advance,
    RealStuff, Mike

    String s = "Less than 20";
    while(s.length() < 20) {
         s += " ";
    System.out.println(s + " " + s.length());Mark

  • Java.lang.Exception: DEBUG

    Hi,
    Can you please tell the significance of these error message coming in the weblogic logs.
    java.lang.Exception: DEBUG
    at weblogic.transaction.internal.ServerResourceInfo.setState(ServerResourceInfo.java:281)
    java.lang.Exception: DEBUG
    at weblogic.transaction.internal.TransactionImpl.setState(TransactionImpl.java:1682)
    java.lang.Exception: DEBUG
    at weblogic.transaction.internal.SCInfo.setState(SCInfo.java:59)
    ####<Mar 11, 2011 11:53:03 PM PST> <Debug> <JTAXAStackTrace> <dssoptperftest> <BPMServer> <BPM Directory Polling> <<anonymous>> <BEA1-002E212D6D278FAF9E64> <> <1299916383609> <BEA-000000> <java.lang.Exception: DEBUG: Xid=BEA1-002E212D6D278FAF9E64(13480230),Status=Active,numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=0,seconds left=30,activeThread=Thread[BPM Directory Polling,5,Pooled Threads],XAServerResourceInfo[XAFDIDS]=(ServerResourceInfo[XAFDIDS]=(state=started,assigned=none),xar=XAFDIDS,re-Registered = false),SCInfo[TOCDLC+BPMServer]=(state=active),local properties=({weblogic.jdbc.jta.XAFDIDS=[autoCommit=true,enabled=true,isXA=true,isJTS=false,vendorID=0,connUsed=true,doInit=false,'null',destroyed=false,poolname=XAFDIDS,appname=null,moduleName=null,connectTime=31,dirtyIsolationLevel=false,initialIsolationLevel=2,infected=false,lastSuccessfulConnectionUse=1299916383578,secondsToTrustAnIdlePoolConnection=10,currentUser=null,currentThread=null,lastUser=null,currentError=null,currentErrorTimestamp=null,JDBC4Runtime=true,supportStatementPoolable=true,needRestoreClientInfo=false,defaultClientInfo={}], weblogic.jdbc.jta.XAbpmengineDS=[autoCommit=true,enabled=true,isXA=true,isJTS=false,vendorID=0,connUsed=true,doInit=false,'null',destroyed=false,poolname=XAbpmengineDS,appname=null,moduleName=null,connectTime=31,dirtyIsolationLevel=false,initialIsolationLevel=2,infected=false,lastSuccessfulConnectionUse=1299916331266,secondsToTrustAnIdlePoolConnection=10,currentUser=null,currentThread=null,lastUser=null,currentError=null,currentErrorTimestamp=null,JDBC4Runtime=true,supportStatementPoolable=true,needRestoreClientInfo=false,defaultClientInfo={}]}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=BPMServer+192.168.1.128:80+TOCDLC+t3+, XAResources={XAbpmengineDS, WLStore_TOCDLC__WLS_BPMServer, XAFDIDS},NonXAResources={})],CoordinatorURL=BPMServer+192.168.1.128:80+TOCDLC+t3+) XA.start(rm=XAbpmengineDS), xar=XAbpmengineDS, flags=TMNOFLAGS)
    at weblogic.transaction.internal.TxDebug.debugStack(TxDebug.java:60)
    Edited by: 820097 on Mar 15, 2011 9:58 AM

    Any clue about why this error would occur?

  • Mapping using Java Coding

    I've got a big trouble. First, I'm trying to do mapping using Java Coding based on the TopLink Developer's Guide.
    I'm using a Employee's Table as usual, but here is the problem, I can not do inserting on the database after I do mapping. As a note, there is no error compile and also I can do the session login already.
    Employee.java
    public class Employee extends oracle.toplink.sessions.Project{
         private Long id;
         private String fnama;
         private String lnama;
    public Employee() {
    setName("ObjectTab");
    applyLogin();
    addDescriptor(empDesc());
    conformAllDescriptors();
    public String getFnama() {
         return this.fnama;
    public String getLnama() {
         return this.lnama;
    public void setFnama(String fnama) {
         this.fnama = fnama;
    public void setLnama(String lnama) {
         this.lnama = lnama;
    public void applyLogin() {
    DatabaseLogin login = new DatabaseLogin();
    // use platform appropriate for underlying database
    login.usePlatform(
    new oracle.toplink.platform.database.oracle.Oracle9Platform());
    login.setDriverClassName("oracle.jdbc.OracleDriver");
    login.setConnectionString("jdbc:oracle:thin:localhost:1521:pusat");
    login.setUserName("tryo");
    login.setEncryptedPassword("a, ENCRYPTED");
    // Configuration Properties
    setDatasourceLogin(login);
    public ClassDescriptor empDesc() {
    ObjectRelationalDescriptor descriptor = new ObjectRelationalDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setTableName("EMPLOYEES");
    descriptor.setStructureName("EMPLOYEE_T");
    descriptor.setPrimaryKeyFieldName("ID");
    descriptor.addFieldOrdering("ID");
    descriptor.addFieldOrdering("F_NAME");
    descriptor.addFieldOrdering("L_NAME");
    descriptor.addDirectMapping("id", "OBJECT_ID");
    descriptor.addDirectMapping("fnama", "F_NAME");
    descriptor.addDirectMapping("lnama", "L_NAME");
    return descriptor;
    Main Class:
    protected String getSessionsXmlPath() {
    return "sessions.xml";
    protected String getSessionName() {
    return "Session";
    protected void createSession() {
    XMLSessionConfigLoader loader = new XMLSessionConfigLoader(getSessionsXmlPath());
    SessionManager mgr = SessionManager.getManager();
    session = (DatabaseSession)mgr.getSession(loader, getSessionName(), Thread.currentThread().getContextClassLoader(), true, true);
    public static void closeSession(){
    SessionManager.getManager().destroyAllSessions();
    session = null;
    private void jButton1_actionPerformed(ActionEvent e) {
    Employee myEmp = new Employee();
    createSession();
    private void jButton2_actionPerformed(ActionEvent e) {
    Employee theEmp = new Employee();
    UnitOfWork uow = session.acquireUnitOfWork();
    try{
    theEmp.setFnama("A");
    theEmp.setLnama("B");
    uow.commit();
    }finally{
    uow.release();
    For everybody who already knows the solution, please reply as soon as possible. Because I really need this solution to finish my last final project.
    Thanks

    When you create a new instance you must register it with the UnitOfWork in order to have the new entity persisted.
    Employee theEmp = new Employee();
    UnitOfWork uow = session.acquireUnitOfWork();
    theEmp.setFnama("A");
    theEmp.setLnama("B");
    uow.registerObject(theEmp);
    uow.commit();
    Doug

  • Java coding in combo box

    how to call the set of java coding by using combo box................

    Siva,
    Try avoiding opening different threads for the same questions...
    Combox Box date format
    You can use the option Edit/Reply to update your thread..
    -Anil

  • Possible to access bean property without Java Bean conventions?

    Hello,
    I'd like to show a component whenever there is an error message in the Faces context. Naively, I set the component's "rendered" attribute to the following:
    rendered="#{facesContext.messages.hasNext}"
    The object returned by facesContext.messages is an iterator, the properties of which do not follow Java Bean naming conventions. If there was a method called getHasNext() then all would be well. However as it stands, EL cannot evaluate this expression.
    I realise that wrapping this up in a managed bean would solve the problem, but I'd like to avoid this if I am able to do this directly from EL.
    Cheers,
    Chris

    Hi Juergen,
    hasNext actually returns a boolean which EL understands fine. In the end I just wrapped the call within a managed bean, as you suggested, and this works a treat:
      public boolean getHasMessages() {
        // hasNext will return true if there are any messages to be displayed
        return FacesContext.getCurrentInstance().getMessages().hasNext();
      }I suppose I felt compelled to post this entry since I found myself having to write some code for an expression that could be written perfectly well in EL but was limited only by the fact that EL can only access properties that follow the Java Bean convention.
    I thought that may have been some qualifier or method wrapper I could have used to mean 'take this property name literally'. Alas, it seems no such faclility exists.
    Thanks for taking the time to reply,
    Chris.

  • Java coding in CAF

    hi  experts,
    i went through lot of blogs and docs on SDN regarding how to compose services and consume services, export RFC etc.,. In some of the scenarios we needed to write some code in java. I am pretty much new to java even though i know basic java. what is the best way to learn what kind of java code i need to write when i create some CAF. is there any how-to-doc explaining most used java code in CAFs?
    thanks
    sankar

    Hi Sankar!
    I am not sure, what you are searching for. However, I will try to explain the CAF a little bit.
    Basically, a composite application consists of business objects and (entity and application) services.
    A business object represents a logical data structure your application is aiming at (e.g., customer, sales order). For each business object you get an entity service which operationes represent the fundamental database operations such as create, read, update, delete, and a number of find operations.
    On top of the entity services of your composite application you can model and implement application services. The operations of the application services represent the business logic of your application. These operations are where your Java coding comes into play.
    Finally, you can expose some of your application services as web services which can then be externally invoked.
    Best regards
    Alexander

Maybe you are looking for

  • I use iTunes 11.1.3 and books is not listed in preferences.  I want to add a pdf file into ibooks.

    Hello:   I use iTunes 11.1.3 and under preferences,  books is not listed as an option.  I am trying to add a pdf file to ibooks.

  • Parameter memory not initializing whwn re execute the program

    I have used parameter memory in  selection screen  of module pool program, The problem is when I exit from the program and re execute the transaction the parameter memory not initializing and the same value come again in the selection screen .

  • Empty Events

    Man, this is the crappiest upgrade Apple has ever put out. I've solved a lot of issues by rebuilding the library, fixing permissions, etc. Importing photos is still flakey, and I've had to rebuild the library many times just to get newly imported pho

  • Lost CVS when upgrading to 9.0.3.1

    I have upgraded to 9.0.3.1 by installing it in a new directory. I enables CVS and created a new CVS connection in the new IDE and opened the workspaces I was using previously. No CVS menu options are available in the context menu (except Editor and T

  • How to call VXIplugNplay driver from Labview

    I downloaded a VXIplugNplay driver from Tektronics but I can't find any documentation on how to implement and use from Labview