coding-style

From XCode 4.2 to 4.3, new ViewController class .m files are defined differently. Why?

眉间皱痕 提交于 2019-12-23 03:55:06
问题 Like most, I recently downloaded the latest version of XCode (4.3.1). I've noticed that as I'm creating new UIViewController objects, the associated .m files contain additional class definition code that I haven't ever seen before. Specifically, if I create a new UIViewController named 'TestViewController', I get the following .m file output. \\... removed comments... #import "TestViewController.h" @interface TestViewController () @end @implementation TestViewController - (id)initWithNibName:

Refer to data files from within C++ project

自古美人都是妖i 提交于 2019-12-23 03:40:38
问题 I have a C++ project with a folder structure something like so: root/trunk root/trunk/src/... root/trunk/include/... root/trunk/utils/... <-- this has the `main` programs which are compiled root/trunk/bin/... compiled binaries root/data/... data used in the programs In my source files, I sometimes refer to files included in the data subfolders. I want the paths I use to be relative paths (because I am sharing this project with someone else). How can I ensure that the data files can always be

What's the best to handle unaccepted method arguments in Java?

烂漫一生 提交于 2019-12-23 03:31:35
问题 When writing a method, say, inside one of your DAO objects, and you dont want this method to accept certain input, for discussions sake, say it does not allow null arguments. How do you go about implementing that, taking into account this method is likely to be reused in the future by new team members. The way I do it is: In the interface, I document inside the method javadoc that arguments a, b and c cannot be null. Inside the method I check for null values first thing, and if any of a, b or

What's the best to handle unaccepted method arguments in Java?

徘徊边缘 提交于 2019-12-23 03:31:11
问题 When writing a method, say, inside one of your DAO objects, and you dont want this method to accept certain input, for discussions sake, say it does not allow null arguments. How do you go about implementing that, taking into account this method is likely to be reused in the future by new team members. The way I do it is: In the interface, I document inside the method javadoc that arguments a, b and c cannot be null. Inside the method I check for null values first thing, and if any of a, b or

How to write gnatcheck rules

陌路散爱 提交于 2019-12-22 22:19:53
问题 Is it possible to write your own gnatcheck rules, and if so, can someone point me to a good reference? I am searching for a particular "style" that is being used, and would love if I could simply write a rule that says if you see said style, it will throw up a warning, or an error, this way we can flag when this isn't following a particular standard. 回答1: A bit of background may be helpful here. While the style checks hold out a lot of promise for enforcing user style guidelines, that isn't

What's the difference between these two approaches to namespacing?

删除回忆录丶 提交于 2019-12-22 18:26:41
问题 I've got the first file in my code directory as follows myNamespace.js var myNamespace = {}; Then my subsequent files can look as one of the two following ways. first (function (ns) { ns.DoStuff = function(){ // do stuff } })(myNamespace); second myNamespace.DoStuff = function(){ //do stuff } So what is the difference between these two methods? Both seem to work for me. Is there a more generally accepted convention? sorry, still new to javascript 回答1: You have an error in your first one, you

What's the difference between these two approaches to namespacing?

倾然丶 夕夏残阳落幕 提交于 2019-12-22 18:26:40
问题 I've got the first file in my code directory as follows myNamespace.js var myNamespace = {}; Then my subsequent files can look as one of the two following ways. first (function (ns) { ns.DoStuff = function(){ // do stuff } })(myNamespace); second myNamespace.DoStuff = function(){ //do stuff } So what is the difference between these two methods? Both seem to work for me. Is there a more generally accepted convention? sorry, still new to javascript 回答1: You have an error in your first one, you

Should a class constructor return a subclass?

霸气de小男生 提交于 2019-12-22 09:03:59
问题 Should a class constructor return a subclass? This is mostly a question about OOP style and python style. I have problem where I need to implement a general case solution and, for performance reasons, I need to implement an optimized solution for a specific input type. The input type depends on the user. Currently I've implemented this by sub-classing the general case solution to make the optimized solution. I've come up with the following example to help describe what I mean. from

x or y: acceptable idiom, or obfuscation?

女生的网名这么多〃 提交于 2019-12-22 08:59:10
问题 I have to extract values from a variable that may be None, with some defaults in mind. I first wrote this code: if self.maxTiles is None: maxX, maxY = 2, 2 else: maxX, maxY = self.maxTiles Then I realized I could shorten it to: maxX, maxY = self.maxTiles if self.maxTiles is not None else (2, 2) But then I realized this might be the most succinct and easily readable: maxX, maxY = self.maxTiles or (2, 2) Is the latter acceptable, or too hackish? 回答1: About, specifically, self.maxTiles if self

Are there issues using Dim foo As Foo in VB.NET?

こ雲淡風輕ζ 提交于 2019-12-22 08:57:11
问题 In a recent VB.NET project I adopted the naming conventions I'm used to using in C#. Namely, often calling a variable the same name as the class it references, only with a different case, e.g. Foo foo = new Foo(); // C# Dim foo As New Foo() ' VB.NET I find this is often the clearest way to write code, especially for small methods. This coding style obviously works fine in C#, being case sensitive, and because of the syntax highlighting provided by Visual Studio, it is very easy to see that