Welcome to the 6th part of this series: “Powerful Design Patterns to create an Amazing Stopwatch App”. Our Stopwatch App is almost complete. We just have to give a good finishing touch to it. The problem with the current version of our app is: It is not scalable. Take a look at the way we have handled the button presses in a state:

private void handleStartPress() {
if(currentState==NOT_RUNNING)
{
sw = new Stopwatch();
sw.registerObserver(this);
sw.start();
start.setText("Pause");
stop.setVisible(true);
currentState=RUNNING;
}
else if(currentState==RUNNING)
{
sw.stop();
start.setText("Resume");
currentState=PAUSED;
}
else if(currentState==PAUSED)
{
sw.start();
start.setText("Pause");
currentState=RUNNING;
}

}

Too many if-else statements. If we…


Welcome to the 5th part of this series. In the last tutorial, we focused on building our UI, designing our layout, and adding minimal functionalities to our app. Now that we have our UI ready, we can think of making the UX better.

Previous Tutorial

If you are reading this part first, you should definitely check out Part 4 of this series to catch up.

Right now, our app looks like this:


Welcome to the 4th tutorial of this series. From the last 3 tutorials, we have been focusing on our Core Stopwatch class. We tried to make it better and better, reducing the client-side code as much as possible. Now it’s time to move on and focus on using this Stopwatch class in our Swing App.

Previous Tutorial

If you are reading this part first, you should definitely check out Part 3 of this series to catch up.

Before diving into any of the code, let’s take a look at what we are going to make.


Welcome back to the 3rd tutorial of this series. As identified in the previous tutorial, we have a logic issue in the stopwatch. To see the time of the stopwatch, we are just printing out the time but in most applications, we do not want the time to be printed out on the console, (in fact, no application has a console nowadays). We want the stopwatch to return the time asynchronously to the client so that the client can do whatever it wants to do with the time. Seems like a nice design problem, right?

Observer Pattern to the rescue.

Previous Tutorial


Welcome to the second part of this series “Powerful Design Patterns to create an Amazing Stopwatch App”. Until now, we have just figured out the working of our core stopwatch class. But the problem is that we have to explicitly call the getTime() method of our stopwatch class to get the time at a particular instant. But that was not satisfactory for us. We wanted to see the stopwatch running and that is the reason, from the client-side, we made a different thread just to watch the stopwatch running with continuous time-updates. But the client-side code is becoming heavier and…


Answer me one question. Do you think that writing programs are easy? Well, it depends on the problem (and on the programmer’s mood too). Do you think writing structured programs are easy? Adding one word to the question made a lot of change. First of all, what do you mean by structured programs? And how do you write programs that are easily understood by other people without even reading your code comments? It is a fairly difficult task and the concept of Object-Oriented Programming tries to solve it by using four principles: Abstraction, Encapsulation, Polymorphism, and Inheritance. With the advent…


One of the biggest nightmares of a ML beginner is the different kinds of complicated classification metrics (like Confusion Matrix, Precision, Recall and so on.) that are used by advanced people. As beginners, we normally tend to use Accuracy for evaluating which model performs better. But sometimes accuracy cannot be relied upon. Suppose we have two models which have the same accuracy, what next metric should we use to infer which model is better? That’s what we are going to discuss in this blog.

Table of contents:

  • Confusion Matrix
  • Accuracy and why it cannot be relied
  • Precision and Recall
  • Specificity…


Have you ever wondered how cars drive by themselves? Have you ever wondered how Siri / Cortana respond to your commands sarcastically sometimes? Well, all these benchmark applications have a core algorithm embedded in their systems which are trained by human behaviour. Those who are familiar with the term “Artificial Intelligence” will say that the algorithms driving these benchmark applications are “Machine Learning” algorithms and particularly “Deep Learning” algorithms. But, whenever I hear the term Deep Learning, the image of a neural network pops up in my mind. But have you ever wondered how these clever networks learn? How these…


If you are a Machine Learning Beginner, you might have heard about this term, “Bias Variance Trade Off”. The term might feel very heavy and hard to understand, but trust me, it is very very simple. This concept applies to all the Machine Learning and Deep Learning models, not just a particular model.

We will dive into what Bias and Variance really means but first let us look into these set of points that are plotted on the graph below:


If you have ever wondered what the distance parameter(as highlighted in the image below) is and what are the different types of distance metrics used in Machine Learning, this blog will certainly help you.

Rajtilak Pal

Android App, Machine Learning and Deep Learning Integration Enthusiast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store