Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [naming]

Give meaning and explanation with the fewest number of characters in a form that is most accepted by your team or community at large.

11
votes
3answers
11k views

Use of “this” in Golang

On the closest thing Golang has to a style guide found here, under Receiver Names this is written: The name of a method's receiver should be a reflection of its identity; often a one or two letter ...
2
votes
2answers
88 views

Naming a contradictory wrapper

I have written a Monix Consumer that wraps a Kafka Producer and am at a loss about what to name the result. KafkaConsumer is already a class, which has essentially the opposite meaning which the ...
5
votes
2answers
1k views

Avoiding conflicting namespace and class name

Say I am developing a Calculator application. It has one class called: Calculator. Therefore my namespace structure would look like this: MyCompany.Calculator.Core.Calculator Unfortunately, this ...
3
votes
1answer
126 views

Building a solid vocabulary when working in a specific domain

This question might be a bit vague and answers might come up quite opinionated but I don't know how to rephrase it so here it goes. How can a developer build a solid vocabulary when working in a ...
2
votes
4answers
580 views

Naming similar variables [closed]

I need few related variables (for example I have the lengths of 3 lines given. I have to say whether they form a triangle). Which variable naming convention is preferable in Java? len0, len1, len2 ...
3
votes
5answers
344 views

Is naming a class based on its implementation acceptable?

Is naming a class according to its implementation an acceptable practice? e.g. SortedSet if the class is maintains a sorted list of unique items or TreeSet if it using a binary search tree structure ...
-3
votes
2answers
370 views

Writing readable code and not overdoing it with naming [closed]

I've been in an argument at work about writing readable code. It was mainly about variable and method names and the idea that comments are worthless if the code is readable enough. I would not like to ...
0
votes
1answer
1k views

How to name different components in adapter pattern?

(example code in PHP, but this can apply to more languages) I have a scenario with an adapter pattern, where I have classes, interfaces and objects with different roles, like so: An original object ...
6
votes
4answers
2k views

Derived Class Method Naming

I'm having a hard time coming up with a good naming convention for methods in derived classes that serve the same purpose as the methods in the base class. For example, if both the base class, and the ...
2
votes
1answer
116 views

Is it Pythonic to have a module named `functions`?

I have a Django project. All the apps are separated nicely. Each apps often have functions that are used across the apps. Currently I place them in module named wrappers (for wrapping django/built-in/...
-2
votes
1answer
68 views

What to call a API and DB code layer [closed]

In a recent MVVM mobile app project I wrote a set of API classes and Database classes where there was a clear flow of logic between both api and db code. To enforce the way api and db interacted I ...
-1
votes
1answer
1k views

Tender Type vs Payment Method/Type

I'm designing the data model of a payment database. One of the domain requirement is to keep track of how the customer paid and, if applicable, what was used i.e.: Visa, Amex, etc. In the past I ...
0
votes
1answer
92 views

What is the name or description of my technique for filtering items in array? [closed]

I've tried posting this question on StackOverflow but they told me to try it here since it's not so specific. I'd like to know the name of the algorithm or technique of following implementation. I ...
43
votes
9answers
13k views

How and why to decide between naming methods with “get” and “find” prefixes

I always have trouble figuring out if I should name a certain method starting with getSomething versus findSomething. The problem resides in creating helpers for poorly designed APIs. This usually ...
3
votes
3answers
376 views

How to avoid confusion between services as in “service layer” and services as microservices?

If I have microservice architecture and one or more microservices have layered architecture that contain service layer, how can I avoid naming confusion between microservices and structural units of ...
27
votes
2answers
2k views

Why does XMLHttpRequest not seem to follow a naming convention?

I've been working with the XMLHttpRequest object in JavaScript recently, and I couldn't help but notice that the casing of this name makes no sense. Why is 'XML' all in caps while 'Http' is not? ...
2
votes
2answers
411 views

Giving multiple classes in a single library the same name

The project that raised this question is in C#, but it could apply to most languages that use namespaces. I've read many things on good naming practices: "Don't prefix your class names with their ...
0
votes
1answer
169 views

Can I change the name of a project in codeplex before publishing?

I started a project repo on codeplex and haven't publicly published it yet. I realized that the name I gave to it is not appropriate and would like to change the name of the project before publicly ...
-3
votes
1answer
110 views

Is it bad practice to give a directory and a file the same name?

I have a program that produces a command line tool called GetFood. The source code lives in a directory named GetFood/, and I have a main file that interacts with a class that gets the food. It seems ...
-2
votes
3answers
97 views

Adding qualitative information to function names

I started adding informations about the behavior of functions to their name recently. Two big examples: pure - this function has no side effects (besides the returned value), which I would use in ...
1
vote
2answers
159 views

Naming functions that do one or more things

I recently picked up 'Clean Code' by Robert Martin and have taken to refactoring my recent project. I'm realizing how important it is to name variables and functions in a way that clearly expresses ...
2
votes
5answers
498 views

Is wrapping built-in functions with user functions ok?

As I was working with a friend on a project I noticed that he created custom functions such as: function is_empty($val){ return empty($val); } function is_not_empty($val){ return !empty($val); } ...
5
votes
2answers
2k views

Java-style package naming and second-level country domains

I own a .co.uk domain, and I whenever I've dealt with Java-style package naming, I've gone with uk.co.domainname. Once I encountered package that did the following: co.uk.domainname. Is one of these ...
1
vote
3answers
381 views

Is Diff a well understood term, or should I name it Differentiate?

I have a class which checks for differences. I could call this class ViolationDiffer public IEnumerable<ViolationChange> Diff( IEnumerable<Violation> old, IEnumerable&...
3
votes
2answers
1k views

What do we call “IP” and “port”?

When I'm looping through files and coming up with dynamically created Ansible playbooks and stuff like that, I've quite frequently had to work with a single variable that contains the IP and port of ...
7
votes
2answers
2k views

What's the Java convention for names with a sequence of numbers, like “ISO 8859-1”?

If I'm creating a Java class for something that has a sequence of numbers in its name, e.g. “ISO 8859-1”, how should I name my class? Iso88591 seems wrong, since there's no boundary between the ...
8
votes
2answers
4k views

Should APIs be in en_US or en_GB or both? [closed]

Should I write APIs in US spelling or British spelling? Or should I provide with mapping both of them to a single one and internally using anyone which I like so that both of them works ? At present ...
5
votes
2answers
765 views

Use of “my” prefix in object naming

I am refactoring a large code base, and noticing the author often uses "my" to prefix object names. For instance, using myThingy to identify an object of type Thingy. Is this generally considered a ...
1
vote
2answers
64 views

What's the standard term for removing data and embedded code modules from a database before publishing?

Hopefully this question isn't too application-specific; I'm thinking about it with regard to Excel, but I think it applies to any file-based database that includes embedded code. I'm working on an ...
0
votes
3answers
125 views

What to rename my order table? [closed]

I have a database table named order. It contains eCommerce orders. Problem is, that's a reserved word in MySQL, and while I can use back-ticks to prevent issues, it's probably a good idea not to use a ...
5
votes
4answers
14k views

Naming Convention for Private / Public Fields [duplicate]

I read the following on the MSDN: Use Pascal casing for all public member, type, and namespace names consisting of multiple words. Note that this rule does not apply to instance fields. For ...
39
votes
3answers
13k views

Boolean Method Naming Affirmative vs Negative

Should boolean methods always take the affirmative form, even when they will only ever be used in the negative form? Say I wanted to check whether an entity exists before creating one, my argument is ...
-3
votes
2answers
147 views

How to name the parameter that holds `next` middleware in the chain?

I am writing an implementation of middleware chain in Python. Here is how a middleware function looks like: async def logger(ctx, next): print(f"Started doing stuff with {ctx}") await next() ...
1
vote
1answer
826 views

If I package by feature, but have many homogeneous classes, what is preferable?

I am wondering whether this is the correct way to handle my situation when packaging-by-feature. Use the following project structure as an example: com.foobar.web.Bootstrap.java com.foobar.web....
2
votes
4answers
263 views

Naming a class representing a collection of objects of another class

This is always a problem for me. Say, in a game, there's a class representing an enemy spacecraft named EnemySpacecraft and there's a class representing some collection of those, say all that exist in ...
78
votes
4answers
6k views

What's the difference between “to” and “as” method name prefixes? [closed]

What's the difference between "to" and "as" method name prefixes like toList(), asList(), etc... When to use which when designing a method?
2
votes
5answers
2k views

Function names - “standardized” prefixes

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 ...
2
votes
1answer
1k views

Python class naming: nested classes or composed names?

I encountered a scenario where I cannot decide on which is the best (or worst) naming strategy. The context is the following: a bracket (as in a tournament) made up of nodes, where is node is made up ...
4
votes
2answers
188 views

Are there any grammatic conventions on naming functions?

For example, I have a Selenium WebDriver and as part of my initialization I would like to check if I am able to instantiate it and start up browser. I can't come up with a proper name. Is there any ...
0
votes
1answer
1k views

How to name a service that does CUD operations from CRUD tetrad?

There is a need to separate services working with data into two groups: ones that perform read-only operations and others doing Create(or Add) + Update(can also be called Modify) + Delete(Remove). ...
3
votes
1answer
67 views

Naming a view class

I'm a little hesitant on what to name a view class. I have a view class which I call ChooseImageView because that's what the user does in that view. After the user has chosen an image I display a ...
0
votes
1answer
57 views

If I'm explicitly using WCHAR strings in my Windows application, should I use the -W functions rather than the TCHAR #defines?

Basically, TCHAR and the associated macros (_T/TEXT) are only really necessary if you're targeting both ANSI and Unicode, and, like 99.9% of developers out there, the possibility that someone might be ...
0
votes
1answer
1k views

Naming collections of helper methods, and avoiding meaningless jargon words

While coding anything remotely useful, I inevitably find myself wanting to add methods to perform smaller bits and pieces. (It could be a method to return everything in a string to the left of the ...
3
votes
1answer
1k views

Why shouldn't you create a custom uri scheme?

In setting up deep linking to android and iOS apps, I've made some use of custom URI schemes, and they work great, especially as a fallback when the mechanism that allows maps from http: fails (as ...
88
votes
5answers
91k views

Naming classes, methods, functions and variables [duplicate]

There are 3 important naming conventions: with_underscores PascalCased camelCased Other variants are not important because they are not commonly used. For variables it seems that the one with ...
-1
votes
1answer
74 views

REST: Using singular to return logged-in info

Github uses the convention "/user" (singular) to interact with the logged-in user's info. They still have the full "/users" suite of paths to support getting info based on IDs (or usernames in their ...
0
votes
2answers
207 views

Is there a name for being able to substitute a variable for the source code assigned to it?

Consider the following (python) code x = [1, 2, 3, 4] y = 2 + 3 z = x[0] + y Here, I can substitute the expressions for x and y verbatim in the expression for z, possibly by surrounding then in some ...
48
votes
2answers
15k views

Naming of bool methods: Is vs. Can vs.?

Which is the better name for a method that returns a boolean? IsSupportContentType or CanSupportContentType
1
vote
1answer
148 views

Providing context in Class name, even though the namespace provides context

So I am reading Clean Code and I want to write my class names with the proper amount of context, but how does .NET namespaces play into the concept of Meaningful Names? Do I forego context in the ...
-6
votes
1answer
594 views

Class names with Verbs

So I am reading Clean Code. In the Meaningful Names chapter, they lay down a rule of no verbs in class names. However in the Adding Meaningful Context section of that chapter, on page 29, he uses a ...