Posts

Handling Exception Using Spring's Aspect Oriented Programming

In this post, I will show you how we can handle exceptions using springs aspect-oriented programming. Prerequisites To follow this article you should have JDK 8+   gradle 2.3 +  Your favorite IDE (I used IntelliJ Idea) Folder Structure The folder structure should be as follows  aopexeptionhnadling ├── build.gradle └── src     ├── main     │   └── java     │       └── net     │           └── asifhossain     │               └── aopexceptionhandling     │                   ├── aop     │                   │   └── ExceptionLoggerPointCut.java     │                   ├── AopExampleApp.java     │                   └── service     │                       └── ExceptionalService.java     └── test         └── java             └── net                 └── asifhossain                     └── aopexceptionhandling                         └── AopExampleAppTest.java Creating Gradle Build File Create a file named build.gradle in application with the following content build.gradle Creating the se

Most Valuable Agile Suggestion I Have Ever Had

Not every day you fall into a loop with a youtube video. If it's about technology the cases are rarer. But a few months ago that happened to me. I was watching a video on agile by Agile Samurai. At the end of that video, he told something that certainly changed my life. So basically the suggestion goes like this " Deliver something of value every week." No matter what position you are on, no matter what role you play, no matter what job you are in, do something  Deliverable  that adds value to your company every week. Look how I emphasized on Deliverable !   Let tell you a bit more about it. Deliverable I could have used learn, do, etc. But I choose  deliverable . Because a deliverable is has a special meaning. It is quantifiable and tangible. A deliverable could be a report, a document, a software product, a server upgrade or any other building block of an overall project. A deliverable might even consist of smaller deliverables.  So What Happens When You H

What is a View in oracle?

View in Oracle A view in Oracle database is simply a SELECT query that is given a name and stored in memory for later use. A view can be made joining one or more table and later be queried like a virtual table. How to Create a View Suppose we have the following query. SELECT customerid , customername FROM customers WHERE countryid = 'US' ; Now we can create a view with this query as follows CREATE VIEW us_customers AS SELECT customerid , customername FROM customers WHERE countryid = 'US'; Now, this view can be used instead of the full query SELECT customerid , customername FROM us_customers WHERE customerId > 50 ; Oracle will transform the query into following one SELECT * FROM ( select customerid , customername from customers WHERE countryid = 'US' ) WHERE customerid BETWEEN 100 AND 200 How to Update a View To update a view we can use CREATE OR REPLACE VIEW statement to update a view CREATE OR REPLACE VI

Refactoring Comparators in Java 8

In this article, I will show how  we  can refactor our old ugly comparators to cool elegant one. Example Domain Class Employee { private int salary; private int yearsOfExperience; int getSalary() { return salary; } public int getYearsOfExperience() { return yearsOfExperience; } } Use Case Sort a list of  Employee  class by  salary ,  yearsOfExperience  etc. Java 7 Code Sorting By Salary employees.sort(new Comparator<Employee>() { @Override public int compare(Employee o1, Employee o2) { return o1.getSalary() - o2.getSalary(); } }); Sorting By Years of Experience employees.sort(new Comparator<Employee>() { @Override public int compare(Employee o1, Employee o2) { return o1.getSalary() - o2.getSalary(); } }); This code looks ugly. Actually, it became ugly after the introduction of lambda operator. Refactoring in Java 8 Java8  introduced a new operator