September 24th, 2008 Rusty
My brilliant tidbit of iPhone SDK advice today is to ignore the message that xCode gives you when compilation fails and just accept that something is messed up and now you need to put on your utility boots and start digging.
There aren’t very many different compiler error messages, so “syntax error before” should be read as “start here and work back”
My issue today was that I had a circular reference. The problem manifested itself as the above error message. The actual line where the build result console pointed me to had absolutely nothing to do with the problem.
How DID I find the problem? I started deleting s#&@. I started from the line that was listed in the compiler error. I’d delete that line, build. The “syntax error before” would go away but now I had an undeclared variable. I’d delete an #import. build. AFter going to lunch and proceeding with this approach for about two hours, I deleted an #import in a file three imports away and 80 errors suddenly popped up. Yep every single one of them “syntax error before”.
The solution was simple but not very exciting. leave the #import in the “.m” file unless it is part of the interface.
So there is my second tidbit today: don’t #import anything into you “.h” that your “.h” don’t need.
Posted in iPhone SDK | No Comments »
September 14th, 2008 Rusty
On this one, I’ll be short and sweet. Read Apples memory management paper.
Objective C memory management, simplified - or - head, meet wall. repeat.
Here are the golden rules that I’ve discovered to overcome the EXC_BAD_ACCESS monster.
- When you create a pointer, its just a pointer. for example: NSString *someString; There’s nothing there yet. When you assign value, you have a pointer to some allocated memory space. This is true in all programming languages, we just tend to forget as many modern languages abstract this away from us.
- If you reference something that you received from a method, don’t release it. for example:
NSArray* resultSet = [entropyRepository queryWithClass: classType];
I didn’t allocate or create that array, its not mine to release. When my pointer goes out of scope, it will decrement the reference count. Whoever created it is ultimately responsible for its release. It may be auto-released or the creator may have a dealloc method. However, if you release it, somewhere down the line, the originator may try to access it and you’ll get "EXC_BAD_ACCESS". Unfortunately, this error will occur sometime in the future, long after you’ve made your mistake. This was happening to me when the autorelease pool was being processed and I’d already released that array when I was done with it. Ooops. There went a week of "head, meet wall. repeat".
- If you use "alloc", you need to release the referenced memory. Basically, "alloc" is, "initialize this memory space for me." If you don’t release it, it’ll just sit there, forever and ever… You can opt to use autorelease or you can explicitly send a release message.
- In addition to alloc, methods used to get a reference that "create" an object using a method whose name begins with “alloc” or “new” or contains “copy” are yours to release. This rubs me as hack-a-logical as it leaves so much up to naming conventions. But, whatever…
Posted in Programming, iPhone SDK | 3 Comments »
September 12th, 2008 Rusty
This morning I needed to copy a 300 MB file from my dev server to my local machine. I was lazy and Windows Explorer was already open. So I called up my ftp:// url and copied the file to my local folder. It showed 1 hour and some odd minutes to complete. That’s an amazing 50k per second! Wow… broadband has brought us so far.
2 hours later, the dialog stated 39 minutes remaining. Hmmm, perhaps that initial prediction was a little fuzzy. Vista must be applying some fractal logic to determine how long things should take. Then, KABOOM. "Windows was unable to copy the file"
Now I remember why I started using FileZilla and why I stopped hating ftp.
So I launched old FileZilla, connected to my same server, and copied the same file. Now I can see that it, indeed, is achieving around 40k per second. FileZilla handles communication issues much better. I failed to time it but I was able to leave the transfer window minimized and continue on with other work.
I still don’t like ftp but no-one has really come up with a great alternative. Although I am now checking out Drop Box. Looks promising…
Posted in Programming, Windows | No Comments »
September 11th, 2008 Rusty
Aw, shucks guys, you rock! The Asp.Net team: Scott "Gu" Guthrie, Scott Hanselman, Phil Haack, Rob Connery
Preview 5 was released last Thursday. I’ve been buried in iPhone development so hadn’t seen that till this morning. Reading the release notes was like receiving a "thinking of you" card out of the blue when you’d been away from home for a very long time. If I sound dramatic, go build yourself and Objective C project and then fire up Visual Studio and write some Asp.Net MVC. Its like jogging with 20 lbs ankle weights for 3 weeks and then coming back to naked ankles. …but I digress.
Preview 5 brings many of the kick-ass features I missed form Monorail and was hoping the Asp.Net MVC team might build for us.
Model Class Binding
My favorite feature is "model binders". This allows you to declare your action parameter as a strongly typed class instance and then marshall the request values into an object before you even hit the action. Monorail had this built in as a convention where you could pass [param name].[property] from a request key and it would be initialized. For example: given a class called "Car" with a property "TopSpeed", you could declare your action signature to be: public void Add( Car car) and then, in your html, pass <input type="text" name="car.TopSpeed" /> and magic would instantiate your Car class, set the TopSpeed property and pass it in your car parameter.
With Asp.Net MVC, you can write ModelBinders to map the request keys to your model class and perform any necessary initialization or validation. In addition, there a new ModelState collection that you can use for validation issues and awesome integration with the view side of things. At first glance. it looks like there’s a whole lot of extra work to be done to accomplish this. However, the team is planning to include standard modelbinder that uses the modelname.propertyname syntax for mapping incoming parameters. All this ModelBinder goodness is for extensibility in those cases where you want to be super special or where your class is not that uses the modelname.propertyname.
The validation is pretty slick. Personally, I use jquery.validate on the client side. The rules that Scott demonstrates reminds me of this jquery library and I have a feeling it wouldn’t be too difficult to write a validation helper that could emit the server-side rules as a jquery registration. While the jquery plugin does an awesome job on the browser side, it can be bypassed easily and having a server-side backup would be excellent.
Posted in Asp.Net, Mvc | No Comments »
September 10th, 2008 Rusty
Gotta do what you gotta do
While there are several posts online recommending complete disregard for jury summons, I don’t have stones for that. I also have a propensity for getting in trouble when others breeze right on by. If, on ten occasions, I am pacing with nine other people speeding, the cops will pull me over, ten out of ten times. Additionally, I believe there are few things as inefficient as state government and I really don’t want to contribute negatively to the overall system. Finally, If I find myself on a jury someday, I would want someone like myself to be available for that selection even though I detest having to be a part of something so inefficient and poorly executed. At its core, its this jury of peers that makes our government "of the people" and I would find it immoral to shuck this responsibility. Of course, I still hope to never be summoned again.
Pain Avoidance
Getting There
The address is 185 Central Ave.
Get a ride, Avoid Traffic
If you can get a ride, I recommend it. Marta constitutes as a ride. If you are driving, avoid the Interstate. My Google Maps got me close. You’ll see quite a lot of people entering a building on the West side of Central Ave just north of Mitchel St.
Arrive Early, Avoid Lines
Get there early. When I arrived, there were hundred of people standing in a coiling line. Its like airport security except you can leave your shoes and belt on and there are a lot more armed police there to take you down if you get out of line.
I can only assume that 20 minutes would have saved me a lot of standing and being barked at by the officers greeting the assembly.
Once upstairs, there is another line to wait in. You’ll be checked in and can proceed to your seat.
Getting Connected
If you brought a laptop, as I did, there are tables. There is "free public wifi" but my mac couldn’t connect to that. However, there is also another strong, non-secured signal. I had no problem getting connected.
Power is at a premium. If you sit at a large table, there are a couple of outlets. Bring a compact power splitter (surge protector) and you’ll be a hero.
Settled In
Ok, so getting there and getting to a seat was not a lot of fun. I felt very bad for the people sitting on the floor and standing through announcements and "the video". However, everyone was so very polite and respectful that I almost felt privileged to be there. In this forum, every person is genuinely appreciated and no one makes any claims that the system isn’t flawed. In fact, they joke about it. They make you realize that the flaws are, in fact, the strength of our system. Its that malleability in our government that empowers change. On the other hand, change is definitely needed in the juror recruitment process. It is inexcusable to call over 400 people into a room with fewer uncomfortable chairs than jurors and then make them all sit there, all day, while highly compensated lawyers abuse their role as legal representation and disregard the cost of unpreparedness both to the court and the individuals who should be at work, school or with their children rather than doing absolutely nothing all day.
Posted in Blogging | 1 Comment »
September 10th, 2008 Rusty
I have may directions I could go with this. I could talk about an experience I just had with an individual who I had a disagreement with. I could generalize the concept and talk about how most of us believe narcissist are the stereo-typical, upturned nose character who is fully aware of their superiority complex. Instead, I’ll personalize it and share what I’ve learned in hopes that someone might identify and grow from it.
Hello Narcissist
I used to have a very hard time with relationships. My usual M.O. was to fall victim to some oppression, then to become a pesky antagonist to the oppressor, then I’d suddenly find myself saving the day and I would briefly be the hero. Of course, I’d then find myself persecuted for over-achieving and I would, once again, be oppressed…
For this cycle to succeed, I needed triangles. I needed someone to hate on and someone to confide in. I needed an ally and an enemy. I usually found myself, conveniently, between two existing foes.
All of this was made clear to me when I sought therapy to deal with relationship issues that I couldn’t make sense of. It astounded me how quickly the psychologist was able to identify patterns in my past that were so logical and so repetitive. She was able to tell me more about my family and growing up then I was able to tell her. Of course, she is a practicing Ph.D. psychologist for 22 years teaches at GSU and Emory University School of Medicine has worked with the Kennedy School of Government of Harvard University. Experience matters.
What she did, rather than tell me what was up, was give me a book. Trapped in the Mirror.
In this book, many painful scenarios are illustrated in which one individual behaves in a way that is passive-aggressive and emotionally abusive to the other. In reading the review on Amazon, you’ll find those who feel the book is spiteful and depressing and those who feel the book is enlightening. I fell into the latter group. I couldn’t finish the book. It was too familiar, too emotionally challenging to relate so well to these relationships. What I did read was enough to establish a pattern of behavior that I could now identify and explain.
Not your momma’s narcissist
When considering narcissism, most of us think of the person who walks in the room and acts like they own the place, talks down to everyone around them, and behaves like Napoleon returning home from successful conquest. The truth is that most people afflicted with this condition manifest it by "organizing their lives around denial of negative feelings about themselves" rather than demonstrating superiority. The truth is that most narcissists will outwardly appear to be very humble. They will speak of self sacrifice and the greater good. In the process, however, they will blind themselves to any consideration for their actions and how they affect those around them. They get so good at it that they become incapable of observing themselves or the perspective of others. Its as if they could stab you in the face and then absolutely believe it wasn’t them who did it.
To break the cycle or be consumed by it
Earlier I said that I was a narcissist. I’m actually more of a recovering narcissist. Once you are aware of the condition, you have the capacity to break the cycle. You have to work hard to put yourself in other people’s shoes. You have to accept burdens that you’d rather discard in order to prevent history repeating itself. You have to learn to recognize triangles and dissolve them fast.
Today I tried to handle something by directly addressing a problem that I thought could be resolved with a simple communication of my perspective. Narcissist behavior number one. I then brought another individual into the conversation to validate my position. That was both narcissism and triangle making. Finally, the whole thing dismantled and a snowball of dysfunction began to form.
The only ting left for me to do is ride out the storm. I find comfort in the fact that I can realize this was completely my fault and I made several judgement errors.
I watch my son grow and I see in him glimpses of myself and of my brother and I wish so badly to have a richer relationship with him when he is my age then I have with my parents. I believe I can create that reality but I have to constantly remind myself that I am predisposed to repeat history and every step I take must be a deliberate one that is not shrouded by my own, narrow, personal perspective.
Posted in Blogging | No Comments »
September 5th, 2008 Rusty
I’ve been on google chrome for 1 day(s) now.  The whole office has pretty much switched.  Its amazingly fast.  In fact, my post about SugarCRM slowness can now be amended to state that SugarCRM with Google Chrome is awesome!Its unbelievable what a remarkable difference  this new browser makes on a site that was completely unusable before.Considering that Salesforce.com would have cost us appx $400/mo for our small shop, I am quite pleased with the way two free apps came together to save us alot of jinga.We’re also using Google Apps for Domains so Google is now on both sides of our CRM.  wow, scary.   Â
Tags: Google, SugarCRM
Posted in Blogging | No Comments »
September 4th, 2008 Rusty
I really, really want to be balanced in my discussions regarding the iPhone SDK and Cocoa/Objective C. Its been tough. But an ahah just occurred and I feel its important to lay it out there.
http://github.com/aptiva/activerecord/tree/master
Take a look at the instructions for how to use it. The dynamic nature of Objective C, in that it uses a messaging paradigm for calling methods, means that an inheritance hierarchy can provide structure and guts. That’s cool!
Much like dynamic, interpreted languages (Ruby, Python, Asp classic), you can exercise much freedom with how your objects interact, construct themselves, etc. You also get strong typedness and the performance that comes with that.
In this example, by #import(ing) the active record framework… you can
- Create the table in your database
- Create a model class named as the singularized version of your table name
(people -> person)
for a table with:
id as the primary key
firstName as varchar(255)
lastName as varchar(255)
The required code would be:
person.h
@interface Person : ARBase
@property(readwrite, assign) NSString *firstName, *lastName
@end
person.m
@implementation Person
@dynamic firstName, lastName
@end
That’s it.
Now you have active record capabilities
NSArray *people = [Person find:ARFindAll];
Person *person = [people objectAtIndex:1];
NSLog(@"%@ %@", person.firstName, person.lastName);
Posted in iPhone SDK | 2 Comments »
September 4th, 2008 Rusty
My brilliant tidbit of iPhone SDK advice today is to ignore the message that xCode gives you when compilation fails and just accept that something is messed up and now you need to put on your utility boots and start digging.
There aren’t very many different compiler error messages, so “syntax error before” should be read as “start here and work back”
My issue today was that I had a circular reference. The problem manifested itself as the above error message. The actual line where the build result console pointed me to had absolutely nothing to do with the problem.
How DID I find the problem? I started deleting s#&@. I started from the line that was listed in the compiler error. I’d delete that line, build. The “syntax error before” would go away but now I had an undeclared variable. I’d delete an #import. build. AFter going to lunch and proceeding with this approach for about two hours, I deleted an #import in a file three imports away and 80 errors suddenly popped up. Yep every single one of them “syntax error before”.
The solution was simple but not very exciting. leave the #import in the “.m” file unless it is part of the interface.
So there is my second tidbit today: don’t #import anything into you “.h” that your “.h” don’t need.
Posted in iPhone SDK | No Comments »
September 3rd, 2008 Rusty
I’ve heavily embarked on my journey into iPhone sdk development and have made tremendous progress as I slowly iterate through v1 of our Ockham Research Idea Generator. The experience has certainly humbled me and made me appreciate Visual Studio more. I am not a C++ programmer so I must start from ground zero and learn a number of things I already know how to do on other platforms and in other contexts. Its frustrating to consider yourself an expert in software design and engineering yet find the simplest problems elusive and hard to overcome. This such as setting background colors, initializing screens, converting variables, appending strings, memory management and object construction are all common, basic concepts but have proved unusually inaccessible coming from a Microsoft and web development background.
I hope others may grow as I go
I plan to post regularly about the things that I learn about developing for the Mac OS platform. Specifically, I am targeting iPhone but most of the concepts are applicable. Objective C is the language of choice for iPhone development, although you can also use C or C++ (though I haven’t tried). Objective C is weird, no other way to put it. The latest Obj-C supports dot notation for properties but I just find that convenience confusing and inconsistent. "Do or don’t," I say. Rather than dots, you pass messages using brackets. The messaging capabilities are interesting and powerful. The brackets become familiar after a while and the common conventions start to look rational once you’ve been staring at it long enough.
iPhone is Cocoa
The short of it is: if you don’t find an answer in iPhone resources, try Cocoa resources, forums and docs.
Cocoa is the mac framework built in Objective C and is pretty much the equivalent of the Microsoft.Net framework. You build against the framework and your app benefits from the abstraction of details that you should not have to care about. It evolved from the NextStep platform developed by NeXT around the time the Delorean first went back to the 50’s. While the full OS X Cocoa platform has modern features like automatic garbage collection, the iPhone OS is stripped of these novelties. It is remarkably easy to crash your app doing nothing more than loading lists. Once I’ve gotten a little further, I will pick up a good book on Cocoa development and familiarize myself with where this all came from. I’m sure that will help. If you have the time, do that. Otherwise, I hope you can gleam enough from me and others like me to clamor through the bits you need.
Objective C
I really don’t care to add more languages to my alphabet soup list of 1001 ways I can skin a cat. Nonetheless, I now have another C based language to paste into my presenter bio. If it were really interesting like Ruby, or really prolific like PHP, I’d be less irritated. Sorry, I am irritated. I am sure I’ll find the magic books/forums/tutorials that answer all the questions I’ve had but, for now, its like I am trying to join some secret society where I have to prove myself before I’ll be granted my practice manual. The thing that makes it hard is that Apple seems to be telling folks not to help them educate and share with the community. Apparently, posting tutorials violates their NDA. I hope I don’t get an email stating that my opinion is covered in Section 4a of the developer agreement. I will check just to be sure
Resources are hard to find
The advantage that Ruby, Php, Javascript, JQuery, Python, Xsl, C#, yadda, yadda, yadda have is that you can Google for answers. Objective C documentation is often behind a password so that single, tiny, obscure, wonderful tidbit of eureka is buried in a 300 page Tome that you cannot see unless you log in. Therefore, simple things are difficult to figure out.
When you do find something, its nasty
Here’s the thing that’s really tarnished my opinion and caused these many paragraphs of whine… No offence to all the bright, clever YouTube kids out there who spent their summer hacking the iPhone instead of lighting their GI-Joes on fire like I did (in fact, many kudos), but a decade of programming has taught me a lot about how to program but even more about how not to. I’ve learned though trial and error, and more error, and how the hell to I troubleshoot this error, how to structure my programs so that its less costly down the road when something needs to change. Its not a matter of if, its a matter of when, will it will change. When it does, you’ll either be glad you took the time to design strong object oriented concepts and design patterns into your program or you’ll be very angry that you (or someone else) didn’t. Unless you need practice cursing or just want to expand your slang vocabulary, you’ll want to practice good design.
The iPhone tutorials out there will get you from XCode to button click but should you really load the next view in the event handler of a button click? And should you load all the data that your view needs inside the loadView method of the View? The answer to that is, "No." This is not the place for design patterns and such but I will try to cover that going forward. You can design iPhone software well, its just not the default.
I’m a Windows programmer who switched to Mac for all its charms
I’m still a Windows programmer and I love Visual Studio now more than ever. I love C#. I absolutely enjoy programming web applications and services on the Windows platform. I derive great pleasure from launching Vista inside VM where it can do me no long term harm. I delight in having the ability to continue working while being Vista’d as Windows updates cripple my Windows VM. When I am not programming, I love to surf the net using Safari, watch TV on my AppleTV, or do just about anything on the iPhone.
While Microsoft spoiled me with Visual Studio and massive developer support, Apple is the expert in consumer devices and user interface. Perhaps there is some prestige attached to being a Mac/iPhone developer. On the other hand, I would like to build upon the strong community I have experienced in the MS development world and perhaps build some of that in the iPhone developer arena.
My next post will be technical. This one was just to explain why (and get it off my chest)
Posted in iPhone SDK | 6 Comments »