coding-style

Cocoa NSTabView coding style question

。_饼干妹妹 提交于 2020-01-01 19:39:32
问题 I have a coding style question which probably should be asked of a senior mac programmer at work - but since I'm the only mac programmer, well, SO it is. I have a pop-up GUI for my software (3D models, data visualization) and the pop-up is Mainly a Tabbed control with a ton of stuff in each tab (sliders, radio buttons, checkboxes, etc.) With something like 20 controls per tab, and maybe half a dozen tabs... using a single controller for all the views is going to get unwieldly very quickly. Is

python: make a variable equal an operator (+,/,*,-)

≯℡__Kan透↙ 提交于 2020-01-01 19:39:28
问题 is it possible to assign a variable a maths operator. this is what I've currently got, just a sample (typed it in now, so dont worry about simple errors) if image == "lighten": red_channel = red_channel + 50 else: // image is darken red_channel = red_channel - 50 notice how i am repeating the exact same code, with a different operator. Is it possible to achieve something like this: if (image == "lighten"): operator = + else: operator = - red_channel = red_channel operator 50 回答1: import

How to avoid duplicating logic on two similar WinForms?

痴心易碎 提交于 2020-01-01 11:51:19
问题 I have two forms, form A and form B. These forms must differ in appearance, but they share a lot of logic. The problem is that this logic is tied to the appearance (validation on button click, events being fired, etc.). For example, I have a name field, and when the save button is pressed, I need to fire an event which causes the parent form to validate the record name to avoid duplicates. Both forms need this logic, but their save buttons are in different places, and the tooltip that is

How to avoid duplicating logic on two similar WinForms?

冷暖自知 提交于 2020-01-01 11:51:12
问题 I have two forms, form A and form B. These forms must differ in appearance, but they share a lot of logic. The problem is that this logic is tied to the appearance (validation on button click, events being fired, etc.). For example, I have a name field, and when the save button is pressed, I need to fire an event which causes the parent form to validate the record name to avoid duplicates. Both forms need this logic, but their save buttons are in different places, and the tooltip that is

Delphi Coding Standards [duplicate]

穿精又带淫゛_ 提交于 2020-01-01 10:56:08
问题 This question already has answers here : What Delphi coding standards document(s) do you follow? [closed] (8 answers) Closed 5 years ago . I am in the process of writing (down) our companies coding standards for Delphi programming, so what would anyone suggest to have as a basis, anything that you would recommend to use / not use ? 回答1: I used Delphi Language Coding Standards Document as a basis for an internal document. The Object Pascal Style Guide could probably be termed the "official"

TextView state_pressed/state_focused/state_selected style change

白昼怎懂夜的黑 提交于 2020-01-01 09:28:11
问题 I'm trying to change a TextView style based on its state. My styles.xml contains: <style name="text_normal_ops"> <item name="android:gravity">left</item> <item name="android:textColor">@color/text_usual_color</item> <item name="android:textStyle">bold</item> </style> <style name="text_normal_ops_pressed"> <item name="android:gravity">left</item> <item name="android:textColor">@color/text_pressed</item> <item name="android:textStyle">bold</item> </style> My selector ( text_ops.xml )is defined

Objective-C Class Prefixes [closed]

女生的网名这么多〃 提交于 2020-01-01 08:23:29
问题 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 5 years ago . What's your preference with naming ObjC classes? I'm a little uncertain what would be the most reasonable approach on this so it would be nice to hear some other opinions. Apple recommends prefixing cocoa classes, because ObjC doesn't support namespaces. The Google ObjC

Way to get VS 2008 to stop forcing indentation on namespaces?

≯℡__Kan透↙ 提交于 2020-01-01 08:17:11
问题 I've never really been a big fan of the way most editors handle namespaces. They always force you to add an extra pointless level of indentation. For instance, I have a lot of code in a page that I would much rather prefer formatted as namespace mycode{ class myclass{ void function(){ foo(); } void foo(){ bar(); } void bar(){ //code.. } } } and not something like namespace mycode{ class myclass{ void function(){ foo(); } void foo(){ bar(); } void bar(){ //code.. } } } Honestly, I don't really

What is the proper style for listing imports in Java?

一笑奈何 提交于 2020-01-01 07:56:15
问题 Is it better to list each individual piece of a package you're going to need (see #1) or is it better to just import everything from a package (see #2)? 1 import java.awt.image.ColorModel; import java.awt.image.ComponentColorModel; import java.awt.image.ColorConvertOp; 2 import java.awt.*; 回答1: It's NOT simply a matter of style; import-on-demand can result in code that ceases to compile as new classes are added to existing packages. Basic idea (See http://javadude.com/articles

Nested method calls vs. one-shot variables

拈花ヽ惹草 提交于 2020-01-01 06:26:14
问题 What is the best practice when nesting method calls or using one-shot variables? Should you never use one-shot variables? example: [persistentStoreCoordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:[NSURL fileURLWithPath: [applicationSupportDirectory stringByAppendingPathComponent: @"storedata"]] options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSMigratePersistentStoresAutomaticallyOption] error:&error]; Should you always break up a