Search Results

Search found 1399 results on 56 pages for 'naming'.

Page 10/56 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • C: What is a good source to teach standard/basic code conventions to someone newly learning the language ?

    - by shan23
    I'm tutoring someone who can be described as a rank newcomer in C. Understandably, she does not know much about coding conventions generally practiced, and hence all her programs tend to use single letter vars, mismatched spacing/indentation and the like, making it very difficult to read/debug her endeavors. My question is, is there a link/set of guidelines and examples which she can use for adopting basic code conventions ? It should not be too arcane as to scare her off, yet inclusive enough to have the basics covered (so that no one woulc wince looking at the code). Any suggestions ?

    Read the article

  • Intentional misspellings to avoid reserved words

    - by Renesis
    I often see code that include intentional misspellings of common words that for better or worse have become reserved words: klass or clazz for class: Class clazz = ThisClass.class kount for count in SQL: count(*) AS kount Personally I find this decreases readability. In my own practice I haven't found too many cases where a better name couldn't have been used — itemClass or recordTotal. However, it's so common that I can't help but wonder if I'm the only one? Anyone have any advice or even better, quoted recommendations from well-respected programmers on this practice?

    Read the article

  • Examples of bad variable names and reasons [on hold]

    - by user470184
    I'll start with a class in the jdk package : public final class Sdp { should be : public final class SocketsDirectProtocol { Sdp is class name, this is ambigious, should be : Class<?> cl = Class.forName("java.net.SdpSocketImpl", true, null); should be : Class<?> clazz = Class.forName("java.net.SdpSocketImpl", true, null); cl is ambiguous private static void setAccessible(final AccessibleObject o) { should be : private static void setAccessible(final AccessibleObject accessibleObject) { There are various other examples in this class, do you have similar and/or differing examples of variables that were named badly ? package com.oracle.net; public final class Sdp { private Sdp() { } /** * The package-privage ServerSocket(SocketImpl) constructor */ private static final Constructor<ServerSocket> serverSocketCtor; static { try { serverSocketCtor = (Constructor<ServerSocket>) ServerSocket.class.getDeclaredConstructor(SocketImpl.class); setAccessible(serverSocketCtor); } catch (NoSuchMethodException e) { throw new AssertionError(e); } } /** * The package-private SdpSocketImpl() constructor */ private static final Constructor<SocketImpl> socketImplCtor; static { try { Class<?> cl = Class.forName("java.net.SdpSocketImpl", true, null); socketImplCtor = (Constructor<SocketImpl>)cl.getDeclaredConstructor(); setAccessible(socketImplCtor); } catch (ClassNotFoundException e) { throw new AssertionError(e); } catch (NoSuchMethodException e) { throw new AssertionError(e); } } private static void setAccessible(final AccessibleObject o) { AccessController.doPrivileged(new PrivilegedAction<Void>() { public Void run() { o.setAccessible(true); return null; } }); } /** * SDP enabled Socket. */ private static class SdpSocket extends Socket { SdpSocket(SocketImpl impl) throws SocketException { super(impl); } } /** * Creates a SDP enabled SocketImpl */ private static SocketImpl createSocketImpl() { try { return socketImplCtor.newInstance(); } catch (InstantiationException x) { throw new AssertionError(x); } catch (IllegalAccessException x) { throw new AssertionError(x); } catch (InvocationTargetException x) { throw new AssertionError(x); } } /** * Creates an unconnected and unbound SDP socket. The {@code Socket} is * associated with a {@link java.net.SocketImpl} of the system-default type. * * @return a new Socket * * @throws UnsupportedOperationException * If SDP is not supported * @throws IOException * If an I/O error occurs */ public static Socket openSocket() throws IOException { SocketImpl impl = createSocketImpl(); return new SdpSocket(impl); } /** * Creates an unbound SDP server socket. The {@code ServerSocket} is * associated with a {@link java.net.SocketImpl} of the system-default type. * * @return a new ServerSocket * * @throws UnsupportedOperationException * If SDP is not supported * @throws IOException * If an I/O error occurs */ public static ServerSocket openServerSocket() throws IOException { // create ServerSocket via package-private constructor SocketImpl impl = createSocketImpl(); try { return serverSocketCtor.newInstance(impl); } catch (IllegalAccessException x) { throw new AssertionError(x); } catch (InstantiationException x) { throw new AssertionError(x); } catch (InvocationTargetException x) { Throwable cause = x.getCause(); if (cause instanceof IOException) throw (IOException)cause; if (cause instanceof RuntimeException) throw (RuntimeException)cause; throw new RuntimeException(x); } } /** * Opens a socket channel to a SDP socket. * * <p> The channel will be associated with the system-wide default * {@link java.nio.channels.spi.SelectorProvider SelectorProvider}. * * @return a new SocketChannel * * @throws UnsupportedOperationException * If SDP is not supported or not supported by the default selector * provider * @throws IOException * If an I/O error occurs. */ public static SocketChannel openSocketChannel() throws IOException { FileDescriptor fd = SdpSupport.createSocket(); return sun.nio.ch.Secrets.newSocketChannel(fd); } /** * Opens a socket channel to a SDP socket. * * <p> The channel will be associated with the system-wide default * {@link java.nio.channels.spi.SelectorProvider SelectorProvider}. * * @return a new ServerSocketChannel * * @throws UnsupportedOperationException * If SDP is not supported or not supported by the default selector * provider * @throws IOException * If an I/O error occurs */ public static ServerSocketChannel openServerSocketChannel() throws IOException { FileDescriptor fd = SdpSupport.createSocket(); return sun.nio.ch.Secrets.newServerSocketChannel(fd); } }

    Read the article

  • "A", "an", and "the" in method and function names: What's your take?

    - by Mike Spross
    I'm sure many of us have seen method names like this at one point or another: UploadTheFileToTheServerPlease CreateATemporaryFile WriteTheRecordToTheDatabase ResetTheSystemClock That is, method names that are also grammatically-correct English sentences, and include extra words purely to make them read like prose. Personally, I'm not a huge fan of such "literal" method names, and prefer to be succint, while still being as clear as possible. To me, words like "a", "an", and "the" just look plain awkward in method names, and it makes method names needlessly long without really adding anything useful. I would prefer the following method names for the previous examples: UploadFileToServer CreateTemporaryFile WriteOutRecord ResetSystemClock In my experience, this is far more common than the other approach of writing out the lengthier names, but I have seen both styles and was curious to see what other people's thoughts were on these two approaches. So, are you in the "method names that read like prose" camp or the "method names that say what I mean but read out loud like a bad foreign-language-to-English translation" camp?

    Read the article

  • Test descriptions/name, say what the test is? or what it means when it fails?

    - by xenoterracide
    The API docs for Test::More::ok is ok($got eq $expected, $test_name); right now in one of my apps I have $test_name print what the test is testing. So for example in one of my tests I have set this to 'filename exists'. What I realized after I got a bug report recently, and realized that the only time I ever see this message is when the test is failing, if the test is failing that means the file doesn't exist. In your opinion, do you think these $test_name's should say what the test means if successful? what it means if it failed? or do you think it should say something else? please explain why?

    Read the article

  • Case convention- Why the variation between languages?

    - by Jason
    Coming from a Java background, I'm very used to camelCase. When writing C, using the underscore wasn't a big adjustment, since it was only used sparingly when writing simple Unix apps. In the meantime, I stuck with camelCase as my style, as did most of the class. However, now that I'm teaching myself C# in preparation for my upcoming Usability Design class in the fall, the PascalCase convention of the language is really tripping me up and I'm having to rely on intellisense a great deal in order to make sure the correct API method is being used. To be honest, switching to the PascalCase layout hasn't quite sunk in the muscle memory just yet, and that is frustrating from my point of view. Since C# and Java are considered to be brother languages, as both are descended from C++, why the variation in the language conventions? Was it a personal decision by the creators based on their comfort level, or was it just to play mindgames with new introductees to the language?

    Read the article

  • How should compound words be handled when coding? Is there a definitive list of compound words? [closed]

    - by Ray
    QUESTION: How should you handle compound words when programming? Are there any good lists available online for developers of generally accepted technology-related compound words? I can see how this is highly ambiguous, so should I just use common-sense? EXAMPLE: I would be inclined to do this: filename NOT FileName or login NOT LogIn However, the microsoft documentation indicates that filename is not compound. So I wonder, is there a more definitive source? See also, this english.stackexchange discussion on filename. Under the section "Capitalization Rules for Compound Words and Common Terms" located here: Microsoft .NET Capitalization Conventions only offers a limited introduction into the topic, and leaves it up to the developer to use their intuition with the rest.

    Read the article

  • Is it bad practice to use the same name for arguments and members?

    - by stijn
    Sometimes I write constructor code like class X { public: X( const int numberOfThingsToDo ) : numberOfThingsToDo( numberOfThingsToDo ) { } private: int numberOfThingsToDo; }; or in C# class X { public X( int numberOfThingsToDo ) { this.numberOfThingsToDo = numberOfThingsToDo; } private int numberOfThingsToDo; } I think the main reason is that when I come up with a suitable member name, I see no reason to use a different one for the argument initializing it, and since I'm also no fan of using underscores the easiest is just to pick the same name. After all it's suitable. Is this considered bad practice however? Any drawbacks (apart from shooting yourself in the foot when forgetting the this in C#)?

    Read the article

  • Why it is called "hash table", or "hash function"? Hash doesn't make any sense to me here

    - by Saeed Neamati
    It's now about 4 years of development that I'm using, hearing, talking about, and implementing hash tables and hash functions. But I really never understand why it's called hash? I remember the first days I started programming, this term was kind'of cumbersome terminology to me. I never figured out what is it, based on its name. I just experimentally understood what it does and why and when should we use it. However, I still sometimes try to figure out why it's called hash. I have no problem with table or function and to be honest, they are pretty deductive, rational terms. However, I think better words could be used instead of hash, like key, or uniqueness. Don't key table or uniqueness table. According to my dictionary, hash means: Fried dish of potato and meats (highly irrelevant) # symbol (AKA number sign, pound sign, etc.) (still irrelevant, maybe just a mis-nomenclature) Apply algorithm to character string (still has nothing to do with uniqueness, which is the most important feature of a hash table) Cut food Another term for hashish Does anyone know why it's called hash?

    Read the article

  • What are good words for defining multiples?

    - by Scott Langham
    In databases you might take about one-to-many. This means there's one thing that maps to zero or more others. In this kind of style I'm looking for words that define min/max amounts of things. So far, I have: min max one 1 1 many 0 infinite optional 0 1 ??? 1 infinite Is there a single word that fits '???' to mean more than one? Do you have better alternatives for 'optional'? I'm wondering if there are any conventional names for those concepts?

    Read the article

  • Software bug/defect classification

    - by Dustin K
    We're trying to come up with terms that better describe our bugs/defects. To us, the term 'bug' or 'defect' is too generic and doesn't accurately reflect what is happening. For example, instead of saying that there is a bug (in the general sense), we'd rather say what type of bug (an error, or enhancement, or improvement, etc.). What names do you use for describing 'bugs'? We found http://www.softwaredevelopment.ca/bugs.shtml which has some pretty good classifications. How do you classify them?

    Read the article

  • C: What is a good source to teach standard/basic code conventions to someone newly learning the language?

    - by shan23
    I'm tutoring someone who can be described as a rank newcomer in C. Understandably, she does not know much about coding conventions generally practiced, and hence all her programs tend to use single letter vars, mismatched spacing/indentation and the like, making it very difficult to read/debug her endeavors. My question is, is there a link/set of guidelines and examples which she can use for adopting basic code conventions ? It should not be too arcane as to scare her off, yet inclusive enough to have the basics covered (so that no one woulc wince looking at the code). Any suggestions ?

    Read the article

  • What is the architectural name for the set of data that enables UI choices?

    - by Richard Collette
    I have separate service methods that fetch business object data and the data for UI selection input such as radio buttons, check-boxes, combo-boxes, etc. I want to name my service methods that fetch the selection data appropriately. I am assuming that Model and ViewModel would not be part of the name because the selection data is but a portion of the Model or ViewModel. What might this set of data be named such that I can name my service method?

    Read the article

  • Why are cryptic short identifiers still so common in low-level programming?

    - by romkyns
    There used to be very good reasons for keeping instruction / register names short. Those reasons no longer apply, but short cryptic names are still very common in low-level programming. Why is this? Is it just because old habits are hard to break, or are there better reasons? For example: Atmel ATMEGA32U2 (2010?): TIFR1 (instead of TimerCounter1InterruptFlag), ICR1H (instead of InputCapture1High), DDRB (instead of DataDirectionPortB), etc. .NET CLR instruction set (2002): bge.s (instead of branch-if-greater.signed), etc. Aren't the longer, non-cryptic names easier to work with?

    Read the article

  • How to define a natural id in database?

    - by gcc
    There are a lot of manuals. I am trying to create an database to hold information of these documents. But, there is a small problem. How can I give meaningful id to the manuals? Are there any standard or logic behind the giving meaningful id to the documents? If there is no standard, can you tell me how I should do that? example: table : manual id | manual name EDIT: Not Meaningful ID 1 or M1 or foo 2 C2 bar 3 P123 name ... ... ... (i) (ii) (iii) (i) Not meaningful for me because if some item deleted, there can be gap. ex 1 33 100. (ii) random character can be confusing when one try to give a name to new manual (iii) Why giving name is not preferred is because finding a name to the manual as ID is hard after 500 manuals. Meaningful : New ID * Can be easily produced even if after 1000 manuals * Should not be so complicated

    Read the article

  • How to name setter that does data conversion?

    - by IAdapter
    I'm struggling with how to name this method, I don't like the "set" prefix, because I feel it should be reserved for normal "dumb" setters and some tools might not like it (i did not check it in checkstyle, pmd, etc., but I got a feeling they won't like it.) for example (in java, but I feel its language agnostic) public void setActionListenerClicked(boolean actionListenerClicked) { this.actionListenerClicked = actionListenerClicked ? "1" : "0"; } The only purpose of this method is ONLY to set, this method is needed and cannot be joined with any other (because of framework used). P.S. I DO know that question is similar to How to name multi-setter?, but I feel its not the same question.

    Read the article

  • Tasks, jobs, activities, operations... which term to use when?

    - by Paul Stovell
    My application has a number of different asynchronous 'things' that it performs: There are things that fire off a schedule (every 5 minutes) There are things that are fired when a user clicks a button There are things that are triggered by an incoming web service call I use the terms like this: Scheduled things = Jobs User-triggered things = Tasks Web service-triggered things = Operations Tasks are quite complicated, so they're implemented using a hierarchy of different objects which I call Activities (operations and jobs may also begin to use these Activities as their building blocks). I feel like I might be using the wrong terms - for example, would you expect something that happens every 5 minutes automatically to be a Job or a Task? Is there an industry standard for this? All of the words seem to mean the same thing.

    Read the article

  • What is the benefit of not using Hungarian notation?

    - by user29981
    One of the things I struggle with is not using Hungarian notation. I don't want to have to go to the variable definition just to see what type it is. When a project gets extensive, it's nice to be able to look at a variable prefixed by 'bool' and know that it's looking for true/false instead of a 0/1 value. I also do a lot of work in SQL Server. I prefix my stored procedures with 'sp' and my tables with 'tbl', not to mention all of my variables in the database respectively. I see everywhere that nobody really wants to use Hungarian notation, to the point where they avoid it. My question is, what is the benefit of not using Hungarian notation, and why does the majority of developers avoid it like the plague?

    Read the article

  • How to name multi-setter?

    - by IAdapter
    I'm struggling with how to name this method, I don't like the "set" prefix, because I feel it should be reserved for normal "dumb" setters and some tools might not like it (i did not check it in checkstyle, pmd, etc., but I got a feeling they won't like it.) for example (in java, but I feel its language agnostic) public void setField1Field2(String field1, String field2) { this.field1 = field1; this.field2 = field2; } The only purpose of this method is ONLY to set, this method is needed and cannot be joined with any other (because of framework used).

    Read the article

  • How to name a static factory method in the utility class?

    - by leventov
    I have an interface MyLongNameInterface with a counterpart utility class MyLongNameInterfaces. What is the best name for a static factory method in the utility class, which creates an instance of MyLongNameInterface? MyLongNameInterfaces.newInstance() -- a new instance of the utility class? MyLongNameInterfaces.newMyLongNameInterface() -- too verbose MyLongNameInterfaces.create() -- create an instance of the utility class? Also, create is not a widely used conventional verb in Java better option?

    Read the article

  • How do you avoid name similarities between your classes and the native ones?

    - by Oscar
    I just ran into an "interesting problem", which I would like your opinion about: I am developing a system and for many reasons (meaning: abstraction, technology independence, etc) we create our own types for exchanging information. For instance: if there is a method which is called SendEmail and is invoked by the business logic, it way have a parameter of type OurCompany.EMailMessage, which is an object which is completely technology independent and contains only "business relevant data" (for instance, no information abut head encoding). Inside the SendEmail function, we get this information from our EMailMEssage object and create a MailMessage (this one is technolgy specific) object so it can be sent over the network. As you can already notice, our class has a very similar name to the "native" language class. The problem is: this is exactly what they are, email messages, so it is hard to find another meaningful name for them. Do you have this problem often? How do you manage it? Edit: @mgkrebbs just commented about using fully qualified names. This is our current approach, but a little bit too verbose, IMHO. I would like something cleaner, if possible.

    Read the article

  • function names - "standartised" prefixes

    - by dnsmkl
    Imagine you have such routines /*just do X. Fail if any precondition is not met*/ doX() /*take care of preconditions and then do X*/ takeCareOfPreconditionsCheckIfNeededAtAllAndThenDoX() A little bit more concrete example: /*create directory. Most probably fail with error if any precondition is not met (folder already exists, parent does not exists)*/ createDirectory(path_name) /*take care of preconditions (creates full path till folder if needed, checks if not exists yet) and then creates the directory*/ CheckIfNotExistsYet_CreateDirectory_andFullPathIfNeeded(path_name) How do you name such routines, so it would be clear what does what? I have come to some my own "convetion" like: naiveCreateDirectory, ForceDirectoryExists, ... But I imagine this is very standard situation. Maybe there already exists some norms/convetions for this?

    Read the article

  • Function names - "standardized" prefixes

    - by dnsmkl
    Imagine you have such routines /*just do X. Fail if any precondition is not met*/ doX() /*take care of preconditions and then do X*/ takeCareOfPreconditionsCheckIfNeededAtAllAndThenDoX() A little bit more concrete example: /*create directory. Most probably fail with error if any precondition is not met (folder already exists, parent does not exists)*/ createDirectory(path_name) /*take care of preconditions (creates full path till folder if needed, checks if not exists yet) and then creates the directory*/ CheckIfNotExistsYet_CreateDirectory_andFullPathIfNeeded(path_name) How do you name such routines, so it would be clear what does what? I have come to some my own "convetion" like: naiveCreateDirectory, ForceDirectoryExists, ... But I imagine this is very standard situation. Maybe there already exists some norms/convetions for this?

    Read the article

  • Vocabulary: Should I call this apply or map?

    - by Carlos Vergara
    So, I'm tasked with organizing the code and building a library with all the common code among our products. One thing that seems to happen all the time and I wanted to abstract is posted below in pseudocode, and I don't know how to call it (different products have different domain specific implementations and names for it) list function idk_what_to_name_it ( list list_of_callbacks, value common_parameter ): list list_of_results = new list for_each(callback in list_of_callbacks) list_of_results.push(callback(common_parameter)) end for_each return list_of_results end function Would you call this specific construct a list ListOfCallbacks.Map( value value_to_map) method or would it better be value Value.apply(list list_of_callbacks) I'm really curious about this kind of thing. Is there a standard guide for this stuff?

    Read the article

  • Initialize array in amortized constant time -- what is this trick called?

    - by user946850
    There is this data structure that trades performance of array access against the need to iterate over it when clearing it. You keep a generation counter with each entry, and also a global generation counter. The "clear" operation increases the generation counter. On each access, you compare local vs. global generation counters; if they differ, the value is treated as "clean". This has come up in this answer on Stack Overflow recently, but I don't remember if this trick has an official name. Does it? One use case is Dijkstra's algorithm if only a tiny subset of the nodes has to be relaxed, and if this has to be done repeatedly.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >