coding-style

Function names in C++: Capitalize or not? [closed]

旧巷老猫 提交于 2019-12-17 21:48:24
问题 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 4 years ago . What's the convention for naming functions in C++? I come from the Java environment so I usually name something like: myFunction(...) { } I've seen mixed code in C++, myFunction(....) MyFunction(....) Myfunction(....) What's the correct way? Also, is it the same for a class

Correct way to define C++ namespace methods in .cpp file

谁说我不能喝 提交于 2019-12-17 21:27:09
问题 Probably a duplicate, but not an easy one to search for... Given a header like: namespace ns1 { class MyClass { void method(); }; } I've see method() defined in several ways in the .cpp file: Version 1: namespace ns1 { void MyClass::method() { ... } } Version 2: using namespace ns1; void MyClass::method() { ... } Version 3: void ns1::MyClass::method() { ... } Is there a 'right' way to do it? Are any of these 'wrong' in that they don't all mean the same thing? 回答1: Version 2 is unclear and not

How do you tell someone they're writing bad code? [closed]

无人久伴 提交于 2019-12-17 21:24:16
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . I've been working with a small group of people on a coding project for fun. It's an organized and fairly cohesive group. The people I work with all have various skill sets related to programming, but some of them use older or outright wrong methods, such as excessive global variables, poor naming conventions,

Coding clarity of closure for load event

心已入冬 提交于 2019-12-17 21:17:20
问题 Is there are clear way to write this closure for the load event on line #4: for i,item of m # add item once image loaded new_item = $("<img src='#{util.image_url(item, 'large')}' />") new_item.on 'load', ((item) => (=> @add_item(item)))(item) $("#preload-area").append(new_item) 回答1: You want a do loop: When using a JavaScript loop to generate functions, it's common to insert a closure wrapper in order to ensure that loop variables are closed over, and all the generated functions don't just

Should you use international identifiers in Java/C#?

江枫思渺然 提交于 2019-12-17 20:34:18
问题 C# and Java allow almost any character in class names, method names, local variables, etc.. Is it bad practice to use non-ASCII characters, testing the boundaries of poor editors and analysis tools and making it difficult for some people to read, or is American arrogance the only argument against? 回答1: I would stick to english, simply because you usually never know who is working on that code, and because some third-party tools used in the build/testing/bugtracking progress may have problems.

Tool that shows unit dependencies for Delphi 2010 or Delphi 7 program

时间秒杀一切 提交于 2019-12-17 20:25:32
问题 We're trying to untangle a hairball of 100's of units, removing some. It would be helpful if there was tool that would show us what units were explicitly using unit X. Penganza doesn't seem to have a report that does that. (Although it has lots of other useful reports.) Can anyone suggest a tool or strategy for doing this, other than just hiding unit x and then hitting F9 ... repeatedly? 回答1: Peganza Pascal Analyzer can do the work. I haven't worked with it much, but a former dev here wrote a

appcompat_v7: Error retrieving parent for item: No resource found that matches the given name

自作多情 提交于 2019-12-17 19:12:41
问题 I am trying to build the Android project that uses appcompat_v7 library. For that, I created my project through Eclipse -> New Android Sample Project and added my custom styles.xml and then added the appcompat_v7 library Project -> Properties -> Android -> Add. But I am getting the following errors in appcompat_v7/res/values/styles_base.xml when I compile my project: appcompat_v7/res/values/styles_base.xml:24: error: Error retrieving parent for item: No resource found that matches the given

Why doesn't my TextBlock/TextBox apply values from a Base Style?

孤者浪人 提交于 2019-12-17 19:04:19
问题 It's not uncommon for me to write something like below for styling a data entry form, but my problem is that TextBox and TextBlock don't seem to implement the Setters that are in the BaseElementStyle . Usually I need to define them separately. Why is this? And is there a way around it? I am guessing it has to do with the fact they are usually used in other control templates (for example TextBlock is used in most controls and TextBox is used in DatePickers and ComboBoxes) <Style x:Key=

usage of property vs getters/setters in business classes

让人想犯罪 __ 提交于 2019-12-17 18:41:51
问题 When dealing with buisness classes, like the typical Customer and Employee classes, is it better to use getters and setters only or to use properties? I am translating to Delphi (for self learning) some OO examples from java books, in those examples there is always GetName() and SetName(), properties are not used. Now, I can see that if I create a component with published properties I have a very good reason for using properties, but in normal classes, which approach is better? Is the code

If the convention in Python is to capitalize classes, why then is list() not capitalized? Is it not a class?

北城以北 提交于 2019-12-17 18:34:57
问题 Often when I see class definitions class Foo: , I always see them start with upper case letters. However, isn't a list [] or a dict {} or some other built-in type, a class as well? For that matter, everything typed into the Python's IDLE which is a keyword that is automatically color coded in purple (with the Window's binary distribution), is itself a class, right? Such as spam = list() spam is now an instance of a list() So my question is, why does Python allow us to first of all do