Skip to main content

Posts

Showing posts from July, 2017

Scala - Learning by understanding Functional Programming Terminology Part 2

Introduction lambda , who named lambda lambda? why did they call it lambda, is it simple or complex? map , what is it? why name map - map? why did they call it map, is it simple or complex? functor , why name functor a functor? what is it? why did they call it functor is it simple or complex? In  Part 1  we have covered background on  FP , why we should use, why not, where it's strength is and where it's weaknesses are. In this part (2) we are going to move on and discuss more  FP  terminology. Lambda Is lambda a function? anonymous function only? a subset of mathematics? both? let's do some research: Wikipedia says Anonymous functions originate in the work of Alonzo Church in his invention of the lambda calculus in 1936, before electronic computers, in which all functions are anonymous.[2] In several programming languages, anonymous functions are introduced using the keyword lambda, and anonymous functions are often referred to as lambdas or lambda abstra

Scala Design Patterns Book Review

Introduction There are many books about scala, some are both advanced and incomprehensible to most, some are not only simple and introductory, but there is currently only one book which managed to touch the sweet spot of a balance between presenting advanced topics and being comprehensible. This book is  Scala Design Patterns by John Hunt . I don't read it because of the design patterns! I mean you can read this book in two ways. First way as a standard scala design patterns book. But the way I read it, is as a book written by an excellent writer who knows to explain himself, excellently, and as he want's to describe the design patterns in scala language, he describes scala concepts, and he manages to do it much better than every book i have seen so far! What the book covers So what does the book cover, or what did I learn from it? many things I found hard to grasp by other books! here is the list: Mixin composition - Will guide you on how to compose functionalit

Functional Programming in Scala for Working Class OOP Java Programmers - Part 1

Introduction Have you ever been to a scala conf and told yourself "I have no idea what this guy talks about?" did you look nervously around and see all people smiling saying "yeah that's obvious " only to get you even more nervous? . If so this post is for you, otherwise just skip it, you already know fp in scala ;) This post is optimistic, although I'm going to say functional programming in scala is not easy, our target is to understand it, so bare with me. Let's face the truth functional programmin in scala is difficult if is difficult if you are just another working class programmer coming mainly from java background. If you came from haskell background then hell it's easy. If you come from heavy math background then hell yes it's easy. But if you are a standard working class java backend engineer with previous OOP design background then hell yeah it's difficult. Scala and Design Patterns An interesting point of view on scala, is

Simplicity and Adapatability in interface design

Introduction How do you like your model and api? detailed, with separate classes or more uniform and lightweight with less classes, but with heavier objects, where some of the properties are optioal? Well, there is a delicate line in interface design between simplicity and adaptability, and it is up to you to decide also on what is a viable design - just enough design to satisfy your needs but keeping in mind you might need to extend it in future. If that wasn't clear or something let's step up for an example and see what I'm talking about. This is an open discussion, I like to hear thoughts and refine and tune my thinking, so I hope you have much to say about it. We are using scala language for compactness of example but this does not mean it's useful only for scala it's just an example. Step 1 simple single data class We start by exploring a simple design, we have some process and we want to report on it's progress, therefore our domain model will commu

Is ElasticSearch Set/Get Eventual Consistent?

Introduction ElasticSearch does much of the heavy lifting on handling horizontal scalability for us, managing failures, nodes, shards. Now I was just getting into it a few days ago in a new project I was working at. I wanted to know if the SET/GET operation is eventually consistent or not. I started by thinking, well it's a nosql, there are replicas, it should be eventually consistent but then I read some documentation which leads me to interesting insights at least if you are the client writing the data in whether for you its going to be eventual consistent if you try to read from a replica. But first, allow me to summarize for you some of the concepts I have learned and then I will say what I think about SET/GET eventual consistency. (I also did a local cluster test to confirm that.) cluster.name Nodes with the same name belong to same cluster The cluster reorganizes itself as we add or remove data, meaning it manages moving data between nodes if needed. Master Node