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

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

Three Rules for Effective Exception Handling

Exceptions in Java provide a consistent mechanism for identifying and responding to error conditions. Effective exception handling will make your programs more robust and easier to debug. Exceptions are a tremendous debugging aid because they help answer these three questions: What went wrong? Where did it go wrong? Why did it go wrong? When exceptions … Continue reading Three Rules for Effective Exception Handling

10 Most Useful Java Best Practice Quotes for Java Developers

Quote 1: Avoid creating unnecessary objects and always prefer to do Lazy Initialization Object creation in Java is one of the most expensive operation in terms of memory utilization and performance impact. It is thus advisable to create or initialize an object only when it is required in the code. Quote 2: Never make an … Continue reading 10 Most Useful Java Best Practice Quotes for Java Developers

Encapsulation in java and its relation with abstraction

Most of you will agree that encapsulation and abstraction together brings a lot of confusion. Most blogs add only confusion further. Lets solve this puzzle. I started working on this post after my previous post “Understanding abstraction in Java“. My goal was to understand encapsulation in java and how it relates to abstraction. As soon … Continue reading Encapsulation in java and its relation with abstraction

Understanding abstraction in java

In computer science, abstraction is the process by which data and programs are defined with a representation similar in form to its meaning (semantics), while hiding away the implementation details. Source : WikiPedia abstraction – a concept or idea not associated with any specific instance. Sections: What is abstraction Types of abstraction How to use abstraction in … Continue reading Understanding abstraction in java