Taken with instagram
John Cleese - “A Lecture on Creativity”
John Cleese lectures on the topic of creativity.
Per Back to Work #62: Cultural Molasses.
Seriously: this wonderful video has had a huge impact on how I think about creativity. For years.
Unfortunately, the copy I’ve had and repeatedly enjoyed “fell off the back of a truck,” so I had no way to share it.
Now, (via danforth), I can finally share and highly recommend it.
And, I really, really do encourage you to watch it. Really. All the way through. It’s just terrific.
Extremely connected with something a bit newer by Jonah Lehrer:
I know it is wrong to put NSLogs everywhere in the code, as they usually just clutter the console log at the point of losing its purpose (or at least part of it). Sometimes however you just want have an easy way to get some feedback in the order of: Is this method even being called?
Well, to do that I device a macro which is printing not only the classic log text but also from which function it is coming (in the style of [Class method]) and the line on the file.
#define MYLog(err) NSLog(@"Log: %s (line n' %d)\n%@", __PRETTY_FUNCTION__, __LINE__, err)
Unfortunately __PRETTY_FUNCTION__ is not defined in C++, in which case you are better off with something like this:
#define MYLog(err) NSLog(@"Log: [%s %s](line n' %d)\n%@", __FUNCTION__, __FILE__ __LINE__, err)
Colto dal classico raptus di psicologia inversa dopo il post di gluca, ho deciso di mettere nero su bianco le motivazioni che guidano la mia idiosincrasia per ogni tipo di infografica. Quelle enormi immagini colorate che raccolgono, nella maniera scientificamente più scomoda ma…
Unit testing is brilliant, it automates things and give you the peace of mind that nothing is going to break in the code you write - at least nothing you know of!
Another brilliant thing are blocks. Since their introduction in iOS4 I started to do a massive use of them; they just make everything more tidy and they solve some implementations that would be otherwise almost impossible. Also they make easier to work with background threads.
Unfortunately blocks with background capabilities do not work well with unit tests, at least out of the shelf. This is happening specifically for the reason that the assert methods implemented inside the block may not even being called because the entire suite of tests got the end before it.
As solution for my projects, I have defined a parent test class from which all the other test classes inherit with the only intention of having a boolean attribute and then I have a while loop which is checking for that boolean in the tearDown method. Inside the block I change the boolean to YES and in the next runloop the tests exists.
By default I set done to YES in the setUp method so for all the tests that do not use blocks I do not need to bother about the done variable.
Here is the code:
Parent Test Class:
#import <SenTestingKit/SenTestingKit.h>
@interface MainTests : SenTestCase
@property (nonatomic, assign) BOOL done;
@end
————————————-
#import “MainTests.h”
@implementation MainTests
@synthesize done;
- (void)setUp
{
[super setUp];
done = YES;
}
- (void)tearDown
{
while (!done) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate: [NSDate distantFuture]];
usleep(10000);
}
[super tearDown];
}
@end
Another children Test Class:
#import “MainTest.h”
@interface AChildrenTests : MainTests
- (void)testFeeds;
@end
———————-
@implementation AChildrenTests
- (void)testFeeds {
self.done = NO;
[AClassWithBlocks collectionForUserName:@”username” completed:^(id data, NSError *error) {
STAssertNil(error, error.description);
STAssertTrue((data && [(NSArray *)data count] > 0), @”Feeds shouldn’t be nill or empty”);
self.done = YES;
}];
}
@end
As iOS developer I do tests most of the code I write, but sometimes, in order to test a piece of functionality you have to recreate the environment of the user actually using your app for a certain period of time. This is true for most of the apps out there and even though the majority of the bugs would show up at any stage of the user iteration for other is necessary just, well, use the app. I am thinking about components like charts, multi user controllers etc.
Of course you can and should use testers to do that, but sometimes is easy to lose yourself in all the back and forth between you and the tester until the bug is really fixed.
In order to avoid this problem there is a good programming technique called data injection, where you programmatically populate your application with some fake data in order to be able to check the result of some operation ready after the app has been compiled and installed.
What I have found fascinating is that in Xcode you can create a specific target for this purpose, or better you would duplicate your active target, rename it in something more suitable like “Your App name Injection”. Then select your newly created target, go to the Build Settings, search for Other C Flags and enter something like:
-D YOUR_FLAG_NAME

Once you have created your flag everywhere in your code you can then create conditional pre-compiled statements like:
#ifdef YUR_FLAG_NAME
//your injection code here
#endif
Now, only if you compile and run the Injection target this conditional statement will be compiled, leaving the application save for all the other targets - as it should be.
As precaution it is wise to add the C flag only to the debug option, so that it is actually impossible to submit the application with the injection bit.
Dictionary Accessorizer is a small application that will help any iOS and OS X developer to easely initialize all the varaible of a class through an NSDictionary. Just past your property and you are ready to go.
The Mythical Man-Month, Frederick P. Brooks Jr.
~pag 55.
I am bouth, being sold,
Standing at the edge of the dark fall,
Holding tight to the last act of independence I have left.
Keep in mind:
“Do not attach big white Apple stickers around your possessions”
It’s not much, but it is still there and they won’t get it, God the won’t.
I guess it will be easy for me, I do not own a car, but still.
I maybe better write a note down, you know, just to remember,
Where is my Moleskine? There it is.
Oh crap!
I really do not know how I missed this feature or when it was introduced. I only know that this was the only thing that I was really missing from my early days of web development with NetBeans - or Eclipse for what matters. I know there where several suggested hacks using scripts and key bindings, but none of them looked as a pretty solutions, and in general was frustrating to see Xcode with suc han handicap.
So today, while furiously typing code, I just sow this line of code jumping up overtaking is parent one. WAT?! I try to get to the context of what I was trying to do and replicate the “mistake”. Long story short, my fat finger tapped the option key while I was trying to indent a line.
In practice to move the line where the cursor is or multiple line selected
cmd + option + {
and to move the same down
cmd + option + }
Hope it helps.