Code Conventions

Hi All,
being a complete Java(TM) newbie here is a very silly question.
After reading the "Java Code Conventions" (see http://java.sun.com/docs/codeconv/)
and studying here and there the Java core library source code (see src.zip
on your SDK installation) I was wondering what the heck is the characters
sequence @(#) behind the file class name in the header comment.
You can see it in all classes' source code and in paragraph 11.1 of the
aforementioned JCC. For example,
* @(#)WhatIsIt.java 1.82 04/09/02
* Copyright [...]
All the best

It is some kind of a marker for the source code control system that Sun uses. When you make changes to the file the system knows to update the revision number ("1.82") and the modification date ("04/09/02") automatically thanks to the presence of "@(#)".
I think Sun uses a system called SCCS; you'd write something else.if you used RCS or CVS for instance.

Similar Messages

  • Check code conventions

    Anyone seen or have any ideas about using javadoc to check code for code conventions compliance? I read about use of it to report source where variables are not declareed private (http://www.smotricz.com/kabutz/Issue035.html) - it might be interesting to apply this to other conventions such as variable and method naming.

    No ideas here. We have a DocCheck doclet, but that checks only doc comments, not the
    code itself: http://java.sun.com/javadoc/doccheck
    A doclet based on javadoc 1.3.x could only check the declarations of code and not its
    implementation, because it does not have access to the implementation through the
    Doclet API. With 1.4, the Doclet API gives the source position (file, line number) of the
    code, which a doclet could then access and check the implementation.
    -Doug Kramer
    Javadoc team

  • Some notes about Java code conventions

    Hello!
    I read the book "Java Code Conventions". It' good conventions but I have some notes Here is my offer
    1.Classes's names start with "C", e.g.
    CMain, CFileTool.
    2.Interfaces's names start with "I", e.g.
    IObserver, IDigitalListener.
    3. Exceptions's names startw with "E", e.g.
    EMyException
    4.Member objects variables start wiht "m_obj". Not member objects variables (local objects variables) start with "obj" respectively, e.g.
    public class CMain {
    private CText m_objText = new CText(); //my class CText
    private void anyMethod() {
    CText objText = new CText();
    5. Vector member variable start with "m_vec" Not member vector variable start with "vec" respectively. Hashtable member variable start with "m_hash".Not member hashtable variable start with "hash" respectively, e.g
    private Vector m_vecElements = new Vector();
    private Hashtable m_hashElements = new Hashtable();
    private void anyMethod() {
    Vector vecElements = new Vector();
    Hashtable hashElements = new Hashtable();
    6. String member variable start with "m_str". Not member string variable start with "str" respectively, e.g.
    private String m_strText = new String();
    private void anyMethod() {
    String strText = new String();
    7. Primitive types starts with "n", "b" and so on. , e.g.
    int nIndex = 4
    boolean bIsCorrect = true
    char cSymbol = 'a'
    float fNumber = 3
    double dNumber = 1.2
    long lNumber=1
    short sNumber=2
    and respectively it's classes start as section 4, e.g
    Integer objIndex = new Integer(nIndex)
    Boolean objIsCorrect = new Boolean(bIsCorrect)
    and so on
    The main idea on my convention is when somebody will look at , e.g. object he at once should understand about what there is this object, and not scrolling java file to understand this.
    It will be pleasant for me to receive your answers.Thank you

    Vector member variable start with "m_vec" Not member vector variable start with "vec" respectively. Hashtable member variable start with "m_hash".Not member hashtable variable start with "hash" respectivelyThere are over 2000 classes in the 1.4 SDK. You need to extend this rule to cover all of them, don't you? For examples, GraphicsConfigTemplate member variables must start with "m_graphicsconfigtemplate"...

  • Where have the code conventions gone?

    The java code conventions used to be reachable from Code Conventions for the Java Programming Language: Contents. It seems that these pages have been moved because all the links now return a 404 page not found error when clicked. Does anybody know the new address of the code conventions?

    jwenting wrote:
    your fallacy is in assuming that "old == bad". If the original was good there's no real need to touch it (and IMO it was good).
    Maybe add a few sections explicitly making statements relating specifically to things like generics and lambdas, but most of that can be derived easily enough from what's in there as is).
    I'm equalling old with "may be outdated" but I leave it to Oracle to decide if so and when to update. But if Oracle has decided now is the time then my guess is that Java 8 has a lot to do with it.
    But maybe I shouldn't have posted an opinion so I withdraw my guess. Happy?

  • Code Convention for Swing

    Can Anyone please point to a document or site which has information
    about Naming or Code Conventions on SWING.
    There are lot of documents for J2EE ,JSP and JMS naming conventions,
    but could not find anything on SWING.
    Any Help would be greatly appriciated.

    "Code Conventions for the Java Programming Language" is found at
    http://java.sun.com/docs/codeconv/index.html. Swing is no exception to these recommendations.

  • Good Practices and Code Conventions

    Hi All,
    What are the good practices in java? Are there coding convention to be followed?
    I would like to improve my coding standards and write better code. Please help me.
    Thanks
    Diana

    Diana12 wrote:
    Then how to make it excellent?Are you serious? Do you expect us to give you a 2-line summary of how to make "excellent" code?
    It takes some time to learn to write excellent code and it can't easily be summarized into 1-2 sentences. If it could, then it would be much easier to learn (that would be nice!).
    Experience, making mistakes, realizing they were mistakes, not making the same mistakes later on. Having your code criticized by someone who writes better code than you. That's how you learn to write excellent code.
    Write simple code, keep it clean, make each method do one thing, write code that doesn't need documentation, document where you must, adhere to the open-close principle, adhere to the KISS principle, adhere to the YAGNI principle, ...
    Grab [The Pragmatic Programmer|http://www.pragprog.com/the-pragmatic-programmer] and read it. Then read it again. Do some more exercises and read it a third time.

  • JSP 1.x Code Conventions - Open Discussion

    This morning, we posted a draft set of recommendations on Coding Conventions for the JavaServer PagesTM Version 1.x Language. The article can be found here:
    http://developer.java.sun.com/developer/technicalArticles/javaserverpages/code_convention/
    The article is intended to be a first draft of coding conventions, and we're getting some great, high-quality feedback on our comments alias, [email protected] Keep 'em coming!
    This alias is one-way only (from you to us), and we'd love to see a more collaborative feedback forum as well. I've started this topic as a place so that users can discuss and share their experiences with JSP coding conventions, as used in their organizations.
    Please continue to send feedback to [email protected] as well!
    Mark Roth, Java Software
    Specification Co-Lead of JSP 2.0
    Sun Microsystems, Inc.

    The JSP guidelines suggest that
    "Indentations should be filled with space characters. Tab characters cause different interpretation in the spacing of characters in different editors and should not be used for indentation inside a JSP."
    It is a simple observation that using spaces instead of tab characters increases the returned content length. While this may seem insignificant, in my opinion it is not. for example, checking the trivial table sample in the guideline:
    <table>
    <% if { tableHeaderRequired ) { %>
    <tr>
    <th>Last Name</th>
    <th>First Name</th>
    </tr>
    <% } %>
    <c:forEach var="customer" items="${customers}">
    <tr>
    <td><c:out value="${customer.lastName}"/></td>
    <td><c:out value="${customer.firstName}"/></td>
    </tr>
    </c:forEach>
    </table>
    using tabs in indentation results in 329 bytes of data, while using spaces results in 443 bytes, or about 35% more data! Testing on several real-world pages gave similar results. While this this certainly varies with content and coding style, following the indentation guidelines, which are extremely important for readability, will result in several indentation levels in an avarage line of nontrivial code, and an increase in data size of similar proportions. In my opinion this increase in traffic and processing is quite significant in a production server. Or, as I like to think of it, imagine an internet where all web servers were jsp-based, and that all web transactions were 35% slower...
    Finally, the stated reason that 'Tab characters cause different interpretation in the spacing of characters in different editors' doesn't seem like a very strong case. Developers who want to view JSP sources are most likely JSP developers, which should have their editors or IDEs set to 4-space tabs in the first place, as the guideline suggests. Perhaps some editors I'm not aware of don't allow these settings, which can cause the stated problem.
    I wonder if these consequences were taken into account when deciding on the guidelines.
    Other than that, I think the guidelines are great, and as with the other Java programming convention guidelines, I hope they reach widespread use and become standard developer practice, for the benefit of all.
    -Amichai

  • Sun's code conventions & Eclipse

    Has anyone ever found or made XML files I could import in Eclipse in order to comply to Sun's Java coding conventions (code formatter and code/comment templates) ? I could normally look for what I'm going to ask by googling, but we have limited access to the Internet at work so that I can't (stupid but it is so...). What's more, some of you might have made their own, which would not be publicly available on the web...
    Thanks in advance !

    s/going to ask/asking

  • Useless code in java.awt.image.SampleModel.java?

    Hey there,
    i just looked up the sourcecode of java.awt.image.SampleModel.java in JDK 6
    I discovered two issues i'd like to discuss.
    1) on lines 736 to 739 this code is stated:
    if (iArray != null)
    pixels = iArray;
    else
    pixels = new int[numBands * w * h];
    I asked myself, why does this code exist? while the getPixels() method is overwritten twice by double[] getPixels() and float[] getPixels, it is impossible to reach the part of the java code that initializes the pixels-array. One could only step into that line if "null" is given for the i/d/fArray-parameter. but if one would do so, the Java parser couldn't determine, which method is to use. so this part of code is just useless IMHO.
    the java developers could get a little more performance out of this method if the if statement would be cut out - especially when reading a lot of very small rasters
    or, on the other hand, they could replace this piece of code by an explicit bounds check.
    When somebody touches this code, i would appreciate it if the errormessage "index out of bounds!" could be rewritten to be a little more verbose, like: Index out of bounds(x=123; y=456, maxX=100, maxY=400)!(numbers are just examples)
    I hope i didn't miss something very basic and could help improving this class a little bit.
    2) the local variable Offset(line 734) is coded against code conventions which say, variables shall start with a lowercase letter. Offset obviously doesn't fit that convention.
    best regards
    kdot

    One could only step into that line if "null" is given for the i/d/fArray-parameter. but if one would do so, the Java parser couldn't determine, which method is to use. so this part of code is just useless IMHO. You can have
    sampleModel.getPixels(x,y,w,h,(int[]) null, dataBuffer);No ambiguity on which method to use.
    the local variable Offset(line 734) is coded against code conventions which say, variables shall start with a lowercase letter. Offset obviously doesn't fit that convention. You're correct, offset is against coding conventions. So are many other examples scattered throughout the jdk source code. For example, Hashtable should be called HashTable. In some cases the coding conventions might not have been established when the original code was written. In other cases it might have been human error. In yet other cases the conventions were probably ignored. The person who wrote the SampleModel class did so some 10+ years ago (Java 1.2). Who knows what he/she was thinking at the time, and in all honesty - does it really matter in this case?
    Did you know there are some classes that declare unused local variables (ahem ColorConvertOp)? Some also have unused imports ( *** cough *** BufferedImage *** cough *** ). In essence, the jdk source code is not the epidemy of code correctness. But it's still pretty good.

  • Conventions for XML-files

    Hi!
    I'm working on the text of a Bible translation that will be quite an extensive file when it's finished. The publisher has requested that I make an XML file in addition to the print-ready inDesign files they will use themselves. This is because there will be other publishers and companies that will want to use their translation (or parts of it) and it's inconvenient to send them inDesign files. An XML file with all of the paragraph styles, character styles and footnotes would be more convenient.
    Now, I've been trying to find information on how such a XML should look. Are there any code conventions for it? Most of the issues on this forum concerns importing xml files for use in indesign - but what I'm wondering is what I must think of when exporting XML files that other people will use?
    Also, is it possible to create inline xml tags based on character styles? (Such as bold, italic, suberscript etc.)
    I'm using CS6 and Mac OS X Lion.
    EDIT: Another thing just struck me. If anyone thinks that XML is not the best format for this then I'd very much like to hear about any other suggestions.

    InDesign has a native "Export XML" option, but that requires that you tag each separate item as an "XML item". Some of this can be automated, using "Map Styles to Tags". I don't have any experience with it, positive or negative, but if you exclusively used paragraph and character styles to layout your text it should be straightforward.
    Fastest way to get re-usable text in a not too difficult to parse file format is to export as Tagged Text. It's not really proper XML, but it may be Close Enough; if the above route is too complickated, try this (and send your publisher a test file).
    SimonLinden wrote:
    I've been trying to find information on how such a XML should look. Are there any code conventions for it? Most of the issues on this forum concerns importing xml files for use in indesign - but what I'm wondering is what I must think of when exporting XML files that other people will use?
    There are no "conventions". XML itself only has some very basic requirements (the way of writing element and attribute tags, correct nesting, some special characters that may not be used in plain text; that sort of things). So you can make up your own set of tags, or, to not confuse your receiving party, use a well-known set of tags such as XHTML (ie., <p> is for Paragraph, <i> is for Italic, and so on) or DocBook. There are also Scripture specific schema's of XML; http://ebible.org/usfx/ is one found with a quick Google.

  • Class naming convention

    many a times i face difficulty with the Action/Class naming convention.
    Say, today ..i wrote a class.....tomorrow i have to rename the name of the class so that it becomes a more meaningful name and becomes unique and understandable with the newcomer classes.
    ...just to do this, i had to change the name of the class very frequently.
    Though i follow few conventions like :
    1) First letter of the class is Captial letter.
    2) use names which is relevant with the classs's functionality.
    but still i fall in problem....
    say, i want to populate a DataBase with my class.....whats the name i should keep ? tommorrow i am going to write another class which also populate the database . what do i do ?
    i first rename the old class with some meaningful name and then i write the new class with some other meaningful name.....but this kills time.....demands lots of changes....and so on...
    you know, i get trouble when my number of classes increases.
    do u feel the same ?
    what are the rules (NOT JAVA RULES but meaningful rules) i should remember to keep a class name ?

    You can name a class based on what it supposed to
    do...
    while naming it follow conventions like the ones
    which are mentioned in the code
    conventions/guidelines of your project.
    You will not be writing the same functionality in two
    different classes... would you??
    In case you may need to refractor(rename the class
    name) you may use java editor with refractoring
    capability to do it..
    With most of the java editors, you get this
    functionality.. e.g. doing a Alt+Shift+R would
    refractor your selected method, class, field etc...
    This applies to Eclipse
    >
    Hope that helps..
    Vaibhav

  • Code generation using Visual cafe

    I'm using visual cafe for GUI development. It includes it's own libraries though the equivalent ones are available in JDK.
    For example: to place a component in GRid Bag layout it generates code with symantec's constructor
    new com.symantec.itools.awt.GridBagConstraintsD(,...) instead of java.awt.GridBagContraints(,...) constructor.
    Is there any way to tell Visualcafe to use jdk instead of it's own libraries when applicable? let me know if anyone knows how to do this?
    thanks,
    sampath

    The simple answer is NO, or its not simple nor reliable.
    The unsolicited answer is; stop using that garbage. I used it for 4 years. Symantec completely dropped the ball. I use the free Jbuilder version. It uses ALL official classes and does NOT force you into code conventions, nor does it complain about many things. VC has its own private section in the code where you can not manually edit it. headache. VC does geenrate much less anonymous classes, but all in all, try JBuilder. Maybe even Forte as I hear good things about that too.
    When I converted to JBuilder, I simply changed the symanted gridbag class into the sun gridbag class. In general the symantec class is EXACTLY the same, but symantec was ahead of its time, and needed to make its own classes in order to have the GUI editing since sun didnt have completel beans available at the time. But sun has not privided these beans for years, and still symantec has not adapted. I think they are arrogant now and hope this keeps you forced into their IDE since changing seems hard(though "replace" works just fine in these situations)...

  • Interface naming convention - HasA relationship

    Hi all,
    I have been wondering from time to time how to name interfaces that declare a "has-a" relationship.
    Let's consider this:
    I have a class - Company - it has many things a company can have.
    Now I have Deal, Invoice, Document, Shipment and other classes that can have a Company as their property. I want to be able to ask every one of them to tell me their Company.
    How to name the interface that will have this method:
    public interface Company...{
       public Company getCompany();
    }Somehow I don't feel comfortable with Companyable, on the other hand HasACompany is no good because sooner or later I will end up with lots of HasASomething interfaces.
    I searched around, read some code convention guidelines, found some threads about naming interfaces (like http://forum.java.sun.com/thread.jspa?forumID=31&threadID=495341), but still I have no solution.
    Please guide me in choosing the proper convention for naming such interfaces in the future
    Mike

    Dave, you are right, my example was no good.
    I also agree that it is not good to mix usage cases. It is also true that in most cases I have hierarchies that have some common usage of a company and I can tell why they have a company. But I don't want to have several interfaces, all of which provide access to the same property but with different names.
    What I would like to achieve is something that is close to the OpenOffice services concept. In OpenOffice you can query some object for some interface and if the service is provided you can get implementing instance.
    I am not quite sure but you can get XWindow from document, or from an internal frame, or who knows from what else.
    What I want to achieve is to say "Something that has this certain property" without caring beforehand why I want to know this.
    On the other hand I cannot prove that the design is "correct". I am just curious how an interface that describes a certain service/property would be named in a good way.
    Thanks for info
    Mike

  • Implementation of Oracle Coding Standards and Code Quality Checks

    I wanted to implement a list of coding standards and code quality checks for my oracle packages,functions,views,tableetc .
    for example
    All variables with number datatype should start with N_ and charcter type with C_ in all my tables & views definition.
    This can be identified during peer review & can be corrected, but i think this is a repeated process which i don want to burden the developers rather i wanted a tool which does all these kind of checks which can be automated.
    Is there any tool which does this operation or can someone give me a little idea how can i automate these stuffs bu creating a generic oracle procedure which can run through all the tables,views and generate a error report for those which are deviating from the standards.
    Thus we can reduce the manual effort spent on peer review, please suggest.
    thanks in advance

    maru wrote:
    I wanted to implement a list of coding standards and code quality checks for my oracle packages,functions,views,tableetc .
    for example
    All variables with number datatype should start with N_ and charcter type with C_ in all my tables & views definition.Hungarian notation is dead. It has no place in modern programming languages. Has no place in PL/SQL. Anit ain't just me saying that.
    +"Encoding the type of a function into the name (so-called Hungarian notation) is brain damaged—the compiler knows the types anyway and can check those, and it only confuses the programmer."+
    Linus Torvalds
    +"No I don't recommend 'Hungarian'. I regard 'Hungarian' (embedding an abbreviated version of a type in a variable name) a technique that can be useful in untyped languages, but is completely unsuitable for a language that supports generic programming and object-oriented programming—both of which emphasize selection of operations based on the type an arguments (known to the language or to the run-time support). In this case, 'building the type of an object into names' simply complicates and minimizes abstraction."+
    Bjarne Stroustrup
    2) Conditional Statements
    IF (x = 1) --> Wrong
    IF ((x = 1) AND (y = 2)) --> wrong
    IF x = 1 AND y = 2 --> RightIdiotic rules. The simple rule should be readability of code. Not how many brackets to use, and when not to use brackets. Minute standards like detracts from designing and writing proper code, fast and efficiently.
    There are many more rules (which is specific to ur application) which can be incorporated in the tool, there by giving consistency ,readability and easy to maintain for the developers.Bull. The more rules there are, the more difficult it becomes for programmers to write code. As it is no longer about writing readable and flexible and performing code - it is about double checking every single statement line against a huge list of rules about do's and dont's. It is not about getting the programmer focusing on solving the problem - it is about distracting the programmer with a complex and large rule list of how the code should look like.
    Sorry - but this rubs me the wrong way. In that environment, I would be the first to tell you to shove your "+many more rules+".
    I've developed systems in over a dozen languages over the years. I've seen all kinds of standards. The standards that work are those that are short, simple and sensible. Hungarian notation is not sensible. Writing reserved words in uppercase is not sensible. Dictating how brackets should be used is not sensible.
    What is sensible is using the de facto naming standards in use today - as per .Net Guidelines for Names (MSDN) and Code Conventions for the Java Programming Language.
    What is sensible is providing guidelines like bulk collection needs to be justified (not possible using SQL only) and use the limit clause to manage memory spend on the collection variable. Or how packages need to be used to modularise code, providing a public interface and private implementation.
    Standards are about creating a sensible and easy-to-use framework for writing code. It is not about creating a list of a 1001 rules that a developer needs to remember and adhere to, as if the developer is now part of some weird religious sect that has rules for every single aspect of human behaviour.

  • JDeveloper code re-formatting: configuration

    I adjusted the right margin in my editor view so as to not have long code lines wrap to early.
    Alas, whenever I run the Reformat (CTRL-ALT-L) command, it completely ignores my adjusted right margin and re-wraps all lines, making my code unreadable (by me).
    Is there a way to adjust the parameters used by the Reformat command?
    Thanks
    Jan

    Hi,
    the margin appears to be a display thing only, not a rule. To achieve what you want, choose
    1. Preferences
    2. Code Editor
    3. Code Style
    4. Select Java Code Conventions
    5. Press Edit
    6. Expand Line Wrapping
    7. Change Line Width (80) property
    Note that the value of 80 is what usually fits on a printed page (just in case you need to print it to some point in time)
    Frank

Maybe you are looking for

  • K7T Turbo Limited Edition

    Ok, i have 3 dimm slots for ram on my Mobo, i had 2 sticks of 128 megs. I just bought a stick of 512. Before this i had no need to use the 3rd slot, now i need to, when trying to use all 3 whenever i put any size of ram in the 3rd my computer will cr

  • Profit Center Derivation in AuC Line Item

    Hi Team, We have Investment Profile configured, where in AuC gets automatically created in background with WBS Release. Step 1: While settlement from WBS to AuC, Profit Center remains blank under Entry View for AuC Line (GL View = Inheritance from th

  • Is there anyway to shutdown from Terminal

    My aging G5 running Leopard is hanging up at random times. Up to now, I have had to shut down the machine by pushing and holding the power switch. I know this is a bad thing to do, but I do not know any other way. Is there any special set of keystrok

  • Date Format in dd-mm-yy in system preferences

    Hi, I am new to Mac - I was trying to change the system date as dd-mm-yy. Unfortunately not, I've changed the system preferences to my local language - but that didn't work. Kindly note that I need this for all my applications viz. Excel, Outlook etc

  • Script to auto kern after typing

    Hello all !  I am curious is it feasible to create a script that will automatically kern specific letter pairings after typing them? I've been scouring the forum and found something like it here Scripted custom kerning tables | Peter Kahrel.   What I