-
Couldn't load subscription status.
- Fork 35.8k
[DEV] Programming advice and tips & tricks
This page is a collection of FYI- and TIL-items that spotlights particular useful utilities or programming patterns that aren't obvious or little known. Take them as an offering and not as some must-do.
- The
Disposablebase class makes it easy for subclasses to_registervalues that should be disposed of when the instance is disposed of. -
DisposableStoresafely manages a collection of disposable values. It is preferred overIDisposable[]. -
DisposableMapmanages a map where the values are disposables. It helps you avoid some tricky lifecycle bugs vs implementing aMap<K, IDisposable>yourself. -
MutableDisposablesafely manages a disposable value that can change over this. This prevents bugs where you forget to dispose of the old value when overwriting it with a new value.
- native
MapandSetare sorted by insertion order 💡 this is a little-know but can come handy -
ResourceMapandResourceSetwhich are normal maps/sets but keyed byURI -
LRUCacheis a map with recency and trimming abilities -
TernarySearchTreeis map-like with the ability to lookup sub and super-strings (useful for path containment) -
SkipListis a map which is sorted based on a custom comparator function -
LinkedListlike arrays but with faster removal/insertion
The modules src/vs/base/common/arrays.ts and src/vs/base/common/strings.ts have many very useful utilities when dealing with arrays or strings.
The src/vs/base/common/iterator.ts modules contains utilities for working with iterables. Iterables can be a better alternative than arrays because they enforce readonly-ness by design and hence saving Array.slice-calls
We have utils to delay certain operations or values
-
Lazy<T>a lazy value is computed only when accessed for the first time -
IdleValue<T>is similar toLazybut uses browser idle times to eagerly compute its value. Implements the "idle until urgent" pattern, see: https://philipwalton.com/articles/idle-until-urgent/ -
runWhenIdleis our wrapper around browserswindow.requestIdleCallback-function -
scheduleAtNextAnimationFrameandrunAtThisOrScheduleAtNextAnimationFrameallows to join this or the next browser animation frame
Project Management
- Roadmap
- Iteration Plans
- Development Process
- Issue Tracking
- Build Champion
- Release Process
- Running the Endgame
- Related Projects
Contributing
- How to Contribute
- Submitting Bugs and Suggestions
- Feedback Channels
- Source Code Organization
- Coding Guidelines
- Testing
- Dealing with Test Flakiness
- Contributor License Agreement
- Extension API Guidelines
- Accessibility Guidelines
- Custom ESLint rules
Documentation