Quotes and lessons from the book “Design Pattern in Ruby, Russ Olsen”

October 28, 2012 § Leave a comment

Quotes and lessons from the book “Design Pattern in Ruby, Russ Olsen”

Patterns of patterns

The GoF did two things for us. First, they introduced most of the software engineering world to the idea of design pattern, where each pattern is a prepackaged solution to a common design problem. We should look around, they wrote, and identify common solutions to common problems. We should give each solution a name, and we should talk about what solution is good for, when to use it, and when to reach for something else. https://hajimezhao.files.wordpress.com/2012/10/design-pattern-in-ruby.jpg A set of general principles for GoF patterns is given as:

  • separate out things that change from those that stay the same: identify and separate static and dynamic parts
  • program to an interface, not an implementation: define the program behavior first, not how to achieve it
  • prefer composition over inheritance: we try to avoid saying that an object is a kind of something, and instead say that is has something. Because the relation is a kind of sth is ambiguous in some contexts, and cause troubles of translating real world concepts into OOP objects
  • delegate, delegate, delegate: delegate responsibility to multiple layers to reduce system complexity
  • You Ain’t Gonna Need It (YAGNI): (a new added principle) it says we should not implement features, or design in flexibility, that we don’t need right now. Because changes are, you ain’t gonna need it later.

Patterns in Ruby

The characteristics of Ruby language leads to open other 3 patterns:

  • The Internal Domain-Specific Language (DSL), a very dynamic twist on building specialized little languages
  • Meta-programming, a technique for creating just the classes and objects that you need, dynamically at runtime
  • Convention Over Configuration: the main motive behind this pattern is to lighten the configuration burdens which cost extra efforts. An example is to compare the HTTP request handling of Java servlet and Rails.
    • In Java, servlet is an elegant little Java class that knows how to handle HTTP request coming into one or more URL. But writing a Java class that extends javax.servlet.HttpServlet is not enough, you also need to configure the things, via the web.xml configuration file
    • In Rails, convention defines which methods handle which URL request neatly – see Rails RESTful cheatsheet


List of my favourite programming blogs

October 28, 2012 § Leave a comment

List of my favourite programming blogs

The following are my favourite collection of CS blogs:

The Heart of the Buddha’s Teaching, Thich Nhat Hanh – part 1

July 18, 2012 § Leave a comment

This space is to contain my favorite quotes from the book “The Heart of the Buddha’s Teaching”, Thich Nhat Hanh.

Chapter 01: Entering the Heart of the Buddha

The ocean of suffering is immense, but if you turn around, you can see the land. The seed of suffering in you may be strong, but don’t wait until you have no more suffering before allowing yourself to be happy. When one tree in the garden is sick, you have to care for it. But don’t overlook all the healthy trees. Even while you have pain in your heat, you can enjoy many wonders of life — the beautiful sunset, the smile of a child, the many flowers and trees. To suffer is not enough. Please don’t be imprisoned by your suffering.

If you have experienced hunger, you know that having food is a miracle. If you have suffered from the cold, you know the preciousness of warmth. When you have suffered, you know how to appreciate the elements of paradise that are present. Don’t ignore your suffering, but don’t forget to enjoy the wonders of life, for your sake and for the benefit of many beings.

Without suffering, you cannot grow. Without suffering, you cannot get the peace and joy you deserve. Please don’t run away from your suffering. Embrace it and cherish it. Go to the Buddha, sit with him, and show him your pain. He will look at you with loving kindness, compassion, and mindfulness, and show you ways to embrace your suffering and look deeply into it. With understanding and compassion, you will be able to heal the wounds in your heart, and the wounds in the world. The Buddha called suffering a Holy Truth, because our suffering has the capacity of showing us the path to liberation, Embrace your suffering, and let it reveal to you the way to peace.

Chapter 02: The First Dharma Talk

The Buddha said, “Dear friends, I have seen deeply that nothing can be by itself alone, that everything has to inter-be with everything else. I have seen that all beings are endowed with the nature of awakening.”

The Buddha then declared, “Dear friends, with humans, gods, brahmans, monastics, and maras as witnesses, I tell you that if I have not experienced directly all that I have told you, I would not proclaim that I am an enlightened person, free from suffering. Because I myself have identified suffering, understood suffering, identified the causes of suffering, removed the causes of suffering, confirmed the existence of well-being, obtained well-being, identified the path to well-being, gone to the end of the path, and realized total liberation, I now proclaim to you that I am a free person.”

Chapter 03: The Four Noble Truths

After realizing complete, perfect awakening, the Buddha had to find words to share his insight. He already had the water, but he had to discover jars like the Four Noble Truths and the Noble Eightfold Path to hold it.

The Buddha did not deny the existence of suffering, but he also did no deny the existence of joy and happiness. If you think that Buddhism says, “Everything is suffering and we cannot do anything about it,” that is the opposite of the Buddha’s message. The Buddha taught us how to recognize and acknowledge the presence of suffering, but he also taught the cessation of suffering. If there were no possibility of cessation, what is the use of practicing? The Third Truth is that healing is possible.

Chapter 04: Understanding the Buddha’s Teachings

When we hear a Dharma talk or study a sutra, our only job is to remain open. Usually when we hear or read something new, we just compare it to our own ideas. If it is the same, we accept it and say that it is correct. If it is not, we say it is incorrect. In either case, we learn nothing. If we read or listen with an open mind and and open heart, the rain of the Dharma will penetrate the soil of our consciousness.

The gentle spring rain permeates the soil of my soul. A seed that has lain deeply in the earth for many years just smiles.

While reading or listening, don’t work too hard. Be like the earth. When the rain comes, the earth only has to open herself up to the rain. Allow the rain of the Dharma to come in and penetrate the seeds that are buried deep in your consciousness. A teacher cannot give you the truth. The truth is already in you. You only need to open yourself – body, mind, and heart – so that his or her teachings will penetrate your own seeds of understanding and enlightenment. If you let the words enter you, the soil and the seeds will do the rest of the work.

Please remember that a sutra or a Dharma talk is not insight in and of itself. It is a means of presenting insight, using words and concepts. When you use a map to get to Paris, once you have arrived, you can put the map away and enjoy being in Paris. If you spend all your time with your map, if you get caught by the words and notions presented by the Buddha, you’ll miss the reality. The Buddha said many times, “My teaching is like a finger pointing to the moon. Do not mistake the finger for the moon.”

After reading a sutra or any spiritual text, we should feel lighter, not heavier. Buddhist teachings are meant to awaken our true self, not merely to add to our storehouse of knowledge.

From time to time the Buddha refused to answer a question posed to him. The philosopher Vatsigotra asked, “Is there a self?” and the Buddha did not say anything. Vatsigotra persisted, “Do you mean there is no self?” but the Buddha still did not reply. Finally, Vatsigotra left. Ananda, the Buddha’s attendant, was puzzled. “Lord, you always teach that there is no self. Why did you not say so to Vatsigotra?” The Buddha told Ananda that he
did not reply because Vatsigotra was looking for a theory, not a way to remove obstacles. One another occasion, the Buddha heard a group of disciples discussing whether or not he had said such and such, and he told them, “For forty-five years, I have not uttered a single word.” He did not want his disciples to be caught by words or notions, even his own.

When an archaeologist finds a statue that has been broken, he invites sculptors who specialize in restoration to study the art of that period and repair the statue. We must do the same. If we have an overall view of the teachings of the Buddha, when a piece is missing or has been added, we have to recognize it and repair the damage.

Chapter 05: Is Everything Suffering?

If we are not careful in the way we practice, we may have the tendency to make the words of our teacher into a doctrine or an ideology. Since the Buddha said that the First Noble Truth is suffering, many good students of the Buddha have used their skills to prove that everthing on Earth is suffering. The theory of the Three Kinds of Suffering was such an attempt. It is not a teaching of the Buddha.

Today, many people invoke the names of the Buddha or do similar practices mechanically, believing that this will bring them insight and emancipation. They are caught in forms, words, and notions, and are not using their intelligence to receive and practice the Dharma. It can be dangerous to practice without using your own intelligence, without a teacher and friends who can show you ways to practice correctly. Repeating a phrase like “Life is suffering” might help you notice when you are about to become attached to something, but it cannot help you understand the true nature of suffering or reveal the path shown to us by the Buddha.

Buddha says that he only want us to recognize suffering when it is present and to recognize joy when suffering is absent.

It is true that the Buddha taught the truth of suffering, but he also taught the truth of “dwelling happily in things as they are.” To succeed in the practice, we must stop trying to prove that everything is suffering. In fact, we must stop trying to prove anything. If we touch the truth of suffering with our mindfulness, we will be able to recognize and identify our specific suffering, its specific causes, and the way to remove those causes and end our suffering.

(To be continued)

Phân biệt khái niệm: computer scientist vs. programmer vs. developer

April 15, 2012 § Leave a comment

Một bài viết hay về phân biệt 3 vai trò:

  • computer scientist
  • programmer
  • developer

Bạn muốn sống theo lựa chọn nào? 😀

Technology and Vision

February 26, 2012 § Leave a comment

Cisco: The Future of Shopping

Cisco: The Future of Energy Management

Futuristic Japanese Cars

Khóa học online miễn phí về Software as a Service (SaaS) của trường đại học Stanford

February 9, 2012 § Leave a comment

Gần đây, trường đại học Stanford có mở một số khóa học miễn phí online về Computer Security, Cryptography … Trong đó khóa học về SaaS có nhiều sức thu hút đối với tôi.

Software as a Service (SaaS) là một dạng ứng dụng của điện toán đám mây (Cloud Computing) cung cấp các service/software mà người dùng không cần phải tốn bộ nhớ để cài đặt thêm trên máy tính của mình. Một vài ví dụ điển hình về SaaS là: Gmail, Google Docs, Google Calendar là những dạng service/software mà người dùng chỉ cần thông qua web browser là có thể truy cập và sử dụng được chức năng của chúng. Một lợi ích đáng chú ý của hình thức điện toán này là bạn có thể truy cập đến dữ liệu (personal data) và không gian làm việc của mình (personal workspace) từ bất cứ nơi đâu, bất cứ máy tính hay thiết bị điện tử tính toán nào chỉ với một điều kiện là có kết nối Internet.

Ngoài ra, khóa học SaaS còn chú trọng hướng sinh viên đến qui trình phần mềm Agile Programming. Đây là qui trình phần mềm mới được sử dụng khá nhiều gần đây. Trọng tâm của qui trình này là hạn chế tách 2 giai đoạn thiết kế (design) và viết code (implementation) thành hai giai đoạn độc lập. Thay vào đó các developers sẽ viết các chương trình mẫu (prototype) để demo ý tưởng mà họ hiểu được từ yêu cầu (requirement) của khách hàng (customers), và tiếp theo đó khách hàng sẽ phản hồi lại độ tốt xấu của prototype này, và sau đó developers sẽ tiến hành sửa đổi lại cho phù hợp hơn, qui trình này sẽ lặp đi lặp lại cho đến khi cả 2 phía developers và customers đạt được thống nhất.

Textbook được sử dụng trong khóa học: “Engineering Long-Lasting Software: An Agile Approach Using SaaS and Cloud Computing,” Beta Edition, by Armando Fox and David Patterson.