Saturday 7 May 2016

New version of Principle

After a year long hiatus, I've touched Principle again. A new version is out, 0.34, that moves all configuration from the clunky pom.xml to a neat yaml file, like the one below



The next big thing will be to make it usable a SBT plugin, while also retaining the Maven plugin nature. By looking at the documentation of "Simple" Build Tool, this looks challenging.

Saturday 9 April 2016

The Reader Monad

Yet another exploration in Monadland. Like the State Monad, its sibling, Read Monad had managed to elude me until I came across an enlightening example in Debashish Gosh's excellent book, Functional and Reactive Domain Modelling. In the following example I'll describe a simple scenario where I'd usually use dependency injection and refactor it to a Reader monad using variant.

Version 1. Dependency Injection

When one tries to follow FP principles, she strives to build her application up like an onion. The core should contain pure functions, and all interaction with external services - DB, web service calls, user input, ... - , i.e. side-effects, should be confined to the outer layer. In the code above the domain logic and side-effects are undisentanglable. The next version shows an alternative.

Version 2. Higher order function

This is better. `notifyUser` is now a referentially transparent function. The actual execution of the effects is deferred to a later point, when the result function is called with the context. The Reader monad is nothing else just a convenient wrapper around such a function.

Version 3. Reader Monad

The benefit Reader monad offers over the simple HOF-solution is the monadic composability, like in the example below.


Note that inside the for comprehension the context doesn't even appear.

Saturday 12 March 2016

Struggling with the State Monad

After spending hours trying to find articles explaining the damn thing without resorting to "let's take this contrived example..." or "let's take a real life example, generating pseudo-random numbers" (seriously?!), I'm still left with frustration. Eventually I'd reached out to Kaloz, who pointed me to one of his earlier explorations of the topic. His example is here, but I'm still in the dark why is it any better than a simple foldLeft. In the code below I refactored slightly Kaloz's code to keep the generic part apart from the specific solutions. A second foldLeft-using function is provided to match the signature of the function using the State monad, although I don't see any additional value in that.

Kaloz? What am I missing?

Saturday 27 February 2016

What a senior back-end developer should know in 2016


I've been developing software for a decade now and quite often feel overwhelmed by the sheer amount of must-know-s someone needs to possess by common consent to earn the right to be called a professional. I think almost everyone can fail an interview if being asked the wrong questions, regardless of experience. 
I've spent half an hour assembling the following lists. I'm too lazy to elaborate the items here (mostly I just mention some related keywords) or structure them properly, but I think the gist comes through. The items also highly vary in importance and required level of depth. Of course it depends on your field, mine is the Enterprise Java (lately Scala) world. E.g. I've never needed to implement a binary tree in my career, but subjectively consider it somewhat "important". I also simply drop in DDD, but it takes years to master (as opposed to getting sufficiently familiar with HTTP). 

So, here we go
  • Knowing at least one language inside-out
  • Good software development principles:
    • separation of concerns, polymorphism, SOLID principles, encapsulation, loose coupling, high cohesion
    • understanding the concept of good quality code and the capacity to produce it - very vague definition, yet the most important. It has nothing to do with frameworks/technologies/most of the things listed below
  • OO fundamentals. Design patterns, SOLID principles
  • FP fundamentals - it's just getting into the mainstream, but hopefully sooner or later will be ubiquitous
  • Algorithms and data structures ( graph theory, O(n), binary trees, tail recursion, ...)
  • Concurrency, thread safety, parallel computation. Deadlock, livelock, threads, thread-pools, locks, synchronization primitives, CSP, Actor model, Dataflow (Functional Reactive Programming)
  • JVM memory model
  • Monitoring tools (JMX, JProfiler, ...)
  • Dynamic vs static typing, pros and cons
  • DI frameworks (the concept and at least one, e.g. Spring)
  • App servers (like JBoss. The concept at least and pros/cons against lightweight solutions)
  • Build tools (Ant, Maven, Sbt, Leiningen, depends on the language)
  • Testing
    • TDD, BDD, mocks, stubs, load tests, unit testing patterns, integrations tests, acceptance-level tests, non-functional tests, property-based tests, ...
  • Databases
    • Relational
      • Working proficiency with SQL
      • Transactions (local vs distributed), ACID, dirty reads, transaction isolation levels, etc
      • optimistic/pessimistic locking
    • NoSQL - when to use which, pros, cons, etc
    • ORM tools
  • Middleware
    • HTTP protocol
    • Network protocols (TCP, UDP, SSL, ...)
    • Messaging - Enterprise Integration Patterns, JMS or some alternative, ActiveMQ or some alternative
    • REST
    • SOAP (not so relevant any more)
    • Synchronous vs asynch communication. When to use which, benefits and pitfalls.
    • Markup languages - xml, json, yaml, ...
  • Small-scale architecture 
    • packaging, layering principles, cohesion, coupling, static code quality metrics, MVC, UML, Hexagonal Architecture
    • Patterns: pipeline, circuit-breaker, ...
  • Big-scale  architecture
    • SOA, microservices vs monoliths
    • Scalability (vertical, horizontal, functional decomposition)
    • CAP theorem
  • Domain-Driven Design
  • HTML, DOM, Javascript
  • Continuous Integration/Delivery tools
  • Deployment tools (Ansible, Capistrano, ...)
  • Cloud - e.g. AWS
  • Project management methodologies (Scrum, Kanban, ...)
  • OSs
  • Networks
I'm sure I missed some pretty obvious ones...