Rob Williams is a probabilistic Lean coder of Java and Objective-C. Rob is a DZone MVB and is not an employee of DZone and has posted 170 posts at DZone. You can read more from them at their website. View Full User Profile

Xcode Love Fest Reprise

08.16.2012
| 1727 views |
  • submit to reddit

There‘s not a lot of changes in Xcode 4.5 DP3, but what is there is pretty awesome. Guess we‘re still not supposed to talk about that.

Meantime, though, I wanted to revisit some of my gripes from before. My main complaint before was that the process of running selected tests was a huge nuisance due to the way the scheme editor works. I'm pretty much over that. I've been just creating a new scheme, adding the tests, then unchecking all but the ones I want to run. If you use the spacebar, it goes pretty quickly. Still kind of dumb, and we still can't run an individual test. But let‘s face that facts, though these little run shortcuts are there in eclipse, they are niceties: you can just comment out the other tests if they are getting in the way. Then you have to remember to uncomment them before committing.

I finally got logger breakpoints to work.. !! Xcode allows you to make a breakpoint and either add a log message or a debugger action. Turns out that for most things, the log message is not a great avenue to go down. The reason is getting the data into a form that will be output is an ugly pita. But, if you add an action, and use the po , then you will get what you want. And of course, you can go into subs, e.g. [[solarPosition solarNoon] description]. This is a great example of a touchstone inside Apple‘s tools that raise some really interesting questions. In the open world, we are used to open debates about these issues: loggers v. debuggers, adjusting levels, etc. Let‘s face the fact, the open method seems like the more democratic, adaptive approach, but have we really seen much adaptation? Loggers in the Java world look little changed from the first ones a decade and a half ago. Furthermore, the amount of grief they have caused is completely looney. When I first started doing O-C I thought NSLog was super stupid. Not thinking that now. Anyway, this is an interesting touchstone because it seems that though in the Apple world there is not a lot of open mentation about what to do, very often the resulting strategies that are adopted seems suspiciously like they have been shaped by the failures of others (ARC being another prime example).

The breakpoint log stuff I would give 4 stars right now. I was completely blown away by the WWDC presentation on the new debugger, which supposedly has the whole type system in it. The fifth star would be making it possible to do simple expressions in one fluid mechanism. What‘s there now is not that much of a hassle and maybe after I have been using it, I will reverse myself (as I did on the scheme editor). One important point about this is that you can stack a bunch of things on top of each other, so if you want to show how many times your breakpoint has been reached, add a log message with the count in there (%H), then just add another action and do the po command to see whatever variable you are interested in.

I still need to fiddle with saving some of these breakpoints into the shared section of the project. That‘s pretty cool too. The only ting I wonder about here is that seeing some logging in the code often helps you get setup to work on a particular part of the code. But just running one time with the breakpoints turned on will probably get you to the same place.

Redux on the logging stuff: still firmly in the debuggers are evil camp, preferring to have the code explain itself, but the dream of the logger in the Java world is a failure, sorry. We very rarely actually use levels properly, doing things like the SMTP handler almost always turns into a nightmare, and as Meyer points out, the logger statements end up clogging up the code, etc. But there is no replacement for what I call the engineering version of psychology‘s talking cure: code needs to explain itself. So once again, Apple is not an also ran in development, in fact, I think they are trailblazers. The last question is how to explain this. One of the simplest explanations is that when you get a ton of really smart people together and they can agree on strategies than support each other, they are going to outperform a community in which there is no real adoption of consensus and sniping is an accepted feature of all development (more on that later)..

I have one final gripe about Xcode: one of the best things eclipse added was that when I type an expression, and I reach a terminus position in the expression, it skips me out past that character so I can just drop the semicolon and move on. Xcode should be able to do this easily since in Obejctive C, we use []s all over the place. It‘s already really smart about where to put the brackets. If I have an expression, e.g. self.solarNoon and I want the description, I can add description then the closing ] and Xcode will put the opening one in the right place. This is a pretty minor request, but it would make a huge difference.

 

Published at DZone with permission of Rob Williams, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)