SwiftUI is a new Toolkit introduced by Apple in WWDC 2019. As per Apple description:-
SwiftUI is an innovative, exceptionally simple way to build user interfaces across all Apple platforms with the power of Swift. Build user interfaces for any Apple device using just one set of tools and APIs.
So without delay let’s start our deep-dive into SwiftUI.
SwiftUI is a toolkit provided by Apple to build a user interface such as Custom Controls, Animations, Effects programmatically in a simple, declarative way. …
Recently I got this interesting problem to solve. To parse a JSON with the content of dynamic type. JSON looked something like this:-
As one can see a value for property content can be an Int or String. In future, there can be different types of content added like Float, Dictionary etc.
In Swift, we use Decodable to parse any JSON to its respective Model. So let’s first create an equivalent Struct for above-mentioned JSON. On my first try, I created something like this:-
So what will be the type of content mentioned in Struct Body?
Recently I was working on a sample project link. The objective of this project was to consume a list of user feedbacks in a given period of time, derive some information out of it and display it in a meaningful format. What I did was to fetch all the data in a selected range and then find an average rating and number of user who gave that rating over a periodic interval. Then show this information a line chart using iOS Charts library.
This solution seems to be simple and meaningful. But I started seeing a few code smell problem…
In today’s era, we as Software Developer have been in a mode of delivering gobs and gobs of features in shorter sprints. This practice has taken us away from one of our core responsibility as Software Developer that is writing Simpler, Reliable and Anti-Fragile Software. We use “easy” frameworks and tools, without giving the problem due thought. That we confuse easiness, with simplicity.
This blog is a reflection of my thought and understanding about writing simpler code. I went through a few articles and videos about software complexity and how to deal with it. …
In our last session, we have talked about Functional ways to do error handling and looked at how this is a better way to handle errors. To achieve this we introduced some new Data Types like Optional, Try, Either. These are Functional Data Types and they helped to solve Exception/ Error handling issues. Today we will talk about simplifying DI in our app.
DI is a concept which makes a class independent of its dependency management. It achieves that by decoupling the usage of an object from its creation. This helps you to follow SOLID’s dependency inversion and single responsibility…
Till now we have been mostly talking about Functional Concept like Composition and Currying with some practical usage. But for a change, I thought to pick a topic which developers encounter in an everyday scenario.
Throwing an exception and handling them in a try catch block is something which every developer encounter quite often. But if u forget to handle an exception “all hell breaks loose” at runtime. This becomes one of the most commons reasons for an application to crash in production or become unresponsive. Making your application looks bad.
An excellent question. But a simple answer. Exceptions are…
So from our last session, we learned about Function Composition. Why do we need it? How to do it? How to make composition convenient by removing a lot of boilerplate? So continuing with the same theme of functional programming. The next stop will be at Function Currying.
So today we will try to answer following questions regarding Function Currying:-
1. What is Function Currying?
2. Why do we need function Currying?
3. How to convert a function to curried function?
4. How Function Currying help us in a day to day programming?
With these questions answered, we will be one…
essence of programming
Continuing from our last session on Side-effect we will continue our journey to explore the core concepts of functional programming. The next stop in our journey is at Composition. One of the most important concepts of programming for any kind of programming style.
Today we answer 3 basic questions regarding Composition.
1. What is composition?
2. Why is composition required?
3. How to compose a function?
Composition is the process of combining two or more smaller components to produce a new larger component. The word component has different meaning in different context. In functional programming, components are…
A pure function is
Advantages of pure functions
Side-effect is some extra work done when calling a function which changes something in the world around it. Lets take an example to understand it better.
Software Engineer, Blogger, Tea Lover and Learner