naming-conventions

What's a good naming convention for methods that take conditional action?

非 Y 不嫁゛ 提交于 2019-12-08 15:41:36
问题 Let's say I have a method, Foo() . There are only certain times when Foo() is appropriate, as determined by the method ShouldFooNow() . However, there are many times when the program must consider if Foo() is appropriate at this time. So instead of writing: if ShouldFooNow(): Foo() everywhere, I just make that into one function: def __name(): if ShouldFooNow(): Foo() What would be a good name for this method? I'm having a hard time coming up with a good convention. IfNecessaryFoo() is awkward

Rails unorthodox naming of models with abbreviations

扶醉桌前 提交于 2019-12-08 14:58:23
问题 In an application I am building I am storing an XML file in my database using the acts_as_tree association. I would like to name the class XMLElement but this throws rails off since the capitalization is non-standard. It is looking for XMLElement from the file name xml_element.rb . I tried changing the filename to x_m_l_element.rb to try and trick it into thinking that "XML" was really two words, but this didn't work either. Should I just suck it up and use the name XmlElement instead of the

What are the type parameter naming guidelines?

淺唱寂寞╮ 提交于 2019-12-08 14:37:28
问题 I noticed, as well as saw in the Essential C# 3.0 book, that paramters are usually defined as T or TEntity For example: public class Stack<T> { } or public class EntityCollection<TEntity> { } How do you decide which name to use? Thanks 回答1: Here is my set of rules If there is one parameter, I name it T If there is more than one parameter, I pick a meaningful name and prefix with T. For example TKey, TValue For a semi-official opinion, it's worth looking at the framework design guidelines on

Java “ANSI constants”

人走茶凉 提交于 2019-12-08 14:36:15
问题 I hit this little tidbit while browsing the Java Code Conventions: The names of variables declared class constants and of ANSI constants should be all uppercase with words separated by underscores ("_"). (ANSI constants should be avoided, for ease of debugging.) (From here.) What are these "ANSI constants" this document speaks of? And how do they make debugging harder? The text makes it sound as if there is a dichotomy between "variables declared class constants" (which I interpret as

C# Variable Name “_” (underscore) only

☆樱花仙子☆ 提交于 2019-12-08 14:33:50
问题 I was just hit with a minor issue in C#, it was just a copy-paste mistake but don't know how C# accept it. This code gets compiled successfully...HOW namespace DemoNS { class DemoClass { String _ = new String('a', 1); } } Is there any default significance of variable named _ ? 回答1: No, there is no default significance, _ is just a variable name like any other. I like to use it in similar way to Prolog's anonymous variables: when you're creating a lambda that ignores one of its parameters, you

Ideal class name for static class for misc functionalities [duplicate]

若如初见. 提交于 2019-12-08 10:44:44
问题 This question already has answers here : Naming convention and structure for utility classes and methods (2 answers) Closed 6 years ago . Whats is the ideal class name for my static class which has some static methods to handle General/Common functionalities iike taking backup,saving recent items etxc.. (Infact Misc items ) in C#. I would like to have Manager as suffix of the class name (ex: SaleManager(to handle sales related functionalities),ContatManager(to handle contact related

What are some universal “clean-coding” conventions? [closed]

人盡茶涼 提交于 2019-12-08 09:46:16
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . Aside from language-specific constructs, for someone who is programming in PHP, javascript, java, and python, what are the top 10 clean coding must-do's? I would like to keep my code as clean as possible and as readable as possible. For example, what's the take on placing the

How can I reduce my Class Name in Zend to call it from any where in application?

℡╲_俬逩灬. 提交于 2019-12-08 05:44:22
问题 I want to follow Zend file naming convention. I have Object.php file with a class and a function in it. MyZendProject->application->models->Test->Object.php class Model_Test_Object { public function test() { echo "Test"; } } Now I want to access above test function in following file but it is not finding it. MyZendProject->application->modules->test->controllers->TestController.php $testModel = new Model_Test_Object(); $testModel->test(); But when I name the class Application_Model_Test

good name for a method that adds to a container if not aleady there

给你一囗甜甜゛ 提交于 2019-12-08 04:57:25
问题 What's a good name for a method that adds something to a container if it's not already there, i.e. void AddCustomerToList(CustomerList list, Customer customer) but that name does not properly convey that it won't be added if it's not there already. What is a better name? AddCustomerToListIfNotThereAlready? EnsureCustomerInList? 回答1: AddIfNotPresent 回答2: Change CustomerList to CustomerSet, then it's obvious. add(CustomerSet set, Customer customer); 回答3: bool TryAdd(CustomerList list, Customer

ExecutorService naming conventions Java

∥☆過路亽.° 提交于 2019-12-08 04:21:52
问题 I have recently found myself using some ExecutorServices (SingleThreadScheduledExecutor and newFixedThreadPool) but I don't have any kind of good name for them. Are there any kind of guidelines or conventions about naming these kinds of objects? I have seen names like "workerThread" used for SingleThreadScheduledExecutors, is this correct as they are not exactly threads? 回答1: Although this is primarily opinion based, I'm using the following conventions in my code: A Field or parameter that