Monthly Archives: September 2017

Chatbots and more

This is not the regular programming post, but more of a discussion post and where we are heading with our technology. Alexa, Google Home, Cortona and number of personal assistants are available at our perusal. With these kind of products, we are slowly evolving into artificial intelligence driven technology. Lot of manual labor jobs might be in danger in near future. Politics aside, I am more interested to understand this topic from technology and humane perspective. While we still struggle with lot of other ethical issues with existing technology, AI will only create social conundrums.

What I want to discuss in this post, is more about chatbots. You can think this as a scribbling post. I am just bringing some ideas forefront to build a chatbot using java.

What are chatbots?

Chatbots are crude version of personal assistants. Personal assistants help you in many ways, in process saving you time, providing you leisure. Simplest version of these chatbots are those that answer your questions like “What’s the weather like today?”, a chatbot will connect to a weather website to find out today’s weather and then answer you accordingly. Similarly, on a ecommerce site, I can ask a question by typing “Where can I find this book?”, chatbot will answer “In literature and short stories section”. A chatbot can also help build customer support, taking away the traditional customer support people. In more advance version, same chatbots can build a library based on your likings, dislikings, answers and provide more options for lifestyle.

Wikipedia definition says

A chatbot is a computer program that conducts a conversation via auditory or textual methods.

Chatbots are part of Artificial intelligence that has been popularized these days.

Design of chatbots

In this article, we will not be showing any code for chatbots, but we will be building chatbots in next post. This is a post where we bring the idea of chatbot into design. As we discussed the definition of chatbot, we will be building an agent that will chat with us in a natural language that we use for daily communication.

Me: “Hi Mr. Chatbot, how are you today?”

Mr. Chatbot: “I am fine, Mr. Mali. Thank You”

Me: “What’s the day today?”

Mr. Chatbot: “It’s Wednesday today.”

This is an example of conversation how a chatbot would answer. We will build a database which will have natural language processing ability to find out what question has been asked and based on that answer the question as accurately as possible. This chatbot is an experimental build up.

Does it mean it can falter? Glad you ask that, it definitely means it can answer erratic. But it’s ok in our experimentation world, even Google home had his off days.

We will need a chat engine and we will be using plain English to type our messages. We will use AIML (Artificial Intelligence Markup Language) to build this chatbot.

In conclusion, I would provide the implementation of this chatbot in next few posts. We will have more discussion about chatbots in future articles.

 

References

  1. AIML
  2. Chatbot
Advertisements

Design Pattern – Adapter Pattern – Part VII

Till now, we have discussed all creational type of design patterns. In this and next series of posts, we will be creating a demo about structural design patterns. In this series, our first design pattern is Adapter design pattern. As said, this design pattern is structural design pattern. This design pattern combines the capabilities of two independent interfaces. It basically acts like a bridge between two incompatible interfaces.

Easiest example to understand adapter pattern in real life is the electric socket in different continents provide different voltages. A traveler from Asia can use an adapter in Europe to get 240 V of electricity for electronic devices.

When to use Adapter Design Pattern?

When a client expects different interface than available, at that time adapter pattern can help to convert a interface of a class into another interface that client can use. Adapter pattern allows reuse of lot of code and it is one of the major reasons why it is most favorable among software engineering. A real example you would find in JDK libraries of InputStreamReader and OutputStreamWriter.

How to use Adapter Design Pattern?

So in this implementation, we will show how to use Adapter design pattern. We have a traveler from Asia traveling in Europe, he wants to use his electronic device which needs 240 V of electricity from socket, but Europe only provides 120 V of electricity. We will design an adapter class that will convert 120 V of electricity to 240 V of electricity.

Our target class or client class is AsiaSocket, as shown below:

It’s a simple class with a method provideElectricity.

Our adaptee class is EuropeSocket which implements an interface IEuropeSocket as shown below:

Now we will implement an Adapter class that will provide adapter between Europe and Asia Socket classes. This will look like below:

This class has a constructor to instantiate AsiaSocket and implements IEuropeSocket interface.

Now in our demo class, we will show how to use this adapter pattern.

If you run this demo class, the output will show that we will be getting electricity of 240 V for asian electronic devices in europe.

Download

In this post, we showed how to use Adapter pattern. The demo code will be available on github repository here.

References

  1. Adapter Design Pattern
  2. Adapter Design Pattern in Java

Spring Boot and Microservices

Over the last few months, I have worked on Spring Boot and tried to collect my knowledge around Microservices. I was discussing lot of this with my friends and one friend did suggest me to write a book. Initially I was little hesitant to write a book about something I was learning. But also the whole point of learning is to teach someone at some point of time.

So I took this as a challenge to write a book about Spring Boot and Microservices. Initially I created series of posts and posted on this blog to see how much it could benefit people. And now to make it easy for every one, I have collected all this information and wrote an ebook. This ebook Spring Boot and Microservices is free to download. I hope this will help people to understand the concepts of Microservices and my example can help them to head start the building their projects.

Spring Boot and Microservices

What’s next?

Where do we go from here? There are lot of questions about the next strategy about Spring Boot and Microservices. What I have covered in this book, is a tiny portion of big picture. There is lot of options like scaling the service, adding health check for the service, deploying the service on cloud with automation. But for right now, I just want to take a break from thinking about this and I will come up with a next plan soon.

Till that time, you can download, read and send me your feedback about the book. It will be great if you can leave a review for the book here.

If you have any questions, please leave your comments on this blog and I will try my best to answer them.