-
Что такое
полиморфизм
? -
Что такое *инкапсуляция? Что такое *нарушение инкапсуляции?
-
Чем
абстрактный
класс отличается отинтерфейса
? -
Расскажите о
паттерне MVC
. Чем отличаетсяпассивная
модель отактивной
?
//SAMPLE CODE FROM APPLE | |
//https://developer.apple.com/library/content/samplecode/GenericKeychain/Listings/README_md.html | |
enum Key { | |
//... | |
//.... | |
enum Headers { | |
static let Authorization = "Authorization" | |
static let ContentType = "Content-Type" |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
import websocket | |
# Get auth token via POST to /api/v1/authTokens | |
# Use returned token to open a websocket connection to wss://host:port/events/v1 | |
# Token is passed as the URL parameter authToken | |
try: | |
self.logger.info("Getting auth token ...") | |
api_conn = api.ApiConnection(self.address, self.username, self.password, port=self.port) | |
response = api_conn.doPost("authTokens", {}) |
Foundation offers a Thread class, internally based on pthread
, that can be used to create new threads and execute closures.
// Detaches a new thread and uses the specified selector as the thread entry point.
Thread.detachNewThreadSelector(selector: Selector>, toTarget: Any, with: Any)
// Subclass
class MyThread: Thread {
The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).
My take-aways are:
-
You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.
-
Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse