AnyObject – a keyword used in Swift protocol definitions that limits protocol adoption to class types (and not structures or enums) which can be important when we want to be able to use a weak reference to the delegate. For clarification: AnyObject
is only for reference types (classes), whereas the Any
keyword is for both value and reference types. We should use Any
and AnyObject
only when we explicitly need the behavior and capabilities they provide.
So AnyObject
refers to any instance of a class, and is equivalent to id
in Objective-C. It’s useful when you specifically want to work with a reference type because it won’t allow any of Swift’s structs or enums to be used. AnyObject
is also used when you want to restrict a protocol so that it can be used only with classes. As of Swift 4. protocol P : class {}
and protocol P : AnyObject {}
parse identically and there’s no semantic difference between them, whereas previously there had been some subtle differences, this means that the AnyObject syntax is now preferred. We almost always want to use AnyObject with delegate methods (whilst also referencing them weakly inside our classes).
Since Swift 4 the preferred way to declare a class-only protocol is to use AnyObject
rather than class
. So instead of writing this:
1 2 3 |
protocol DetailViewControllerDelegate: class { func didFinishTask(sender: DetailViewController) } |
You write this (although one could make the argument that the former is more descriptive – and they parse the same):
1 2 3 |
protocol DetailViewControllerDelegate: AnyObject { func didFinishTask(sender: DetailViewController) } |
Associated Type – An associated type gives a placeholder name to a type – this can be used as a powerful method of making your protocols generic. Indeed when using associated types with a protocol, the actual type to use for that associated type isn’t specified until the protocol is adopted (making this an example of generics). In the words of Paul Hudson, “they mark holes in protocols that must be filled by whatever types conform to those protocols”. Associated types can be specified with the associatedtype
keyword.
A basic Swift example could look like this:
1 2 3 4 5 6 |
protocol ItemStoring associatedtype DataType var items: [DataType] { get set} mutating func add(item: DataType) } |
Atomic (non-Atomic) – (we can mark a property as atomic in Objective-C) Defining a property as atomic will guarantee that a valid value will be returned when we request it (this is the default), in the other case if nonatomic this could mean the property is in the process of being written when we try and get it back. Contrastingly, Swift properties are nonatomic by default, but we don’t use the “atomic” specifier inside Swift.
SOURCE: https://medium.com/@YogevSitton/atomic-vs-non-atomic-properties-crash-course-d11c23f4366c
App Thinning – Thinking in the context of Xcode, the app store and operating system optimize the installation of iOS, tvOS and watchOS apps by tailoring app delivery to the capabilities of the user’s particular device, with a minimal footprint. This optimization is called app thinning, and it lets you create apps that use the most device features, occupy minimum disk space, and can accommodate future updates that can be applied by Apple.
Azure Cosmos DB is “Microsoft’s proprietary globally-distributed, multi-model database service “for managing data at planet-scale” launched in May 2017. It is schema-agnostic, horizontally scalable and generally classified as a NoSQL database” (Wikipedia).
Blocks – These are a C-based language-level feature found in C, Objective-C, and C++ and define a self-contained unit of work. Blocks are like anonymous functions (or lambda abstractions) in that they combine data with related behavior, but they can also have optional binding to stack/heap variables. Therefore a block is a chunk of code that can be passed to a method, and the code can then be executed based on what happens in the method. We have seen Apple is moving many iOS APIs in the direction of utilizing blocks. See Lambda Calculus.
Category – In Objective-C “A category allows you to add methods to an existing class—even to one for which you do not have the source. Categories are a powerful feature that allows you to extend the functionality of existing classes without subclassing.” (StackOverflow), ” The category name indicates that the methods are additions to a class declared elsewhere, not a new class. You cannot, however, use a category to add additional instance variables to a class”(apple docs). This is similar to an extension in Swift. Categories are often used to add methods to existing classes, often from the main apple libraries, such as NSString
or they are less frequently used to extend the functionality of your own custom objects. See reference B for implementation details.
Sources
A: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocCategories.html
B: https://code.tutsplus.com/tutorials/objective-c-categories–mobile-10648
Core Data – in iOS Development CoreData is an SQLite database API (like a wrapper for SQLite). By setting up CoreData properly, an application can store and retrieve the internal state of a class rapidly. (CoreData stack implementation has changed several times over the course of time and can now incorporate cloud storage). We might actually choose to use something simpler like a simple SQLite implementation using something like FMDB if we wanna have something cleaner and without cloud storage etc.
Encapsulation – an object-oriented design principle that advocates hiding the internal states and functionality of objects meaning that the objects keep their state information private.
Extreme Programming – “a software development methodology which is intended to improve software quality and responsiveness to changing customer requirements. As a type of agile software development, it advocates frequent “releases” in short development cycles, which is intended to improve productivity and introduce checkpoints at which new customer requirements can be adopted” (Wikipedia)
Clang – a compiler front end that supports C, Objective-C and C++ developed by Chris Lattner at Apple. https://www.youtube.com/watch?v=IR_L1xf4PrU SEE: LLVM
class func – Class functions are also static functions but they are dynamically dispatched and can be overridden by subclasses, unlike static functions. Giving use cases like:
1 2 3 4 5 6 7 8 9 10 11 |
class AppUtils { class func appUtility(){ print("In AppUtils") } } class AppOtherUtils: AppUtils { override class func appUtility(){ print("In AppOtherUtils") } } |
We can access them similar to static functions as in AppUtils.appUtility()
or AppOtherUtils.appUtility()
.
static
is same as class final
.
Source: https://borgs.cybrilla.com/tils/global-vs-static-function-swift/
class var (Swift) – A class var
is like a static var
to the extent that you will access it by calling MyClass.myVar
however static variables can’t be overwritten in subclasses, whilst on the other hand, class variables can be. “When you make a static property it becomes owned by the class and cannot be changed by subclasses, whereas when you use class it may be overridden if needed” ().
Closures – these are “are self-contained blocks of functionality [or chunks of code] that can be passed around and used in your code. Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages.”
Collection Types – Basically types which are collections, for example, types like Array, Dictionary, or Set in the Swift programming language.
Concurrency – this basically means multiple computations happening at the same time. In the context of iOS development, GCD (grand central dispatch) is built on top of threads. Under the hood, it manages a shared thread pool. With GCD you add blocks of code or work items to dispatch queues and GCD decides which thread to execute them on. As you structure your code, you’ll find code blocks that can run simultaneously and some that should not. This then allows you to use GCD to take advantage of concurrent execution. For more general details look here.
Continuous Integration – Continuous integration is a process designed to allow us to get early feedback when something is going wrong during app development. In many cases, we might use tools like Jenkins combined with some type of centralized git repository like gitlab to ensure that each commit for a merge request is verified as at least working by some automated build process, which can have the benefit of allowing teams to detect problems early. “In XP [Extreme programming], CI was intended to be used in combination with automated unit tests written through the practices of test-driven development. Initially, this was conceived of as running and passing all unit tests in the developer’s local environment before committing to the mainline.” However, now we may or may not have a lot of unit test running and we also will use a build server instead of trying of having to rely on the user to run tests and build locally.
DAX Language – The DAX language was created specifically for the handling of data models, through the use of formulas and expressions. DAX is used in several Microsoft Products such as Microsoft Power BI, Microsoft Analysis Services and Microsoft Power Pivot for Excel. These products all share the same internal engine, called Tabular.
Declarative Programming – A programming approach that looks to define the structure of a given problem as opposed to specifically how to solve it, running such a program then is like proving an assertion, it is used in languages like PROLOG. In other words, it’s “expressed in terms of relations, represented as facts and rules. A computation is initiated by running a query over these relations” (Wikipedia).
Delegate – in the context of iOS development Delegates are Apple’s way of implementing call back methods. They are one way of allowing a class to send information to a different class. Whilst its true Delegates and NSNotifications can be used to accomplish nearly the same thing, delegates work in a one-to-one relationship whilst Notifications can be used in one-to-many relationships.
Dependency Injection – is a technique whereby one object (or static method) supplies the dependencies of another object. A dependency is an object that can be used (a service). An injection is the passing of a dependency to a dependent object (a client) that would use it (source: Wikipedia).
“DI enables loose coupling, and loose coupling makes code more maintainable” (https://www.manning.com/books/dependency-injection-principles-practices-patterns).
Extensions – an extension adds new functionality to an existing class, structure, enumeration, or protocol type. This includes the ability to extend types for which you don’t have access to the original source code (known as retroactive modelling). Extensions are similar to categories in Objective-C. See: Extensions Vs Subclassing
iOS ViewController Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// Your View Controller can have a custom init into which we can pass dependencies init(destination: HolidayDestination, traveler: Traveler) { self.destination = destination self.traveler = traveler super.init(nibName: nil, bundle: nil) } // And from the place that your going to present the VC we create an instance of // the VC passing in the dependencies like this let holidatyDestinationViewController = DestinationViewController(destination: dest, traveler: traveler) // Then we present with our custom presentation logic |
Dependency Management – If we want to integrate an open-source project, add a framework from a third party, or want to reuse code across our own products, dependency management can help us manage these all of these relationships. Widely used tools for dependency management include Cocoa Pods and Carthage.
DevOps – combines software development (Dev) team and information technology operations (Ops) team to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives. These teams participate together in the entire service lifecycle, from design through the development process all the way to and including production support. DevOps is also characterized by operations staff making use many of the same techniques, and systems as developers for their systems work. It *automates the processes* between software development and IT teams, in order that they can *build, test, and release software faster and more reliably*. DevOps is often linked to Continuous Integration, Continuous Deployment and TDD (Test-Driven Development) and the tools used for this like Jenkins, and also things like containerization.
@discardableResult
— this is a modifier used in Swift: sometimes we don’t care what the return value of a function is and therefore might want the option to ignore it, or use sometimes use it. To do this we can use the @discardableResult
modifier in front of our function definition.
1 2 3 4 5 |
@discardableResult func log(_ message: String) -> String { let logLine = "\(Date()): \(message)" print(logLine) return logLine } |
So with the above, we can just write log("Something)
without getting a warning, but we could equally use the result like let logMessage = log("Something")
so in Swift 3 and later, we use this prefix where we want this behavior.
DispatchGroup – A DispatchGroup is something that allows for aggregate synchronization of work. We can use them to submit multiple different work items and track when they all complete, even though they might run on different queues. This behavior can be helpful when progress can’t be made until all of the specified tasks are complete.
Dispatch Queue – a Dispatch Queue in iOS development is a feature of GCD (Grand Central Dispatch) – where GCD is an Apple framework built on top of threads and can remove the need for us to direct our task to different threads, as we had to prior to release GCD – this is because under the hood it manages a shared thread pool. With GCD you add blocks of code or work items to dispatch queues and GCD decides which thread to execute them on. This relates to the topic of Concurrency.
Dynamic Frameworks / Dynamic Libraries
The Difference between a Framework and a Library is primarily defined by the caller/callee relationship. Framework code makes calls to your code, but the Library code is called by your code. Frameworks control the flow of your application, but libraries do not.
The words static and dynamic are used to refer to the way the compiled code is referenced by the target application. With static libraries (*.a), the code that the app uses is copied to the generated executable file by a static linker at compilation time. All non-Apple frameworks before iOS 8 were static frameworks compiled with the source code of the app.
Conversely, with Dynamic libraries (*.dylib), these are linked with the app’s executable at runtime, and they can also be modified without relinking.
A Static Framework contains a static library packaged within its resources. Dynamic Frameworks contain the dynamic library with its resources. In addition to that, dynamic frameworks may conveniently include different versions of the same dynamic library in the same framework!
Dynamic Binding (run-time method binding) – Dynamic binding means determining the method to invoke at runtime instead of at compile time this is something that is also referred to as Late Binding.
Dynamic Dispatch – this is the process of selecting which implementation of a polymorphic operation (method or function) to call at run time. This is typically done using a vtable – also known as a Virtual Method Table (VMT), virtual function table, virtual call table, dispatch table, or vftable which is a mechanism used in a programming language to support dynamic dispatch (or run-time method binding).
Dynamic Programming is a method for solving complex problems by breaking them down into a collection of simpler subproblems, solving each of those subproblems just once, and storing their solutions. Dynamic Programming is basically a combination of recursion and memoization.
Factory Pattern is a way of encapsulating object creation typically for a set of similar objects which all conform to a certain protocol. It’s a way of separating off the responsibility for creating objects from the classes which then use those objects. There are different versions of the Factory pattern, but in each case, the idea is to use a “smart constructor” when generating objects.
See my article on design patterns for more info: [inset link].
Foreign Key (Category: Databases) – In broad terms, “a foreign key is a column or group of columns in a relational database table that provides a link between data in two tables. It acts as a cross-reference between tables because it references the primary key of another table, thereby establishing a link between them.”
Frame ( in Swift) – This rectangle defines the size and position of the view in its superview’s coordinate system. In contrast, the bounds of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0). So, the frame of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within. In other words, the frame is a view’s location and size using the parent view’s coordinate system whereas the bounds means a view’s location and size using its own coordinate system (important for placing the view’s content or subviews within itself).
Framework – A framework (in the context of iOS) is a hierarchical directory that encapsulates shared resources, such as a dynamic shared library, nib files, image files, localized strings, header files, and reference documentation in a single package. Multiple applications can use all of these resources simultaneously. The system loads them into memory as needed and shares the one copy of the resource among all applications whenever possible. Frameworks can control the flow of your application Frameworks group related, but separate, resources together. This grouping makes it easier to install, uninstall, and locate those resources. Frameworks can include a wider variety of resource types than libraries. For example, a framework can include any relevant header files and documentation. Multiple versions of a framework can be included in the same bundle. This makes it possible to be backward compatible with older programs. Only one copy of a framework’s read-only resources reside physically in-memory at any given time, regardless of how many processes are using those resources. This sharing of resources reduces the memory footprint of the system and helps improve performance (REF: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WhatAreFrameworks.html) (SEE ALSO: “Library“).
Functional Programming is a Programming Paradigm – a style of building computer programs that treats computation as the evaluation of mathematical-style functions avoiding changing-state and mutable data (or we can think of it as based primarily around the use of functions). Functional Programming is declarative because we achieve it by using declarations (not statements). Functional code aims to be idempotent such that a function’s return value depends only on its arguments, such that the same input to a function will always produce the same output. The theoretical derivation of functional programming can be thought of as The Lambda Calculus and indeed, many functional programming languages (like Haskell) could perhaps be though fo as really just another way to write lambda calculus that computers can be made to understand. The key advantages of this programming paradigm are considered to be immutable state and lack of side effects.
Functional Programming Languages include ML and HOPE. Furthermore, increasingly many modern programming languages look to combine Object-Oriented Programming with Functional Programming by incorporating elements from Functional Programming. In Swift, like in many FP languages, functions are first-class citizens which means you can treat functions like other objects that you can assign to variables. Due to this support, in Swift, functions can accept other functions as parameters or return other functions – functions that do this are called Higher-Order Functions. Whilst we haven’t traditionally used a FP approach for UI stuff, Reactive Programming is one example of an FP-like approach to UI development. This might include, Functional Reactive Programming (FRP) candidates, such as the likes of RxSwift (a reactive iOS & macOS library), and now perhaps SwiftUI which gives us a declarative syntax for creating native UIs .
For General reference see: https://www.geeksforgeeks.org/functional-programming-paradigm/
Functional Reactive Programming (FRP) is a Programming Paradigm for reactive programming(or asynchronous dataflow programming) through making use of the tools of functional programming (e.g. map, reduce, filter). With FRP in Swift, we have the option to use tools like RxSwift and RxCocoa to build asynchronous reactive applications which can make for easier to maintain coder and cleaner code. FRP per-se was developed by Conal Elliott from Microsoft Research, although his definition is quite strict with most modern so-called FRP not meeting his criteria in terms of requirements for use of denotations and continuous-time.
More loosely defined however Functional Reactive Programming is a programming paradigm which can be defined by the combination of the two concepts of Reactive Programming which focuses on asynchronous data streams which you can listen to and react to accordingly, and secondly Functional Programming, which emphasizes calculations via mathematical-style functions, immutability and expressiveness, and minimizes the use of variables and state.
Generics – Generic code enables you to write flexible, reusable functions and types that can work with any type, subject to requirements that you define. You can write code that avoids duplication and expresses its intent in a clear, abstracted manner. In Swift, we are able to use generics with Classes, Enums, Structs, Initializers, and Functions (see also: “Parametric Polymorphism“).
Generic Programming- a style of computer programming in which algorithms are written in terms of types to-be-specified-later that are then instantiated when needed for specific types provided as parameters.
This approach, pioneered by the ML programming language in 1973, permits writing common functions or types that differ only in the set of types on which they operate when used, thus reducing duplication.
Such software entities are known as generics in Python, Ada, C#, Delphi, Eiffel, F#, Java, Nim, Rust, Swift, TypeScript and Visual Basic .NET. They are known as parametric polymorphism in ML, Scala, Julia, and Haskell (the Haskell community also uses the term “generic” for a related but somewhat different concept); templates in C++ and D; and parameterized types in the influential 1994 book Design Patterns.
The term “generic programming” was originally coined by David Musser and Alexander Stepanov in a more specific sense than the above, to describe a programming paradigm whereby fundamental requirements on types are abstracted from across concrete examples of algorithms and data structures and formalized as concepts, with generic functions implemented in terms of these concepts, typically using language genericity mechanisms as described above.
Graph – A Graph is an important data structure in computer science; it is defined as a collection of nodes with “edges” between some of the nodes. When we talk about Graphs that category includes Trees, however not all Graphs are Trees.
Hypergraph – “A hypergraph is a graph in which generalized edges (called hyperedges) may connect more than two nodes”. Where a “graph” is a data structure as above.
inout
in Swift – You can pass in parameters to Swift functions as inout
, which means they can be changed inside a function, and those changes will reflect in the original value in a context outside the function. For example:
Instance Methods – these are functions that can be called on an instance of a class, struct, or enum, rather than on the type itself.
IntrinsicContentSize – (Source: https://developer.apple.com/documentation/uikit/uiview/1622600-intrinsiccontentsize).
Inversion of control (IoC) – IoC “is a programming principle. IoC inverts the flow of control as compared to traditional control flow. In IoC, custom-written portions of a computer program receive the flow of control from a generic framework. A software architecture with this design inverts control as compared to traditional procedural programming: in traditional programming, the custom code that expresses the purpose of the program calls into reusable libraries to take care of generic tasks, but with inversion of control, it is the framework that calls into the custom, or task-specific, code”(Wikipedia). It means that objects do not create other objects on which they rely to do their work. Instead, they get the objects that they need from an outside service. Implementations of IoC can include patterns like Dependency Injection and the ServiceLocator pattern.
JWT – a JSON Web Token (JWT, sometimes pronounced /dʒɒt/, the same as the English word “jot”) is an Internet standard for creating data with optional signature and/or optional encryption whose payload holds JSON that asserts some number of claims. The tokens are signed either using a private secret or a public/private key. For example, a server could generate a token that has the claim “logged in as admin” and provide that to a client. The client could then use that token to prove that it is logged in as admin. The tokens can be signed by one party’s private key (usually the server’s) so that party can subsequently verify the token is legitimate. If the other party, by some suitable and trustworthy means, is in possession of the corresponding public key, they too are able to verify the token’s legitimacy. The tokens are designed to be compact, URL-safe, and usable especially in a web-browser single-sign-on (SSO) context. JWT claims can typically be used to pass identity of authenticated users between an identity provider and a service provider, or any other type of claims as required by business processes. JWT relies on other JSON-based standards: JSON Web Signature and JSON Web Encryption.
Kubernetes – Kubernetes is an open-source container-orchestration system for automating computer application deployment, scaling, and management. It was originally designed by Google and is now maintained by the Cloud Native Computing Foundation. https://kubernetes.io/docs/tutorials/kubernetes-basics/
Lambda Calculus – The Lambda Calculus is “a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution”. It was the American born mathematician and logician Alonzo Church who came up with Lambda Calculus (λ-calculus) back in the 1930s. The Lambda Calculus is Turing Complete, and Alonzo Church was a supervisor of Alan Turing during the later’s PhD. To see what we really mean by this is best to look at and try some examples yourself.
Lazy Loading – Lazy loading means initializing your properties only if / when they are called. That way, memory is not allocated for a property until it’s needed, and if the property is never used then the memory doesn’t get allocated at all. Lazy properties in swift will be vars( Ref: https://www.natashatherobot.com/swift-lazy/)
Lazy Stored Properties – Lazy stored properties are used for properties whose initial values are not set until the first time they are used. In the Swift programming language, you can declare a lazy stored property by writing the lazy modifier before its declaration. Lazy properties are useful when the initial value of a property is reliant on outside factors whose values are unknown.
Library – a library is a collection of resources and code, compiled into one or more architecture. In the context of iOS applications, we see both static (.a) and dynamic libraries (.dylib) – the difference with dynamic ones are that they are not copied into an executable file like static libraries are, but instead they are dynamically linked at load or runtime (when both binary files and the library are in memory). (Ref: https://medium.com/@zippicoder/libraries-frameworks-swift-packages-whats-the-difference-764f371444cd). Libraries are somewhat different to frameworks, where these days, when using cocoapods for example, one will typically make use of frameworks (we declare this at the top of our pod file thus: </span>use_frameworks!<span style="color: #000000;">
). To elaborate on this: A framework ( .framework): is a hierarchical directory that encapsulates a dynamic library, header files, and resources, such as storyboards, image files, and localized strings, into a single package. Apps using frameworks need to embed the framework in the app’s bundle.
Liskov Substitution Principle – One of the SOLID principles, this principle refers to the ability to be able to replace one implementation of an interface with another without breaking either the client or the implementation. In particular, one should ensure that “objects of a superclass shall be replaceable with objects of its subclasses without breaking the application. ”
LLDB – The LLDB Debugger (LLDB) is the debugger component of the LLVM project. It is built as a set of reusable components which extensively use existing libraries from LLVM, such as the Clang expression parser and LLVM disassembler. LLDB is free and open-source software under the University of Illinois/NCSA Open Source License, a BSD-style permissive software license. Since v9.0.0, it was relicensed to the Apache License 2.0 with LLVM Exceptions.
LLVM – an open-source project originally developed by Swift language creator Chris Lattner as a research project at the University of Illinois.
“””
[LLVM is] a library for programmatically creating machine-native code. A developer uses the API to generate instructions in a format called an intermediate representation, or IR. LLVM can then compile the IR into a standalone binary or perform a JIT (just-in-time) compilation on the code to run in the context of another program, such as an interpreter or runtime for the language.
LLVM’s APIs provide primitives for developing many common structures and patterns found in programming languages. For example, almost every language has the concept of a function and of a global variable, and many have coroutines and C foreign-function interfaces. LLVM has functions and global variables as standard elements in its IR, and has metaphors for creating coroutines and interfacing with C libraries.””” (https://www.infoworld.com/article/3247799/what-is-llvm-the-power-behind-swift-rust-clang-and-more.html).
Marble Diagram – “A Marble Diagram visualizes the transformation of an observable sequence. It consists of the input stream on top, the output stream at the bottom and the actual transformation function in the middle”. Typically in a marble diagram, time flows to the right, and the diagram describes how values (“marbles”) are emitted on the Observable execution.
This key shows the symbols used in these diagrams:
Looking something like this:
Memoization – this just means memorizing or caching the solutions to subproblems in order to avoid duplication of work. This involves “storing the results of expensive function calls and returning the cached result when the same inputs occur again”. The term was coined by Donald Michie in 1968.
Message Dispatch – this is the type of dispatch which Objective-C uses. In deciding which code to execute the Objective-C runtime requires both a selector (which we can usually assume to be the method name) and the object that the message should be passed to. “Objective-C is, ultimately, a simple set of extensions to C that provide an object-oriented coding and runtime model. Objective-C fully embraces C and leverages the C calling ABI throughout. Every method call is really just a C function call with objc_msgSend()
acting as the preamble that figures out exactly which C function — which method — to call!”(source).
“Objective-C messages are dispatched using the runtime’s objc_msgSend()
function. Shown in the Apple docs, the function takes at least 2 arguments:
- The receiving object
- The selector of the message
- [A variable list of arguments to the message being sent.]
Instances of a class have an isa
pointer, which is a pointer to their class object. The selectors of methods in each object are stored in a “table” in the class object, and the objc_msgSend()
function follows the isa
pointer to the class object, to find this table and checks whether the method is in the table for the class. If it cannot find it, it looks for the method in the table of the class’s superclass. If not found, it continues up the object tree, until it either finds the method or gets to the root object (NSObject
). At this point, an exception is thrown” (source).
Method Swizzling – the process of changing the implementation of an existing selector. It’s a technique made possible by the fact that method invocations in Objective-C can be changed at runtime, by changing how selectors are mapped to underlying functions in a class’s dispatch table. It usually considered very hacky and best avoided if possible.
MQTT – MQTT is a machine to machine / IoT connectivity protocol transmitted over a TCP/IP connection. It was invented in 1999 by Dr Andy Stanford-Clark of IBM and Arlen Nipper of Arcom to be an extremely lightweight publish/subscribe messaging transport. As of November 2014, MQTT became an OASIS open standard.
Mutating (Swift keyword) – The properties of value types cannot be modified within its instance methods by default. In order to modify the properties of a value type, you have to use the mutating
keyword in the instance method (*where Instance methods are functions that belong to instances of a particular class, structure, or enumeration)
For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
struct Stack { public private(set) var items = [Int]() // Empty items array mutating func push(_ item: Int) { items.append(item) } mutating func pop() -> Int? { if !items.isEmpty { return items.removeLast() } return nil } } var stack = Stack() stack.push(4) stack.push(78) stack.items // [4, 78] stack.pop() stack.items // [4] |
Source: https://medium.com/the-andela-way/swift-understanding-mutating-functions-in-two-minutes-d9e363904e3a
MUTEX – A mutual exclusion (mutex) is a program object that prevents simultaneous access to a shared resource. This concept is used in concurrent programming with a critical section, a piece of code in which processes or threads access a shared resource. Only one thread owns the mutex at a time, thus a mutex with a unique name is created when a program starts. When a thread holds a resource, it has to lock the mutex from other threads to prevent concurrent access of the resource. Upon releasing the resource, the thread unlocks the mutex.
Nested Functions (Swift) – A nested function provides the facility to call the outer function by invoking the inside function.
For example:
1 2 3 |
<span style="color: #000000;"><span class="pun"><img class="alignnone wp-image-1843 size-large" src="https://www.steveclarkapps.com/wp-content/uploads/2019/07/Screenshot-2019-07-09-at-23.55.30-1024x579.png" alt="nested functions example" width="900" height="509" /> </span></span> |
NP-hardness “(non-deterministic polynomial-time hardness), in computational complexity theory, is the defining property of a class of problems that are, informally, “at least as hard as the hardest problems in NP”. A simple example of an NP-hard problem is the subset sum problem” (Wikipedia).
Object-Oriented programming – Is a Programming Paradigm, based on the notion of objects. Typically this means programming using class hierarchies to allow manipulation of objects of a variety of types through well-defined interfaces and to allow a program to be extended incrementally through derivation. These “objects” which are more often than not just classes can contain data, in the form of fields / attributes / properties / variables and constants, and a set of procedures (functions or methods) with executable code in them.
OperationQueue – an OperationQueue
in iOS is a task management feature from the Foundation framework. It a class that regulates the execution of Operations (where an Operation
is an abstract class that represents the code and data associated with a single task). An operation queue executes its queued Operation objects based on their priority and readiness. After being added to an operation queue, an operation remains in its queue until it reports that it is finished with its task.
Optional Chaining – In Swift, Optional Chaining means a process of querying and calling properties where more than one query can be chained together, and if any link in the chain is nil, then the entire chain fails.
i.e. analytics?.logSomething("Loaded View")
Observables – These are an Rx concept used in the likes of RxSwift. They allow us to emit events, have Lots of static convenience methods, allow for Subscriptions. There are two types: of Observable: An observable is “cold” if its underlying producer is created and activated during subscription. An observable is “hot” if its underlying producer is either created or activated outside of subscription.
Parametric Polymorphism is when your code is written without reference to any specific type, and for that reason, it can be used transparently with a range of different types. Parametric Polymorphism enables you to reuse designs for subprograms (such as standard algorithms for sorting) and also for Abstract Data Types (ADTs), and this is because a generic software component is one that is parameterised with respect to a type T on which it depends, it can be instantiated whenever we want to make an ordinary (non-generic) software component. Therefore, this approach is most often called generics, but in the world of functional programming, it can be referred to just using the term polymorphism. Thus, we can see that with Generics, a function or an ADT can be written generically which means it can handle a range of values irrespective of their type.
Pivot Table – A pivot table “is a table of statistics that summarizes the data of a more extensive table (such as from a database, spreadsheet, or business intelligence program). This summary might include sums, averages, or other statistics, which the pivot table groups together in a meaningful way.
Polymorphism – This means the provision of a single interface to entities of different types. Types of polymorphism include subtype polymorphism, parametric polymorphism (generics) etc. See my article here for more information.
Probabilistic Inference – meaning computing properties of interest, based on probability-distributions, for example, “marginalization” and “maximization“. P.I. is often at least an NP-hard (or even inapproximable) problem, but working out exact inference can be doable in some low order of polynomial time using trees, although based on the difficulty, these problems can be infeasible to solve exact inference which is where approximation comes in, and where approximation methods become super useful for these types of problems. Graphical Models give us a strategy for doing Probabilistic Inference, either with exact inference methods or broad-approximation inference methods. (Ref)
Procedural Programming is a “Programming Paradigm” and a subtype of Imperative Programming as well as a type of Structured Programming based on procedure calls, in which statements are structured into procedures (also called subroutines or functions). To that extent, it’s really all about modularity and also scoping (meaning we use variables in a particular defined scope, and can thus restrict access to properties based on scope to avoid any confusion and keep things nice and clean).
Protocol Oriented Programming (POP)– This is essentially a version of OOP which emphasizes composition over inheritance as a method of functionality-sharing by using (Swift’s version of) Protocols. This means we can still get code reuse, but avoid some of the issues of inheriting a bunch of stuff from some superclass. More information here.
Power BI – Power BI is a business analytics solution that lets you visualize your data and share insights across your organization, or embed them in your app or website. Connect to hundreds of data sources and bring your data to life with live dashboards and reports
Recursion – this means the repeated application of a recursive procedure, typically where a function calls itself directly or indirectly, and it’s used to solve problems like the Towers of Hanoi where a recursive solution makes sense.
RxSwift – is a Swift framework and is also an example of an implementation of Reactive Programming based on the ReactiveX Standard first developed in Microsoft in implementation like rx.NET – this standard is essentially a standard for libraries which can be used across a range of different programming languages which are all used for composing asynchronous and event-based programs by making use of Observable Sequences. The ReactiveX Standard “extends the observer pattern to support sequences of data and/or events and adds operators that allow you to compose sequences together declaratively while abstracting away concerns about things like low-level threading, synchronization, thread-safety, concurrent data structures, and non-blocking I/O.”
Selector – Selectors are the Objective-C way of representing methods. They let you dynamically “select” one of an object’s methods, which can be used to refer to a method at run time, pass a method to another function, and figure out whether an object has a particular method.
Static Binding – The binding which can be resolved at compile time by the compiler is known as static or early binding.
Static Dispatch is a form of polymorphism fully resolved at compile time. It is a form of method dispatch where language or environment selects which implementation of a method or function that it would want to use.
Structured Programming – “is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of the structured control flow constructs of selection (if/then/else) and repetition (while and for), block structures, and subroutines” (Wikipedia).
TPU – “A tensor processing unit (TPU) is an AI accelerator application-specific integrated circuit (ASIC) developed by Google specifically for neural network machine learning”(Wikipedia).
Typecasting / Type Casting – Meaning different things to different people but broadly … “changing an entity of one data type, expression, function argument, or return value into another” (wikibooks.org). “In most ALGOL-like languages, such as Pascal, Modula-2, Ada and Delphi, conversion and casting are distinctly different concepts. In these languages, conversion refers to either implicitly or explicitly changing a value from one data type storage format to another, e.g. a 16-bit integer to a 32-bit integer. The storage needs may change as a result of the conversion, including a possible loss of precision or truncation. The word cast, on the other hand, refers to explicitly changing the interpretation of the bit pattern representing a value from one type to another. For example, 32 contiguous bits may be treated as an array of 32 booleans, a 4-byte string, an unsigned 32-bit integer or an IEEE single precision floating point value. Because the stored bits are never changed, the programmer must know low level details such as representation format, byte order, and alignment needs, to meaningfully cast.”
-typecasting in Swift (https://docs.swift.org/swift-book/LanguageGuide/TypeCasting.html)
Apple states that in Swift, “Type casting is a way to check the type of an instance, or to treat that instance as a different superclass or subclass from somewhere else in its own class hierarchy … Type casting in Swift is implemented with the is
and as
operators. These two operators provide a simple and expressive way to check the type of a value or cast a value to a different type” (apple docs).
-Implicit Type Conversion vs Implicit Type Conversion
Typecasting usual mean explicit type conversion as in the below C code example:
1 2 3 4 5 6 7 8 9 10 11 |
// C program to demonstrate explicit type casting #include<stdio.h> int main() { double x = 1.2; // Explicit conversion from double to int int sum = (int)x + 1; printf("sum = %d", sum); return 0; } |
-Downcasting means …
Waterfall – the Waterfall Approach is the traditional approach to the software development lifecycle. In this approach, the requirements are defined without much or any interaction with the software development team. We can visually think about this looking like a waterfall with the output from one stage cascading down to the next. This is very much in contrast to an Agile development process where there is continuous refining of requirements as development proceeds due to constant interaction between those defining the requirements and the people doing the development.
Xib – in Xcode development, .xib files (or Nibs as they are also known) are files used to layout screens, and other UI elements meaning that a xib defines the layout of a single view controller screen, or could also be used for a tableview cell, or another type of view. Whilst a Storyboard can show many view controllers and also shows the relationships between them (like segues), a nib does not do this.
Zombie Objects – Zombie Objects are a debugging feature of Cocoa / CoreFoundation to help you catch memory errors – normally when an object’s reference count drops to zero it is immediately freed, but that can sometimes make debugging difficult. Instead, if zombie objects are enabled, the object’s memory isn’t instantly freed, it’s just marked as a zombie, and any further attempts to use it will be logged and you can track down where in the code the object was used past its lifetime. So anytime a deallocated object gets sent a message during testing, you’ll be able to see that. Zombie Object are a different thing from Zombie Processes.
Last Updated: 10th May 2019