scala

Error Handling in Scala with Option, Try/Catch and Either

Reading Time: 3 minutes Error handling is the process of handling the possibility of failure. For example, failing to read a file and then continuing to use that bad input would clearly be problematic. Noticing and explicitly managing these errors saves the rest of the program from various pitfalls. Exceptions in Scala work the same way as in C++ or Java. When an exception occurs, say an Arithmetic Exception then the Continue Reading

Synchronous Testing In Akka ToolKit | Testing Classic Akka Actors

Reading Time: 3 minutes Akka, a free open source toolkit simplifying the construction of concurrent and distributed systems/applications. In this blog, we are gonna discuss Testing the Akka Actors Synchronously. Usually, we people say that testing the Akka Actors is a bit confusing and tricky too, but it isn’t. Coming to the types of testing in Akka Toolkit, we have two types of testing i.e. Synchronous Testing and Asynchronous Continue Reading

Understanding Akka Streams and Its Components

Reading Time: 4 minutes Overview In this blog, we’ll be understand about akka streams and its components. Also, we’ll do a simple exercise that involves each of these components. Introduction Stream A stream is a flow of data that involves moving and transforming data. An element is the processing unit of the stream. Akka Streams In software development, there can be cases where we need to handle the potentially Continue Reading

How to do Unit testing using embedded PostgreSQL in Akka

Reading Time: 2 minutes Embedded PostgreSQL provides a platform neutral way for running PostgreSQL binary in unit tests. It is an efficient database to write test cases as it supports all data types of PostgreSQL. In this blog I will not dive deep in the features of Embedded PostgreSQL but rather focus on it’s integration with an Akka application. I have added a sample project for the better understanding. Continue Reading

Akka Typed: Stateful to Stateless

Reading Time: 4 minutes This blog is for people getting started with Akka typed actors. We’ll look at how we can keep state inside an actor in a few different ways. Cover the code from stateful to stateless. Introduction Typed Actors consist of 2 “parts”, a public interface and an implementation. If you’ve done any work in “enterprise” Java, this will be very familiar to you. As with normal Continue Reading

Cats Effect : Pure Functional way to code in Scala

Reading Time: 2 minutes Follow 5 Simple Rules with Cats Program written using Cats Effect provides incredibly strong guarantees and powerful functionality, performance, safety, and composability, provided you follow each of the following rules: Wrap all side-effects in delay, async, blocking, or interruptible (pro tip: try to keep the size of your delay blocks small; two delays with a flatMap is much better than one big delay) Use bracket or Resource for anything which must be closed Never hard-block a thread outside of blocking or interruptible Use IOApp instead of writing your own def main Continue Reading

Learn How To Start OOPS IN SCALA

Reading Time: 6 minutes INTRODUCTION Scala is a functional-object-oriented programming hybrid that seamlessly integrates the features of object-oriented and functional languages. It has the capability to interoperate with existing Java code and libraries. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function. Why object-oriented? Scala Continue Reading

Higher Order Functions in Scala

Reading Time: 3 minutes Introduction: Some functions are called higher-ordered functions as they accept functions as parameters. You can also have a higher-order function as one that returns the functions. So basically, if there is a function that deals with a function, is kind of a meta-level, we call it higher order. Why do we use higher order functions..?? Because we want to be able to reuse our code Continue Reading

Recursion and Tail Recursion in Scala

Reading Time: 4 minutes Introduction: Recursion is quite common in the programming world. If you don’t know recursion, it means, solving a problem by breaking it into smaller sub-problems until you solve it trivially. You can easily spot recursion if you see a method calling itself with a smaller subset of input. Recursion and immutability are corner zone of functional programming. As we have seen earlier, while using loops, Continue Reading

A Simple Introduction to Higher Order Functions in Scala

Reading Time: 4 minutes Overview In this blog, we’ll understand the concept of higher order function in Scala. Also, we’ll learn about some of the most commonly used higher order functions in Scala. Higher Order Function A function is said to be a Higher Order Function if it can take another function as an argument or returns a function as its result. This is possible because of the fact Continue Reading

How to use Exception Handling Mechanism

Reading Time: 4 minutes Introduction: One of the fundamental and important aspects of programming is Exception Handling. A program needs an environment to handle the potential errors and abnormal conditions. Programming does not end with writing code that executes and creates a result, as we also have to handle errors in a user-friendly manner. There are several types of errors that could occur when we run a program. Some Continue Reading

Introduction of Inheritance and its types in Scala

Reading Time: 5 minutes One of the important topics of Object-Oriented Programming is Inheritance. Inheritance allows us to define a class in terms of another class, which allows us in the reusability of the code. Here I’ll be giving you an introduction to inheritance in Scala. What is Inheritance in Scala ? It is the instrument in Scala by which one class is permitted to acquire the features(fields and Continue Reading

Collections in Scala (Part-2) | Set

Reading Time: 4 minutes Collections in Scala systematically distinguish between mutable and immutable collections. In the previous blog, we had covered – An Overview of Collections and its types in Scala (Im)Mutability in Scala You may go through the Collections And (Im)Mutability in Scala (Part-1). So, In this Blog we will discuss Scala Set in detail. Set – Scala Sets are iterables that does not contain any duplicate element. Continue Reading