September 30, 2019

Immutable Go Object

Every Go programmer knows about the receiver in go, which be declared as: type X struct {} func (receiver X) doThing() {...} We have two types of receiver in golang, which is Value receiver and Pointer receiver. Basically, the receiver in golang could be map to self in other programming languages and the function which uses the receiver will be pointed from struct type of the receiver. So, what does this means, anyway? Read more

March 25, 2019

Type embedding not inheritance

Since we don’t have classes in go, you can say struct will do a job to make objects. So how 4 principles of object-oriented programming represent in golang? In this post, we will discuss about the principle of OOP that make golang more better than other object oriented programming language: inheritance. A simple question, how does Golang represent inheritance principle even if it doesn’t have extends? We can easily find out the answer of this question: embedding type Read more

March 23, 2019

Why can't initialize object from abstract class (java)

Difference between Abstract class and Interface is one of the most be confused problem when the first time I learnt Java. In which case we should use Abstract class and which case we should use Interface? Let’s take a deeper look in this two of concepts. By defination, the Abstract class (java) is a class but unlike a simple java class, it’s may not only contain regular defined methods but may also contain abstract methods or a mix of regular and abstract methods. Read more

February 24, 2019

How much your objects encapsulate ?

Encapsulate ( tài liệu tiếng Việt thường dịch là đóng gói ) hay được nhắc đến và ví dụ như là cách để che giấu thông tin trong lập trình hướng đối tượng. Tức là trạng thái của đối tượng được bảo vệ không cho các truy cập từ code bên ngoài như thay đổi trong thái hay nhìn trực tiếp. Việc cho phép môi trường bên ngoài tác động lên các dữ liệu nội tại của một đối tượng theo cách nào là hoàn toàn tùy thuộc vào người viết mã. Read more

© khanhtc 2019