Never confuse faith in God with religion.
|
BlogsPrettier InitsFebruary 19, 2010 - 4:11pm
All the time I’ve used Cocoa, I’ve had one design pattern for creating an autoreleased object:
Guess what? You can twiddle -init and -autorelease.
Why would you want to? Well, consider:
Now, make it prettier:
See? There’s no dangling -autorelease on the end. Happy days! If you create a model class in Django and then create a model subclass of that, then Django creates a 1:1 relationship to a table with the extra fields defined in the subclass. This results in there being an instance of the parent class as well as an “extended version” of that object in the subclass. That works out rather well for most cases, but there’s a few edge cases where it’s not sufficient. Say I have an object A and a subclass B:
I’ll wind up with some tables like this: A
B
What this means is that if I instantiate PK 1 via A’s manager, I’ll get an A and only ever an A because the information about what kind of object it is exists only in B’s table. So if I have, say, a blog engine like Tumblr where there are text, image, video, audio, and other kinds of posts and I’ve made them all model classes based off RootBlog, I can’t do a lookup by PK and expect the right object; I’ll always get a RootBlog object. Traditionally, if you had this problem, you’d use abstract classes and just have a different object series for each kind of post. That works, but it means you can’t do shortcuts that just pass around an ID and get the right object — you have to pass around the type as well. However, there is one trick that’s a result of the 1:1 relationship that could be of some assistance here. When you create an instance of our example object A, it will have a property called ‘b’ that is a link to its corresponding full instance of B. The problem is that we can’t easily follow this without giving the ancestor direct knowledge of all its descendants’ names. Read the rest »
10.6 falsely reports ‘service battery?’ ... I think not And if you follow those “tips” you’ll have a very healthy NiCad battery and a dead LiIon battery. What is this tool thinking? Has he never looked into this at all? CYCLES ARE BAD. Leave the unit plugged in, don’t discharge if possible, and charge as soon as you can when you get near power. Even Apple says this, so why is this ‘tard being an smug idiot? One more reason not to trust “community” tips. I watched the president’s speech on education just now. Fantastic speech, very uplifting, and totally devoid of political context. Can we now agree that Glen Beck is a frigtard that’s just striking up fear and loathing with a soothing tone? Anyway, I did watch it via the FB Live stream so I could see the stream of idiots’ comments flowing on the side as I watched. It was … enlightening. Here’re some golden ones:
I … yes. Exactly. Thank you.
I saw this one come up a lot. That was just sad to see.
This fellow was rather prolific and I do hope he sees some black SUVs soon. HatersRead the rest » And he sent them to preach the kingdom of God, and to heal the And he said unto them, “Take nothing for your journey, neither And they departed, and went through the towns, preaching the
Eh, that works. “It is the mark of our whole modern history that the masses are kept quiet with a fight. They are kept quiet by the fight because it is a sham-fight; thus most of us know by this time that the Party System has been popular only in the sense that a football match is popular.” — A Short History of England. 156 – G. K. Chesterton |
|