coding-style

Regarding removal of Activity Title bar in Android

青春壹個敷衍的年華 提交于 2019-12-22 05:41:47
问题 i have already set the theme of my activity as android:theme = "@android:style/Theme.Dialog" but i also want to remove the title bar of the activity. so how to use android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" along with the dialog theme. 回答1: Try creating a custom style that extends Theme.Dialog : <resources> <style name="DialogNoTitle" parent="android:Theme.Dialog"> <item name="android:windowNoTitle">true</item> </style> </resources> 回答2: I believe you can specify this in

Class member organization

北慕城南 提交于 2019-12-22 05:26:19
问题 What is the best way to sort class members? I'm in conflict with a team member about this. He suggests that we should sort the members alphabetically. I think it's better to organize in a semantic manner: important attributes first, related methods together, etc. What do you think? 回答1: I like semantic. Alphabetical doesn't seem to make a lot of sense to me, cause when you're looking for a member, you rarely know exactly what it's called. Also, if you're using any sort of naming convention

How and How often do you refactor your code?

試著忘記壹切 提交于 2019-12-22 05:04:16
问题 My question vaguely relates to this one. However, it doesn't address the techniques or practices. I am reading The Pragmatic Programmer and it strongly advocates refactoring code as often as you can. However, it doesn't go into detail about how to do that and how often. How do you guys go about refactoring your code, and how often do you refactor? 回答1: When and where needed. There is no point on refactoring per se, it is a tool to ease further development. Only refactor when you will get

How to make gcc/clang warn about missing breaks in switch statements

拈花ヽ惹草 提交于 2019-12-22 04:49:09
问题 Is there any way to make gcc or clang warn about missing breaks in switch statements? Specifically, I almost always want case statements to end with breaks, and it would be great it I could get the compiler to complain if I don't. Even better would be if it would look for either a break statement or a "// fall through" comment. Is there a different solution people use to help themselves not screw this up? 回答1: With Clang trunk, use -Wimplicit-fallthrough . If you're using C++11, intentional

bitwise indexing in C?

假装没事ソ 提交于 2019-12-22 04:43:09
问题 I'm trying to implement a data compression idea I've had, and since I'm imagining running it against a large corpus of test data, I had thought to code it in C (I mostly have experience in scripting languages like Ruby and Tcl.) Looking through the O'Reilly 'cow' books on C, I realize that I can't simply index the bits of a simple 'char' or 'int' type variable as I'd like to to do bitwise comparisons and operators. Am I correct in this perception? Is it reasonable for me to use an enumerated

C# StyleCop - Using “this.” prefix for base class members like current class members or not?

喜欢而已 提交于 2019-12-22 04:36:12
问题 StyleCop has a rule about using "this." prefix to calling class members (SA1101). Is this rule holds true about a member (for example a method) of a class which is inherited from its base class. Example: class BaseClass { protected void F1() { ... } } class ChildClass : BaseClass { protected void F2() { ... } protected void F3() { this.F2(); // This is correct acording to SA1101 // F1 is a member of base class and if I dont put this prefix, stylecop will not show any message. this.F1(); // Is

C# StyleCop - Using “this.” prefix for base class members like current class members or not?

早过忘川 提交于 2019-12-22 04:36:09
问题 StyleCop has a rule about using "this." prefix to calling class members (SA1101). Is this rule holds true about a member (for example a method) of a class which is inherited from its base class. Example: class BaseClass { protected void F1() { ... } } class ChildClass : BaseClass { protected void F2() { ... } protected void F3() { this.F2(); // This is correct acording to SA1101 // F1 is a member of base class and if I dont put this prefix, stylecop will not show any message. this.F1(); // Is

Java for-loop best practice

混江龙づ霸主 提交于 2019-12-22 04:25:14
问题 What is the best way to loop through an array when you need the index? Option 1: int len = array.length; for (int i = 0; i < len; ++i) { array[i] = foo(i); } Option 2: for (int i = 0; i < array.length; i++) { array[i] = foo(i); } Or, does it not matter? Or is there a better way to do it? Just to point out the differences: In one case, the length of the array is evaluated as part of the test in the loop, although the compiler should normally optimize that. Secondly, is ++i any different here

Java code convention for package names [duplicate]

左心房为你撑大大i 提交于 2019-12-22 04:18:15
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: what is the convention for word separator in java package names? I wonder if there are some code convension for package name which contains several words. E.g. package name com.dreamcom.objectInterfaces . Is camel case suitable in this case? 回答1: From Java package naming conventions @ Wikipedia (emphasis added): Packages are usually defined using a hierarchical naming pattern, with levels in the hierarchy

How to accommodate multiple coding styles? (git vs. IDE)

送分小仙女□ 提交于 2019-12-22 04:08:01
问题 I am collaborating on a git-sourced, maven-managed Java project with differing code styling preferences with users using multiple IDE's (note 1). Is there a tool or IDE configuration that will allow code to be viewed and edited using style-1 , but committed to SCM using style-2 ? My research points me to 'no', but a solution combining git hooks and Checkstyle/jrefactory might be possible. So if 'no' to above, is there a tool/process that will perform the TBD process actions below? The