Search Results

Search found 1759 results on 71 pages for 'naming conventions'.

Page 12/71 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Better use on the name of variables

    - by Cuartico
    I have a method that looks like this: Public Function NormalizeStreetAddress(country As Namespace.Country, streetAddress As Namespace.StreetAddress) _ As Namespace.StreetAddress Dim _streetAddress As New Namespace.StreetAddress = streetAddress If My.Settings.Streeteable = True Then Dim _AddressCustom As New Namespace.AddressCustom _streetAddress = _AddressCustom.NormalizeStreetAddress(country, streetAddress) End If Return _streetAddress End Function I receive a streetAddress object, but inside the method I need to use another streetAddress object which I called _streetAddress — is that following the standard? A friend of mine told me that object names such as _yourNameObject are for global variables, but I can't find info about this and I want to make this method more readable.

    Read the article

  • Script language native extensions - avoiding name collisions and cluttering others' namespace

    - by H2CO3
    I have developed a small scripting language and I've just started writing the very first native library bindings. This is practically the first time I'm writing a native extension to a script language, so I've run into a conceptual issue. I'd like to write glue code for popular libraries so that they can be used from this language, and because of the design of the engine I've written, this is achieved using an array of C structs describing the function name visible by the virtual machine, along with a function pointer. Thus, a native binding is really just a global array variable, and now I must obviously give it a (preferably good) name. In C, it's idiomatic to put one's own functions in a "namespace" by prepending a custom prefix to function names, as in myscript_parse_source() or myscript_run_bytecode(). The custom name shall ideally describe the name of the library which it is part of. Here arises the confusion. Let's say I'm writing a binding for libcURL. In this case, it seems reasonable to call my extension library curl_myscript_binding, like this: MYSCRIPT_API const MyScriptExtFunc curl_myscript_lib[10]; But now this collides with the curl namespace. (I have even thought about calling it curlmyscript_lib but unfortunately, libcURL does not exclusively use the curl_ prefix -- the public APIs contain macros like CURLCODE_* and CURLOPT_*, so I assume this would clutter the namespace as well.) Another option would be to declare it as myscript_curl_lib, but that's good only as long as I'm the only one who writes bindings (since I know what I am doing with my namespace). As soon as other contributors start to add their own native bindings, they now clutter the myscript namespace. (I've done some research, and it seems that for example the Perl cURL binding follows this pattern. Not sure what I should think about that...) So how do you suggest I name my variables? Are there any general guidelines that should be followed?

    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

  • 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

  • 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

  • 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 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

  • 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

  • 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

  • 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 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

  • 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

  • How do you refer to the user using the application vs. the user being edited? [closed]

    - by Roman Royter
    Suppose you are developing an administration page where the administrator can edit other users. In your code you want to distinguish between the user sitting in front of the screen, and the user being edited. What do you call the two? User, CurrentUser, EditedUser, CurrentEditUser, etc? Note that the admin user isn't necessarily real admin, they can be just an ordinary user given rights to edit other users.

    Read the article

  • What is the abstract name for Drive, Directory and file?

    - by Omkar panhalkar
    I want to give nice name to my function while returns drive, directory and file. Can you please suggest a good abstract name for this trio? This is the function. static IEnumerable<string> GetDriveDirectoriesAndFile(string path) { if (path.Contains('/')) { path = path.Replace('/', '\\'); } if (path.Contains('\\')) { return path.Split('\\'); } return null; } Thanks, Omkar

    Read the article

  • How to name a clamp function that only clamps from one side?

    - by dog_funtom
    Clamp() is a function that ensures that provided variable is in provided range. You can find such function in .NET, in Unity, and probably anywhere. While it is useful, I often need to clamp my value from one side only. For example, to ensure that float is always non-negative or always positive (like radius value from inspector). I used names ClampFromAbove() and ClampFromBelow(), but I wonder if such names is good or even grammatically valid in programming-English. Also, it probably make sense to distinguish non-negative case too. How'd you name such function? Something like EnsureNonNegative()? My intention is creating pair of extension methods and use them like this: var normalizedRadius = originalRadius.ClampFromBelow(0.0001); var distance = someVector.Magnitude.ClampFromAbove(maxDistance);

    Read the article

  • Is there a name for a mini class that is not a struct?

    - by user1555300
    I have a couple of mini-classes that are not nested classes. They need to be passed around between different larger classes to use. In a way, they act like Tuples, storing fields in them. For example, [Serializable] public class TransformObject { public GameObject GameObj; public tk2dCameraAnchor Anchor; public ManagerTransform MTransform; } I have a few of them for my game I have been developing. They have to be classes, not struct because the Unity3d editor will not show in the inspector if so. I was just wondering if there is a official name for these kind of mini classes.

    Read the article

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