The art of properly calling a cat, a cat; naming is often governed by various conventions. Poor naming can make code harder to read, good naming easier.

learn more… | top users | synonyms

11
votes
1answer
81 views

How can I better name my tests?

I am relatively new to TDD and am trying to adopt better names for my tests. I wrote the following tests abruptly and have since refactored them to the best of my ability, but despite my best ...
5
votes
3answers
737 views

Class for catching error and logging

I often write something like this in my code: ...
7
votes
2answers
73 views

EditController and ModelConverter - Does this make my ass look fat?

Description I am using a combination of the following two classes to achieve a quite simple task. I have Users in my application. These Users can be assigned Roles. And these Roles need to be ...
4
votes
4answers
90 views

How to name template method properly so it makes better sense?

Some might not think it's worth asking but I consider good function names quite important. I am not sure what should be the overridable function name in what I think is template design pattern. I am ...
10
votes
3answers
735 views

Does everyone still love Fibonacci?

I'm following up on this question. I made a few decisions about my model and implemented recommendations accordingly. TL;DR the link Uses a loop algorithm to return a Fibonacci number \$Fn\$ of ...
1
vote
1answer
31 views

How to name this function which chains a number of callables into single function?

How would you name this function (I gave in a name pipe in the example) which constructs combines a chain of functions with a single attribute into a single ...
3
votes
2answers
72 views

Suggested parameter names for utility class function

During our internal code review process, my following code raised some eyebrows: ...
6
votes
1answer
76 views

Retry logic for delegates

I created this class which supposed to take a method and try to execute it. If it fails lets say 10 times, it will throw the original exception thrown by the delegate. Do you guys have any ideas for ...
6
votes
1answer
139 views

What is the proper naming of classes and method when designing API for calculation library?

I'm working on library which will provide easier writing and calculation in Java using fluent API. Library I have implemented with basic functionalities and now I am working to improve API. I ...
2
votes
1answer
118 views

How should I name a mapper or manager?

Recently I was reading a book called Clean Code by Robert C. Martin. There is a chapter called Meaningful Names that started me thinking if I was doing this right. I know there isn't one good way to ...
6
votes
2answers
232 views

Android Thread and Runnable

This is my code for running a background thread. I believe it is very poor in naming and code structure. ...
3
votes
1answer
85 views

Class naming conventions

I have the following scenario: The (web-) application is built with Java/Spring. I have several REST-endpoints which deliver data prepared to be consumed by a frontend by ...
2
votes
1answer
57 views

Naming for a variable in before and after status and different type of variable

I'm not a native English speaker, so I'm unsure about this. Is it ok to name a variable and put the prefix "before" and "after"? If not, how could I give it a better name? ...
2
votes
2answers
86 views

How to name this very simple class?

I want to give a short and clear name to this class: ...
5
votes
1answer
101 views

How to name a read-only Collection property

I think good naming is an important part of maintainable and good usable code. One rule we have for that is that properties must start with a capital letter. We have an API here which can be ...
2
votes
1answer
84 views

Code reuse while keeping meaning clear and avoiding unforseen consequences

I like to reuse code as much as possible and keeps things DRY. But I'm afraid that sometimes it creates too many layers of indirection. It then becomes a chore to find where code exists that is ...
3
votes
1answer
53 views

Proper naming for filter classes

In my Android application, I have two types of filters: search filters and sorting filters. I need to read filters from view, display filter on view, save them into and from memory. I should include ...
6
votes
2answers
129 views

Class that represents searchable and sortable elements

In my application, I have a small hierarchy of related classes (partner categories - partners - partner points). The application has two representations of its content: in the form of partners ...
4
votes
2answers
68 views

Proper naming for Time class

If I have this simple class: ...
3
votes
1answer
100 views

Naming of predicate methods

Sorry for my English. I want to discuss this question. I don't agree with @200_success. He says: I would also rename evenNumber(int number) to isEven(int number). There is a convention in Java ...
6
votes
1answer
184 views

Class for typecasting an Activity to an interface

In several places, I have some code that looks like the following, the only difference is in the type of listener. ...
8
votes
2answers
189 views

Commenting and naming variables in Python

I am struggling with commenting and variable naming. My teacher says my comments need to be more explanatory and explicit. He says my variable names are also sometimes confusing. I was just wondering ...
5
votes
1answer
227 views

A Program that Finds Empty Folders

I wrote a program that finds empty folders and subfolders in a directory. It's the first program I've ever written in Java, and I'd like some critique. I feel like I'm not utilizing classes in a very ...
2
votes
1answer
119 views

Naming convention in my C++ library

I am implementing a library in C/C++11 and I have chosen to follow Google C++ Style Guide as I also use this Style Guide in my code. As such all classes and types (including ...
0
votes
1answer
74 views

Help me choose a more appropriate name or make this class inherit from another class [closed]

I need to rename the next class or have it inherit from ArrayAdapter<String>. ...
15
votes
3answers
724 views

Commenting in Python and general semantics

I am struggling with commenting and variable naming. My teacher says my comments need to be more explanatory and explicit. He says my variable names are also sometimes confusing. I was just wondering ...
1
vote
2answers
137 views

Android class in Tic-Tac-Toe

CellDrawableProvider is an Android class used in the game Tic-Tac-Toe. It provides drawables for cells of game board (drawables for figures X and O, and "Fire" if ...
2
votes
2answers
64 views

Help me choose a more appropriate name

The game involves two players. To identify each of them, I use an enumeration containing two possible values ​​- PLAYER_1 and ...
2
votes
1answer
179 views

Method names for encapsulated unit testing logic. Which convention is better?

I have some C# unit tests which each basically perform the same steps but supply different arguments to the unit under test. I wanted to encapsulate the logic inside some "helper methods" but found ...
6
votes
2answers
263 views

Simple anagram game with names of colors

This is a very simple anagram game that plays only with names of colors. I tried to focus on code design. I also wanted it to support further updates. But, my ...
-1
votes
1answer
68 views

Foreach loop naming conventions [closed]

Is it considered bad practice to name the item with the singular version of the name of the iterated collection? In dynamically typed languages it would be easy to use the collection variable by ...
1
vote
2answers
102 views

Naming convention for a method with double get

The following are an example of methods supported by a proprietary device: Monitor ControlTemp PutPeakInfo GetPeakInfo I have a class that builds the packets for the above corresponding methods: ...
1
vote
1answer
34 views

Naming of method that returns a viewmodel

In my ASP.NET MVC code, I like to use controller service classes for my controllers. These service classes contain methods for retrieving viewmodel objects. Here is an example controller snippet: ...
1
vote
1answer
63 views

Is this class name for my commenting system confusing?

In my project (which is a discussion system) there are approved and unapproved comments. There's a class that tells if unapproved comments should be shown. But I cannot think of a good name for this ...
0
votes
2answers
823 views

Printing out all the subsets of a set - am I unnecessarily creating new objects?

I am concerned about creating too many objects in my code. Am I using duplicate code? Can I cut down on the number of lines of code? Note: I only want to use recursion to solve this. Any ...
5
votes
1answer
139 views

Recommended Naming for function that tests and mutates

I am a huge proponent of self-documenting code (when at all possible). I prefer to have code be self evident by the very nature of the names of the variables, methods, etc.. For instance: ...
5
votes
5answers
300 views

Is this an acceptable method name?

GetCollectionWhereKeyStartsWith(string key) The intent of the method is to retrieve a sub-collecteion from a name value collection where the key starts with the ...
-1
votes
2answers
302 views

What is a good name for bidirectional dictionary structure? [closed]

I'm writing a generic bidirectional dictionary which will be a part of a (somewhat) public API. This is how the dictionary works: It will hold key-key pairs where ...
-1
votes
2answers
114 views

How to name this function?

The sample code is like this: ...
1
vote
1answer
136 views
2
votes
2answers
113 views

Suggest name for the method

I have an Interpreter class that has a method named loop. This method takes two inputs, a ...
2
votes
2answers
92 views

Naming of overloaded methods - singular or plural? [closed]

This question is about your opinions and/or existing conventions. Let's say I have an object Basket that store various items in some private property (...
11
votes
2answers
679 views

Advice on naming convention with enum

I have an enum called NodeType. Since my public field does not want to conflict with enum, ...
3
votes
1answer
398 views

Rails: Cleaning parameters before passing them to a model

I'm writing an API and want to be able to pass in the attributes of a model without prefixing them with the name of the model. I wrote this little extension to ActiveRecord in order to make it happen: ...
9
votes
6answers
467 views

Better test names

I have some simple tests written, however, the names are not good...I think, any suggestions on better names? I'm not really sure how these tests should be named. I'm looking for a format or pattern ...
1
vote
2answers
99 views

FooTest or FooTests? [closed]

Can't make up my mind. For a class Foo, should its test class be called FooTest or FooTests? ...
4
votes
2answers
254 views

Name Proper Casing code example

I deal with hundreds and hundreds of names each week. These names (along with other pedigree information) are stored in a database. Typically, I get these names in all sorts of formats, mainly proper ...
3
votes
3answers
236 views

Is “int2rgb” an OK method name?

All colors can be represented by an int, and often you want to get the individual red, green and blue values from that int. I ...