Skip to content

Instantly share code, notes, and snippets.

View kprofic's full-sized avatar

Krzysztof Profic kprofic

View GitHub Profile

1. Separation of immutable and mutable logic

Quite a lot of different people have been on the same trail of thought. Gary Bernhardt's formulation of a "functional core, imperative shell" seems to be the most voiced.

"Boundaries" - Gary Bernhardt

"Imperative shell" that wraps and uses your "functional core".. The result of this is that the shell has fewer paths, but more dependencies. The core contains no dependencies, but encapsulates the different logic paths. So we’re encapsulating dependencies on one side, and business logic on the other side. Or put another way, the way to figure out the separation is by doing as much as you can without mutation, and then encapsulating the mutation separately. Functional core — Many fast unit tests. Imperative shell — Few integration tests

https://www.youtube.com/watch?v=yTkzNHF6rMs

@kprofic
kprofic / NSOperation+Promise.swift
Last active August 29, 2017 11:11 — forked from ulrikdamm/gist:68c4f019abcc885247b5
Railway Oriented Programming in Swift
class Promise<T> {
var value : T? {
didSet {
if let value = value {
notifyListeners(value)
}
}
}
init(value : T? = nil) {
@kprofic
kprofic / best_breakfast_restaurants_in_krakow
Last active April 6, 2017 10:26
Breakfast places worth visiting in Krakow
> 7:00
Fitagain Café
Charlotte
SoHo Coffee
Wesoła Café
Zielonym Do Góry
> 7:30
Bonjour Cava Piłsudskiego
Gossip Café
@kprofic
kprofic / swift.tex
Last active August 29, 2015 14:07 — forked from chriseidhof/swift.tex
\lstdefinelanguage{swift}
{
morekeywords={
func,if,then,else,for,in,while,do,switch,case,default,where,break,continue,fallthrough,return,
typealias,struct,class,enum,protocol,var,func,let,get,set,willSet,didSet,inout,init,deinit,extension,
subscript,prefix,operator,infix,postfix,precedence,associativity,left,right,none,convenience,dynamic,
final,lazy,mutating,nonmutating,optional,override,required,static,unowned,safe,weak,internal,
private,public,is,as,self,unsafe,dynamicType,true,false,nil,Type,Protocol,
},
morecomment=[l]{//}, % l is for line comment
// http://matthewmorey.com/improved-xcode-build-phases/
echo "Total lines of code:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -and \( -path "${SRCROOT}/Pods/*" -prune -o -print0 \) | xargs -0 cat | wc -l
@kprofic
kprofic / CalculateCodeComplexity.sh
Last active August 29, 2015 14:07
Code Complexity Calculator
#!/bin/sh
# Based on http://matthewmorey.com/improved-xcode-build-phases/
if [ -n ${1} ]; then
LOC_LIMIT="$1";
elif [ -z ${LOC_LIMIT} ]; then
LOC_LIMIT=500; # default limit
fi
pushd ${PROJECT_DIR};
@kprofic
kprofic / Base.xcconfig
Last active August 29, 2015 14:04
Xcode project base configuration that brings the sanity to the higher level.
//
// Created by Krzysztof Profic on 07/02/14.
//
// ----- COMPILER WARNINGS -----
OTHER_CFLAGS = "-Wunreachable-code";
// Apple LLVM 5.0 - Warning Policies
GCC_TREAT_WARNINGS_AS_ERRORS = YES