Skip to content

Instantly share code, notes, and snippets.

@epatey
epatey / brokenWindows.md
Created March 28, 2022 12:54
Broken windows in software engineering synopsis.

Tip 4 - Don’t Live with Broken Windows

A broken window.

One broken window, left unrepaired for any substantial length of time, instills in the inhabitants of the building a sense of abandonment—a sense that the powers that be don’t care about the building. So another window gets broken. People start littering. Graffiti appears. Serious structural damage begins. In a relatively short space of time, the building becomes damaged beyond the owner’s desire to fix it, and the sense of abandonment becomes reality.

Don’t leave “broken windows” (bad designs, wrong decisions, or poor code) unrepaired. Fix each one as soon as it is discovered. If there is insufficient time to fix it properly, then board it up. Perhaps you can comment out the offending code, or display a "Not Implemented" message, or substitute dummy data instead. Take some action to pr

@epatey
epatey / SwiftUICollectionChanges.md
Last active February 13, 2020 15:29
Refreshing SwiftUI on changes within objects in a collection.

Refreshing SwiftUI on changes within objects in a collection.

How to approach updating UI for changes within objects held within a collection? After experimenting a bit, I think there are basically two approaches.

  1. The conformance to BindableObject by the object that contains the collection needs to be deep - not shallow. It needs to fire didChange if the collection, or anything recursively within the collection, changes. or
  2. The parent/container can have shallow conformance to BindableObject if the row model themselves conform to BindableObject and the row view declares the dependency with @ObjectBinding.

You must do one or the other if you want a row to refresh when isTyping changes value. I suspect that in the general case, #2 will be simpler.

@epatey
epatey / keybase.md
Last active November 14, 2016 22:30

Keybase proof

I hereby claim:

  • I am epatey on github.
  • I am epatey (https://keybase.io/epatey) on keybase.
  • I have a public key ASD25tkvI5O9gEhCvQzXSWpmC6FLpMaiu_H1WyeiOp4A2Qo

To claim this, I am signing this object:

@epatey
epatey / gist:02d8ca2b1e8593a6ce7a
Last active August 29, 2015 14:09
NSObject category that explodes if an object doesn't get deallocated soon
// Use this gist when you need to assert that a particular object is deallocated
// "soon". I use this technique extensively to ensure that I don't introduce retain
// cycles into my code. It really beats not noticing that you regressed and started
// leaking a view controller months ago!
@interface NSObject (ExplodingDealloc)
// Explode if this object isn't deallocated within 3 seconds
- (void)explodeIfNoDealloc;