Java 8: The First Taste of Lambdas

Project Lambda is the major theme in the upcoming Java 8 and probably the most awaited one among Java developers. There’s one interesting feature that is being added to Java along with lambdas – the defender methods. In this blog post my intention is to look under the covers – to see how lambdas are represented … Continue reading Java 8: The First Taste of Lambdas

Java NIO qua một vài ví dụ

Java quá chậm, "biết rồi khổ lắm nói mãi", đây là một trong những điểm yếu lớn trên một vài công nghệ của Java và I/O là một ví dụ điển hình. Là một nhà phát triển ứng dụng, bạn luôn phải đau đầu với những kêu ca từ khách hàng khi quá trình đọc … Continue reading Java NIO qua một vài ví dụ

Why extends is evil

Improve your code by replacing concrete base classes with interfaces The extends keyword is evil; maybe not at the Charles Manson level, but bad enough that it should be shunned whenever possible. The Gang of Four Design Patterns book discusses at length replacing implementation inheritance (extends) with interface inheritance (implements). Good designers write most of their code in terms … Continue reading Why extends is evil

The Law of Demeter Principle

The Law of Demeter Principle (Tạm dịch là luật cho người thứ 3 - đùa đó) Một đoạn hội thoại "Giờ anh tính giải quyết thế nào về chuyện này?""Ah... anh...""Tôi không biết, chuyện của anh và cô ấy, tốt nhất là anh nên tự giải quyết riêng với cô ấy. Đừng để đến lúc … Continue reading The Law of Demeter Principle

The Dependency Inversion Principle

The Dependency Inversion Principle (DIP) (Tạm dịch là nguyên lý đảo ngược sự phụ thuộc) Đây là nguyên lý cuối cùng trong 5 nguyên lý cơ bản trong thiết kế hướng đối tượng SOLID. Nguyên lý này chỉ ra rằng các lớp high-level không được phụ thuộc vào các lớp low-level. Thay vì để các … Continue reading The Dependency Inversion Principle

The Interface Sergregation Principle

The Interface Segregation Principle (Nguyên lý phân tách interface) Đây là nguyên lý thứ 4 trong 5 nguyên lý của thiết kế hướng đối tượng SOLID. Nó giúp giảm sự cồng kềnh, dư thừa không cần thiết cho phần mềm và quan trọng hơn là giảm sự kết dính làm hạn chế tính linh động (flexibility) … Continue reading The Interface Sergregation Principle

Liskov Substitution Principle

Liskov Substitution (LSP) Đây là nguyên lý thứ 3 trong SOLID. Nguyên lý này nói rằng các lớp dẫn xuất phải có thể được thay thế bởi lớp cha. Nguyên lý này được Barbara Liskov đề cập lần đầu tiên trong quyển “Data Abstraction and Hiearchy” xuất bản năm 1988. Xin nói thêm rằng Barbara … Continue reading Liskov Substitution Principle

Working with hashCode and equals methods in java

In this post, i will point out my understanding about hashCode() and equals() method. I will talk about their default implementation and how to correctly override them. I will also write about implement these methods using Apache Commons package’s utility classes. Sections in this post: Usage of hashCode() and equals() Overriding the default behavior Overriding … Continue reading Working with hashCode and equals methods in java