Skip to content

Instantly share code, notes, and snippets.

View adam-e-trepanier's full-sized avatar

Adam Trepanier adam-e-trepanier

View GitHub Profile
original post @ https://www.linkedin.com/feed/update/urn:li:activity:6881954451964461056?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A6881954451964461056%2C6882013851898933249%29&replyUrn=urn%3Ali%3Acomment%3A%28activity%3A6881954451964461056%2C6882320295986917376%29
I think there is a lot to unpack here, and it is probably a very long blog post with very descriptive meaning to terms
around system/software design. For more in-depth information, see CQRS Documents by Gregg Young. Also, look
at Event Modeling from Adam Dymitruk. Both are exceptional.
However, I will try to be concise. CQRS means separating your writes from your reads. In other words, when some
actor (user, external system, what have you) issues a command (write side) to the system, it is only changing its state.
The system's internal state is critical here, and the system shouldn't leak the internal structure out (encapsulation and
information hiding). The Command side does not mean the system doesn't return a typical representation of t
Public Sub DeleteRowTest()
Dim i As Long
Dim LastRow As Long
Dim Cols As Variant
Dim LookFor As String
Dim rng As Range
With Application
.ScreenUpdating = False
(ns clojure-programming.concurrency.futures
(:import (java.util Date)))
;; Futures
;; Simple concept. Take some code and evaluate it in another thread. Thats it.
;; Futures return immediately, which allows the current thread of execution
;; to continue on doing its own thing. The results of the future can be
;; obtained by dereferencing the future. Note that if you try and dereference
;; the future prior to it being complete, it will block
@adam-e-trepanier
adam-e-trepanier / apply.clj
Last active August 29, 2015 14:08
Working with apply
(ns functions.apply)
;; We can use apply with print because print takes the (& more)
;; parameter. So we can pass any number of args to messenger
;; and then apply will explode the sequence generated by (& who) in
;; the argument list into the print method
(defn messenger "Fooling with apply function" [greeting & who]
(println who)
(apply print greeting who))
@adam-e-trepanier
adam-e-trepanier / no_instance_var_test
Created October 22, 2014 02:47
Don't test instance variables
class Foo
def initialize
@logger ||= APP::LOGGER
@agent = Agent.new(name, action, args)
end
end
describe Foo do
it "should initialize an integration logger" do
foo = Foo.new
@adam-e-trepanier
adam-e-trepanier / gist:2383227e043d93c68923
Created October 20, 2014 21:55
Restructuring with auto resolve
;; In Clojure 1.6 we can now also auto resolve keyword forms in the :keys directive
;; I think you lose some context with auto-resolve, but its the shortest code
(let [{:keys [name date-of-birth orders
::street ::city ::state ::postal-code]
:as patient} data]
(println name \- date-of-birth)
(println street ", " city ", " state " " postal-code)
(println orders)
(println "------- Full Patient Deatils -----")
(println patient))
@adam-e-trepanier
adam-e-trepanier / gist:cac11fa98ac4d1422735
Last active August 29, 2015 14:07
Restructuring with prefix
;; In Clojure 1.6 we can now prefix the name of a key if its the same
;; A litte more context with the prefix, but still very clean
(let [{:keys [name date-of-birth orders
shipping-address/street shipping-address/city
shipping-address/state shipping-address/postal-code]
:as patient} data]
(println name \- date-of-birth)
(println street ", " city ", " state " " postal-code)
(println orders)
(println "------- Full Patient Deatils -----")
@adam-e-trepanier
adam-e-trepanier / gist:47866b5d0a8045d87561
Created October 20, 2014 21:48
Destructuring with :key directive
;; Destructor a map with another map -> patient has a shipping address
;; We use the :keys directive to to assign the shipping address info inside of data
;; Notice we also use the :keys directive to also get the name and date of birth
(let [{:keys [name date-of-birth orders]
{:keys [street city state postal-code]} :shipping-address
:as patient} data]
(println name \- date-of-birth)
(println street ", " city ", " state " " postal-code)
(println orders)
(println "------- Full Patient Deatils -----")
(def data
{:name "Adam Trepanier"
:date-of-birth "1981-04-30"
:gender "male"
:patient-key "test-adam"
:status "active"
:phone "555-555-5555"
:shipping-address {:street "123 Foo Bar Way"
:city "Somwhere"
:state "CA"
-module(math_functions).
-export([test/0, even/1, odd/1, filter/2, split/1, split2/1]).
test() ->
true = even(10),
false = even(11),
true = odd(11),
false = odd(10),
tests_passed.