Monday, March 6, 2017

Scalable System Design Patterns

1) Load Balancer : 












2) Scatter and Gather: 











3) Result Cache :











4) Shared Space












5) Pipe and Filter













6) Map Reduce












7)Bulk Synchronous Parellel












8)Execution Orchestrator



Friday, March 3, 2017

REDIS 101


Client Libraries:


Data Types

1) Strings : BinarySafe: MAX 512 MB, you can even save images etc..
2) Set : Unique list of elements. Useful when operation on two different key with : intersect, union, difference

3) SortedSet

4) List
5) Hash : Useful for storing objects with fields. name, surname etc...

Pipelining : Less blocking client code can be achived by means of it : Send multiple request and get one answer as result. Consider: split them to multiple pipelines to reduce memory requirements on server side.using pipelining Redis running on an average Linux system can deliver even 500k requests per second.Is not it enough ? 


Pub/Sub: implements org.springframework.data.redis.connection.MessageListener





Thursday, February 16, 2017

Java 8 Optional examples and usage

        Why OptionalUse it with streams , use it in your return types, make your code safer against to the NPE, make your code more readable...This allows the caller to continue a chain of fluent method calls.

And NoteThe key here is the focus on use as a return type. The class is definitively not intended for use as a property of a Java Bean. Witness to this is that Optional does not implement Serializable, which is generally necessary for widespread use as a property of an object.


If you really wonder what will change in your life with this new Stolen keyword (from Guava) you'd better to read its origin.

More code & less bullshit.. Lets see its usage then..







And you can use in streams as follows

Thursday, February 9, 2017

Java 8 Lambda Building Blocks: Predicate, Function, Consumer, Supplier, BinaryOperator

















Let the code explain itself..Be quiet...And read..










Bye


Java 8 Lambda Expressions

I'll try to explain the topic according to my motto --"No bullshit , Just Code.."

1) SAM= Single Abstract Method = An Interface with Only One Method = Functional Interface

2) A class with a method which will consume a lambda expression

3) Now.. Actionnn...Lambda expression as a parameter





Okeyy... I know some of you need bullshit also :)

If you want to pass a behavior to a parameter (behavior= function=action) just create an interface and annotate it @FunctionalInterface and use Lambda Syntax like i did in above.

(param1,param2,,,,,paramN) -> {play with params}

Java 8 lots of built in @FunctionalInterface inside it. You can use them anywhere you need. Just  google for them .

Bye