conventions

Java Architecture - Question about ActionListener Conventions

橙三吉。 提交于 2019-12-30 05:25:24
问题 I am making a user interface which shows graphs and manipulates graphs. The class extends JFrame implements ActionListener. The ActionListener then calls different classes to manipulate graphs depending on the action. This worked while the class had few ActionListeners; however, now the class is becoming unmanageable. I know that in the interest of encapsulation, it would be best to have the ActionListener within the user interface class because it needs to access non-static components of the

Where to define custom error types in Ruby and/or Rails?

為{幸葍}努か 提交于 2019-12-29 02:23:30
问题 Is there a best practice for defining custom error types in a Ruby library (gem) or Ruby on Rails application? Specifically: Where do they belong structurally in the project? A separate file, inlined with the relevant module/class definition, somewhere else? Are there any conventions that establish when to and when not to create a new error type? Different libraries have different ways of doing things, and I haven't noticed any real patterns. Some libraries always use custom error types while

Where to define custom error types in Ruby and/or Rails?

喜夏-厌秋 提交于 2019-12-29 02:23:06
问题 Is there a best practice for defining custom error types in a Ruby library (gem) or Ruby on Rails application? Specifically: Where do they belong structurally in the project? A separate file, inlined with the relevant module/class definition, somewhere else? Are there any conventions that establish when to and when not to create a new error type? Different libraries have different ways of doing things, and I haven't noticed any real patterns. Some libraries always use custom error types while

Private and protected methods in Objective-C

早过忘川 提交于 2019-12-28 12:43:33
问题 What is the recommended way to define private and protected methods in Objective-C? One website suggested using categories in the implementation file for private methods, another suggested trailing underscores, or XX_ where XX is some project-specific code. What does Apple itself use? And what about protected methods? One solution I read was to use categories in separate files, for example CLASS_protected.h and CLASS_protected.m but this seems like it could get very bloated. What should I do?

Java array convention: String[] args vs. String args[]

徘徊边缘 提交于 2019-12-28 12:00:43
问题 I am currently teaching students as a tutor programming conventions. I've told them that they can find most conventions in the Oracle Code Conventions. In my last tutorial a student asked if: public static void main(String args[]) or public static void main(String[] args) is written by convention or if there is a difference. I have never seen the first version before, so I'm very sure that the second one is a convention. But I don't have a source for that. Can you give me a source (preferably

What does this mean “This method is deprecated as the user should use the Java 5 conventions.”?

守給你的承諾、 提交于 2019-12-25 03:15:47
问题 I am using the "ColumnPositionMappingStrategy" class of the opencvs library. This class has the deprecated method setType(Class<T> type) and as comment has " This method is deprecated as the user should use the Java 5 conventions " As far as I understand is that I have to use Generics instead of setType like: ColumnPositionMappingStrategy<MyClass> mappingStrategy = new ColumnPositionMappingStrategy<>(); to solve the problem. But I get NullPointerException when I remove the line:

\Windows\ versus \Windows\System32 - File location conventions

倖福魔咒の 提交于 2019-12-23 20:50:37
问题 Is there a standard convention for the types of files that go in \Windows\ versus those that go in \Windows\System32 ?? I'm working on an SDK that has a variety of DLLs a helper exe, and a Windows service exe. The previous guy who worked on the code put the two exe files in \Windows\ and the DLLs in \Windows\System32\ But it seems to me that they should likely all go in \Windows\System32\ Which would you do? Edit: I am NOT trying to debate the merits of if they should go there at all. Plenty

Designing constructors around type erasure in Java

百般思念 提交于 2019-12-23 17:53:28
问题 Yesterday, I was designing a Java class which I wanted to be initalized with Lists of various generic types: TheClass(List<String> list) { ... } TheClass(List<OtherType> list) { ... } This will not compile, as the constructors have the same erasure. I just went with factory methods differentiated by their names instead: public static TheClass createWithStrings(List<String> list) public static TheClass createWithOtherTypes(List<OtherType> list) This is less than optimal, as there isn't a

How can I create a Fluent NHibernate Convention that ignores properties that don't have setters

孤街浪徒 提交于 2019-12-23 15:24:06
问题 I'm looking for a FluentNH (Fluent NHibernate) convention or configuration that ignores all properties that have no setter: It would still map these: public class foo{ public virtual int bar {get; private set;} } And omit these: public class foo{ public virtual int fizz{get;private set;} public virtual int bar{get {return fizz;}} //<------- } 回答1: You should use a custom mapping configuration public class DefaultMappingConfiguration : DefaultAutomappingConfiguration { public override bool

What's the clearest way to indicate a function uses the 'arguments' object?

此生再无相见时 提交于 2019-12-22 09:25:47
问题 What's the best way to indicate a function uses the 'arguments' object? This is obviously opinion based but are there any conventions? When would it be better to use an array of arguments? Some examples: // Function takes n arguments and makes them pretty. function manyArgs() { for (var i = 0; i < arguments.length; i++) console.log(arguments[i]); } function manyArgs( /* n1 , n2, ... */ ) function manyArgs(n1 /*, n2, ... */ ) function manyArgs(argArray) 回答1: // Using ES6 syntax ... var foo =