code-organization

Game object with composition and CCSpriteBatchNode

一个人想着一个人 提交于 2019-12-13 01:35:10
问题 I'm currently developing a game with cocos2d and box2d on iPhone. I read a lot of articles concerning game code organization, game objects structure etc. I first started developing my game objects by inheriting from a base class itself inheriting from CCSprite. I had a CCSpriteBatchNode to draw all the game items, which the player can interact with, in one draw call. This was easy because my Item class indirectly inherit from CCSprite so I could easily add my items to the CCSpriteBatchNode.

Nice pythonic way to specify django model field choices with extra attributes and methods

帅比萌擦擦* 提交于 2019-12-13 00:23:25
问题 How can you specify choices on a django model such that the "choice" carries more information than just the database value and display value (as required by django's choices spec)? Suppose the different choices have a number of config options that I want to set (in code) as well as some methods, and the methods may be different between different choices. Here's an example: class Reminder(models.Model): frequency = models.CharField(choices=SOME_CHOICES) next_reminder = models.DateTimeField() .

Objective-C Category Performance

若如初见. 提交于 2019-12-12 11:42:51
问题 If I used categories to break up the implementation of my Objective-C class into multiple @implementation blocks, would that make the resulting binary of my iOS app larger or affect performance at all? Apparently, you can't Obtain details of categories on a class at runtime?. So, shouldn't the resulting binary be identical with or without categories, assuming all else equal? Background I have a custom subclass of UIViewController that's getting rather complex. iOS Developer Library :

What is this dashed line called that aligns function blocks in my IDE?

余生长醉 提交于 2019-12-12 10:59:26
问题 The SPE IDE that I use for my Python code uses this "visual cue" that looks like a vertical dashed line for alignment of (what I would call) function blocks. How can I get this option in Visual Studio 2008? Here is what it looks like: 回答1: I've seen it called structural highlighting or code outlining. There's a Visual Studio plug-in called CodeRush from Developer Express that supports this (bottom of the page) and a lot more. update: As divo mentioned, there is a free lite version of CodeRush

Where do the Python unit tests go?

若如初见. 提交于 2019-12-11 12:25:58
问题 If you're writing a library, or an app, where do the unit test files go? It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. Is there a best practice here? 回答1: For a file module.py , the unit test should normally be called test_module.py , following Pythonic naming conventions. There are several commonly accepted places

How many repositories should I use to maintain my scripts under version control?

流过昼夜 提交于 2019-12-11 07:22:03
问题 I mainly code small programs for myself, but recently, I've been starting to code for my peers on my team. To that end, I've started using a Mercurial repository to maintain my code in some form of version control (specifically, Tortoise-Hg on Windows). I have many small scripts, each in their own directory, all under one repository. However, while reading Joel's Hg Tutorial, I tried cloning a directory for one of my bigger scripts to create a "stable" version and found I couldn't do it

Using open source libraries in Android projects

谁说我不能喝 提交于 2019-12-11 03:15:19
问题 I'm a beginner in Android programing, and I'm working with android studio...now i wander what is the best way for installing open sources libraries from gitHub. my question is from organization principles point of view- should i create a new package for every library and put all the library source code as is in that package? should the package be in the source.main.java folder?? (the one that the android studio creates automaticly). sorry for the dumb question...it's just that im taking my

Avoiding dependencies is exploding the number of projects in my VS solution

…衆ロ難τιáo~ 提交于 2019-12-11 00:36:26
问题 I'm working in C++; I'm new to Visual Studio and still trying to understand how to use it effectively. My problem is that I have what seems to me a fairly small, non-complex project, but I find myself adding more and more Projects to the Solution, and managing them is becoming unwieldy and frustrating. The project depends on a device, so I've defined DeviceInterface , and I've got FakeDevice and RealDevice implementing the interface. My core project Foo , I've written is a static library,

How to properly split a C program in files and include then?

末鹿安然 提交于 2019-12-10 15:43:36
问题 I organized my program splitting every entity in its own file. Which is something like this. main.c #include "student.h" #include "subject.h" #include "classroom.h" #define PI 3.14 int sum(int a, int b); student.h typedef struct st student; student.c #include "student.h" subject.h typedef struct sb subject; subject.c #include "subject.h" classroom.h typedef struct cr classroom; classroom.c #include "classroom.h" My problem is, inside classroom I need student and subject . How should I include

Why are the controllers on ASP.NET MVC name-based?

坚强是说给别人听的谎言 提交于 2019-12-10 12:58:35
问题 In ASP.NET MVC, we're required to use the suffix "Controller" for all controllers. This seems unnecessarily restrictive - is there a technical reason for it? I'm mostly just curious, but can see situations where more flexible naming rules could improve code organization. Couldn't the discovery of possible controller classes be easily made using reflection to search for Controller derived classes? Or require that controller classes be marked with a ControllerAttribute ? 回答1: The MVC community