Interested in programming and app development? Our veteran programmer, Tim Park, shares some of his beginner tips for programming. Check them out below:

Learn keyboard shortcutsprogrammingSince programming involves a lot of typing, I try to avoid using the mouse whenever possible. So if I need to do any file operations, I’ll generally do them at a command line with cd, pushd & popd, mv, cp, rm, open, etc instead of mousing around. When I started using OSX, I thought it was cool that you could do Command-tab to switch windows like Alt-tab in Windows, but found it odd that windows of the same type were “grouped together”. I soon found that Command-` (backtick) could switch between windows of the same application. Command-shift-3 for taking a picture of the screen was weird, compared to “printscreen”, but oh well. (OSX keyboard shortcuts) Sometimes you can even create your own shortcuts. My old netbook doesn’t have PageUp/PageDown keys, so I used AutoHotkeyto map them to Ctrl-Up and Ctrl-Down.

 

Don’t put spaces in filenames

This is arguably a matter of opinion (they really irritate me), but depending on your workflow they can be a major hindrance. At the command line, you have to either put the filename in quotes, or put a backslash before each space. (to distinguish a space in a filename from a space that separates arguments) Forbidding spaces can also save you headaches if you have to use certain tools like “make”. I’ve been given a cocos2d-x project that built fine for iOS, but the Android toolchain isn’t happy about the filename spaces. Similarly, be careful about naming. Project names like “example-project” and “com.company.2examples” were fine when compiling a cocos2d-x project on iOS, but not on Android.

 

Watch your data formats

You can end up with a lot of wasted space if you’re not careful. Going from >250MB to 10MB in animation data in the previous entry was an extreme example requiring a lot of work, but figure out what formats your platform supports and see how much you can compress your assets before they look or sound bad. Some things to look at include the following:

Graphics: Codec and settings, resolution, colourspace (e.g. RGBA8888 vs RGBA4444), frame rate
Audio: Codec and settings, KHz, number of channels (stereo vs mono)

Before I started on Office Attacks, the sound was being stored in DVD quality, or 48KHz stereo, since those were the default settings used in a sound tool. Sound effects really don’t need that high fidelity, so I converted them to 22KHz mono for large space savings. And although PNG is lossless compression, there are settings that affect the amount of compression, and it depends on the contents of the image, so no single one is “best”. There are tools like OptiPNGand pngcrush to help you. (PNG may not be appropriate for your project, but it’s just an example) To see what’s taking up space, I cd to the .app directory in the simulator folder and do “du -k | sort -n”.

When I needed to free up space on my iPad I found that a sudoku app was using 100MB. A hundred megabytes. I don’t know what caused it to take up that much space but now it’s beenBALEETED. The bigger your app, the more likely it is to be on the chopping block when the user needs to delete something.(In comparison, Sudoku 7 by another local company uses <10MB) Also, try to remember to delete old or placeholder assets that are no longer used.

 

Keep notes

8Y0EDX4VP9

Although there are email histories and chat logs to remember things for us, I also have a text file to save random snippets that might help me later. Error messages, test results, helpful commands or settings I haven’t memorized, you name it. At my previous job we had an internal wiki, so I asked Steve to install Confluence, since we’re already running Jira for bug tracking.

Have any general tips of your own for programming? Leave them in the comments below.