Subscribe to
Posts
Comments
NSLog(); Header Image

OO Ohhhhh!!!

Object-Oriented Programming. OOP. Flip it around and you've got poo, which Justin Williams seems to think OOP is at this point. In his words, he doesn't get it.

I've met people who "get" things quickly and I've met people who struggle with things at first. Neither kind of person is stupid. Oftentimes, the second person simply hasn't found the right paradigm or mental model. For example…

I "got" pointers right away. We were learning C++ in college and pointers were introduced. "Ahhh, I see, I get it." I didn't really understand why I got them - I just did. However, I've now taught some level of programming to a lot of people, and for Mac users, the mental model I often use is the Mac's "alias" system.

If you think about it, this might make a lot of sense. An alias is a small (usually 4kb since HFS+) file that points to a larger file (14 MB, whatever) somewhere. Accessing (double-clicking, etc.) the alias accesses the original chunk of disk space, regardless of where it may actually be on the disk or in the file system. I can drag an alias for a TextEdit document onto BBEdit, "passing the alias" to BBEdit for editing (of the original document). It's a model that's held up pretty well. You can even delete an alias, copy an alias, etc. as you can with pointers (though this is the point at which the model breaks down a little bit, since in the filesystem, you can always find the actual file again if you delete all aliases to it). For introductory programmers, though, this helps them "get it."

The Model-View-Controller, or MVC, paradigm (every time I type "paradigm" I think of Dilbert cartoons) put forth by Cocoa (and other frameworks, languages, etc.) is a good one. However, I too am guilty of goofing it up from time to time. MailDrop isn't pure MVC, nor are some of the other products we've got. MailDrop 2.0 will be - at least it's a design goal - but that first version was not because we didn't have the foresight to plan the features - and where they'd go - when we began coding.

I'd say that MailDrop 2.0 will be a total rewrite, but frankly, that's silly. We'll move a lot of stuff around, refactoring things into new classes and objects, but 75% of what we've got will remain nearly intact. We'll then add to those new classes and objects, and plug in new classes and objects, and bada bing, bada boom: MailDrop 2.0.

So, Justin, keep battling. I "get" OO programming in Cocoa, but I've somehow yet to do a completely OO PHP site, reverting to procedural methods too often. Why? I don't know. But when I find the right paradigm, I'll be sure to write about it here.

6 Responses to "OO Ohhhhh!!!"

  1. I don't usually go for OO in PHP either. I did it once and I picked a bad project--way more work than procedural methods. Rumor has it that PHP 5 will kick some object ass. Let's hope!

  2. It's funny how everyone's brain is a little different. I've always thought the easiest way to understand pointers is to actually draw out what's in memory. You draw a little box and write an address in it instead of a number. Analogies rarely have worked for me in programming, because they're rarely perfect. I think of a Mac OS alias as more like a handle than a pointer, because if you move the file the alias still points to it. (But if you think of it at a lower level, moving a file doesn't change its file system address or the contents of the alias, so in that sense it *is* like a pointer.)

  3. I must be backwards from Justin because I seriously don't know how I would program anything of any size without OOP. I have a hard time managing procedural code - it just starts running everywhere. OOP forces me to organize and think about the problem I'm solving.

    Except, like you said PHP, because well ... OOP in PHP sucks. That, and I use Fusebox for most of my PHP applications.

  4. I suck at conceptualizing applications. I've tried to use things like OmniGraffle to sketch out the program but I leave stuff out all the time. Ugh.

    Also, MVC is like... it's like a layer of fog over my understanding of itself.

  5. Object Oriented Programming

    So, lately on a few of the weblogs I read on a regular basis, there has been some talk about Object Oriented Programming and the Model View Controller (MVC) model that one is supposed to use when programming in Objective-C. As a former C++ programmer (...

  6. Yeah, OOP in PHP does suck. But like Steven, I use OmniGraffle to lay out my apps. Helps a ton with class hierarchy and stuff. But oh man, MVC is the best thing that happened to clean programming since, well moving from asm to c 😛


Comments RSS

Leave a Reply


Warning: Undefined variable $user_ID in /var/www/vhosts/nslog.com/httpsdocs/wp-content/themes/nslog/comments.php on line 96

Please abide by the comment policy. Valid HTML includes: <blockquote><p>, <em>, <strong>, <ul>, <ol>, and <a href>. Please use the "Quote Me" functionality to quote comments.