9 ms·
Coding tricks I learnt at Apple
- sc68cal 15y agoWe had one, highly specialized piece of software code which could only be checked out, worked on, and checked in by a single engineer at a time. You were only allowed to touch this piece of code if you possessed a physical token. Ahh, the all powerful Source Control Shingle: http://thedailywtf.com/Articles/The-Source-Control-Shingle.aspx http://thedailywtf.com/Articles/The-Source-Control-Shingle.a...
- matwood 15y agoVSS did this with all files by default. Does that put VSS way ahead of its time? :)
- caseyboardman 15y agoNo. God no.
- sc68cal 15y agoI'd actually take a Shingle over VSS. At least a shingle can't crash and corrupt all your revision metadata.
- brown9-2 15y agoThis is really interesting and I would love to know what the code in question was responsible for. Requiring that work on it be done single-threaded like this suggests that some other part of the overall process broke down somewhere - the developers/automated tests/continuous integration server couldn't catch merge conflicts? Code reviews weren't done and made visible to everyone else on changes to this special code?
- sc68cal 15y agoGood question - though I don't think it's a problem of broken process, but an absence of processes like you listed above. That's when these types of "solutions" are devised/used.
- marshray 15y agoTwo things I've learned in my years as a developer: 1. Sometimes the best process is old fashioned communication between people with common sense. 2. Never underestimate the power of a rubber chicken.
- sc68cal 15y ago>1. Sometimes the best process is old fashioned communication between people with common sense. I most wholeheartedly agree. Git, or a Source Control Shingle cannot replace effective communication. In fact, a solving a merge conflict is much more painful than a quick discussion.
- SoftwareMaven 15y agoNot necessarily. It could be a particularly tricky and critical piece of code that they want to ensure nobody is "auto-merging" into oblivion. By putting a mutex on it, you are forced to re-evaluate the state when you obtain the lock. You can't sneak in a change in front of somebody else's change, requiring them to re-evaluate (or, worse, merge and hope). If it was required for modules all over, it would be broken process. For a single module, I can understand it.
- unshift 15y agono real tricks here, this guy just seems happy he worked on a team with professional standards. thorough testing like that is, while not the norm, pretty commonplace at most of the better places i've worked.
- prpon 15y agoYeah, I would have liked to see specific things he learnt at apple. Load testing tools, algorithms for caching, how and which metrics they measured etc. I am trying to figure out who would find this article useful without any details.
- ctdonath 15y agoThose who would find this useful are those who have not figured out that following these basic principles WORKS. Too many teams think bypassing mundane correct process will somehow buy them time. There is no magic or secret to great success, only doing things right all the time.
- deleted 15y ago[deleted]
- JoeMoreno 15y agoYup, I have to agree with you that I was very happy to work on a team with professional standards. While commonplace at high tech organizations, there are many non-tech organizations with their own tech teams which aren't aware of good practices since it's something that you have to experience, rather than be taught from a text book. That non-tech group is the one I'm really hoping to reach.
- benihana 15y agoWhen you're asked, during a job interview, which is the fasted lookup function, don't, as is very common, say, "a B-tree." Perfect hash tables always win, hands down. Wait, saying a B-tree is the common answer?
- thurn 15y agoFurthermore, B-trees are designed for storing things that don't fit into primary memory. They are the right answer for things like file systems, I think almost every file system uses some variant of them.
- lallysingh 15y agoSurprisingly not: https://ext4.wiki.kernel.org/index.php/Frequently_Asked_Questions#History_of_ext2.2C_ext3.2C_and_ext4 https://ext4.wiki.kernel.org/index.php/Frequently_Asked_Ques... http://www.geeksofpune.in/drupal/files/8058778-ext34talk.pdf http://www.geeksofpune.in/drupal/files/8058778-ext34talk.pdf ext2,3 used an indirect-block tree structure. Ext4 uses an extents system which is nicer, but still not (AFAIK, I've only skimmed this part) a B tree.
- seanp2k 15y ago>"Coding tricks I learnt at Apple" I'd wager "learning how to properly use 'learned'" wasn't one of them. http://www.urch.com/forums/english/9214-learned-vs-learnt.html http://www.urch.com/forums/english/9214-learned-vs-learnt.ht... "The descriptive answer in American English is: There is no such word as "learnt". Use "learned" always."
- maukdaddy 15y agoHate to break it to you, but not everyone on the Internets speaks American English.
- michaelcampbell 15y agoYou don't sound like you hate it one bit.
- michaelcampbell 15y agoThe article's title is "Tricks I Learned At Apple: Steve Jobs Load Testing"; the use of "learnt" must have been from whiskers who posted it.
- whiskers 15y agoI'm from the UK - learnt is perfectly valid here!
- michaelcampbell 15y ago<nod> I wasn't asserting that you were wrong, only that the user to whom I replied that implied the author of the article used it incorrectly was wrong in his assertion.
- smiler 15y agoWith that sentence construction, you could be a lawyer :)
- lamby 15y ago> We had one, highly specialized piece of software code which could only be checked out, worked on, and checked in by a single engineer at a time. Why? Also, is this common these days?
- tszming 15y agoIt seems to me that the author was very proud of the O(1) sophisticated caching algorithms invented at Apple.
- tptacek 15y agoHash tables are worst-case O(n) time. B-trees are an external storage technique; he means balanced binary trees. The answer to the interview question is another question: "what operations does the container need to support?". It's not "hash tables are O(1)".
- quacker 15y agoHe does say: "Perfect hash tables always win, hands down." A perfect hash table does have O(1) look-ups in the worst case.
- tptacek 15y agoI saw that. From the context of the article, do you think he was really talking about a system using perfect hash tables? Be that as it may, "use a perfect hash table" is rarely a good answer to the job interview question, which is the only reason I commented on this.
- bricestacey 15y agoSince they did load testing to optimize performance, I think his argument stands. If they didn't bother to optimize I would agree with you.
- aaronblohowiak 15y agoA really perfect hash table is just an array ;)
- groby_b 15y agoYes. So? There are lots of other constraints that come to mind. Do we do frequent insertions/deletions? What are the memory constraints? What is the size of the unhashed key? And many more... No data structure always wins.
- geocar 15y agoOnly if you neglect hashing time (significant with perfect hashes) and comparison-time. That makes them O(k), not O(1). It is helpful to me to think of hashing as expensive as copying. Radix tries on the other hand don't hash. They're always at least O(k), and you can find the next and previous values (lexicographically) in O(k) as well. They're also more compact and you never have to resize your tables.
- edw 15y agoPerhaps I'm too attuned to NDA issues after having listened to the most recent episode of Gruber's Talk Show (http://5by5.tv/talkshow/46 http://5by5.tv/talkshow/46), but I am guessing that this guy is coming dangerously close to — and is perhaps crossing — the line with respect to disclosing details about Apple's technology and software development practices. When in doubt, STFU. Not just for legal reasons, but also because you don't want future collaborators and employers thinking you're a Chatty Cathy who's going to tell everyone about your secret sauce.
- Luyt 15y agoJust what crept up my mind when I read the article. But then I realized: If American culture allows this kind of insight publicized, what boon that is to freedom of thought and freedom of expression! All around us we see civilians cuffed and murdered for their opinions (for example, in countries with dictatorial regimes), but apparently this is not the 'status quo' in the USA.
- phillco 15y agoI agree. He should remove the picture of that Darth Vader token immediately, it's clearly a very important Apple trade secret.
- JshWright 15y agos/Vader/Tater/
- kelnos 15y agoI wouldn't want to work for any company that'd take issue with an article similar to this one.
- edw 15y ago"Take issue with" is vague. Is someone at a company allowed to think, "Dude, you don't talk about Fight Club"? Is that too extreme a reaction? Or are you talking about the legal department filing a lawsuit. Or something in between? I don't think it's fair to expect Steve Jobs to hop in his helicopter and track down Joe Moreno so that he can high-five the guy for writing something that got on the front page of Hacker News.
- steilpass 15y ago"Before writing any production code, we'd write our unit tests." With XCode? Somehow I have my doubts.
- warwick 15y agoHe mentions they're using Eclipse. The store is written with Java/WebObjects.
- rimantas 15y agoXcode 4 offers to create unit test files when you create new project and it can run them. But there are other approaches: http://www.raywenderlich.com/3716/unit-testing-in-xcode-4-quick-start-guide http://www.raywenderlich.com/3716/unit-testing-in-xcode-4-qu...
- svdad 15y agoSo this is all well and good if you work with a team like this. But I have two questions: (a) How do you find out, before going to work somewhere, whether they actually work like this? Are there questions you can ask? Word of mouth? ... ? (b) If you don't work somewhere like this, how do you start putting professional processes in place? Assuming in particular that you have never actually worked somewhere like this, so you can't speak from experience, only from instinct about what seems to be a good way of working.
- deleted 15y ago[deleted]
- groby_b 15y agoa) You ask. "What is your development process". Places that have a decent process are more than happy to share that with you, usually b) Read. Talk to colleagues at other companies. Find things that improve your process and introduce them locally for yourself. If it seems to work out, share. Careful of politics there, though. Find out if there's anybody who "created" the process, make sure you get them on your side. It's always easiest to introduce change if you have proof ;) If it would be a larger change you can't do by yourself, try to make a compelling case with attached metrics. "If we do FOO, it'll reduce our broken build time by x%". If you can't measure those metrics, start measuring. And if you're making up how much you'll save, be as conservative as possible ;)
- BrandonM 15y ago> These tests were run against a copy of the live database in a production environment. This is pretty terrible from a security standpoint. A development environment is typically much less secure than the live environment, and for good reason. The development environment must be accessible to developers, typically both on-site and remote. All developers have access to test databases for the purpose of testing their changes. There are often many more software packages in a development environment, and development servers have a higher probability of running vulnerable services. Live environments typically have much better logging and auditing. Every company should have a program that can be run to sanitize the live database for use in testing. I've seen too many situations where the production environment was appropriately locked down and audited, but the development environment was compromised. It's not unheard-of for a developer to lose possession of his laptop, and if it contains a copy of the live database it's no better than the site, itself, being compromised.
- schrototo 15y agoYou make some very good and interesting points, though I think it's wrong to just presume Apple is lax on security based from that one sentence.
- BrandonM 15y agoI agree. My main intention was to inform would-be copy-cats that they shouldn't play fast and loose with copies of their live database. I'm sure (or at least, I hope) that Apple is smarter about sensitive data than that.
- JoeMoreno 15y agoI have to second BrandomM's comments. Don't make a complete copy of your live database to use in dev. Sensitive data needs to be scrubbed, ideally by a bona fide DBA, before bringing it over. Best to avoid this if at all possible so you don't have to worry about overlooking something that was sensitive. Also, I don't recall ever seeing any security issues with our environment or how we handled the code and data. There were some very smart engineers "minding the store."
- 15y ago
- synnik 15y agoWait a sec - "it was always an interesting experience to turn the store back on after Steve Jobs walked off stage following one of his keynote presentations" ?? Does Apple seriously turn off their store while Jobs talks? Or is he talking about pushing new content out based on announcements? The former just sounds... Odd.
- matthew-wegner 15y agoApple generally turns off the store for keynotes related to new product launches (new iPhone, sometimes MacBook/etc refreshes).
- groby_b 15y agoYep. During keynotes, the web store is usually "down for maintenance". For simple reasons - they don't want to pre-announce before "The Steve(tm)", but they want to have all the new products immediately available after the keynote.
- synnik 15y agoOk, but that sure sounds like a design flaw. I would have expected that they would still have an option to push the new products live at the time of their choosing vs. disabling online purchases of their existing products. I would think an appropriate separation of content from the site itself would allow them to reach their same business goals without deliberately giving themselves an outage.
- schrototo 15y agoIt's not so much a technical issue as it is a marketing decision. The store being down creates a sizable amount of suspense. Of course they could leave it up if they wanted to, but it's as much part of Apple folklore now as Steve's turtleneck.
- evan_ 15y agoThey turn the store off when they introduce new products, I suspect more as a tradition than anything. You wouldn't want an uninformed person buying an iPhone 3GS after Steve has already introduced the iPhone 4, but you don't want to put it up for sale yet because the media should be paying attention to Steve, not the store. If they just launched the item with all the specs on the store as soon as it was introduced in the keynote or media event or whatever, then it would ruin the suspense. Jobs is a salesman.
- vilda 15y agoI'm afraid the methodology described has little to do with Steve Jobs.
- stretchwithme 15y agoI was thinking the physical token would have had a USB connector that you actually had to plugin to use it.
- kevinburke 15y agoHow can I learn how to test like Apple does? I feel like I don't know where to look for good resources on thorough website testing.