engineering dogmas

Over the years in our software community, I’ve seen a lot of dogmas, myths and lies that spread like ‘cholera’. That only reflects the fact that many programmers just repeat like parrots what they ‘learned’ from school, news, books… without their own justification, and to some extent, reflect their lacking of experiences. A good engineer should, at least, have some abilities to judge the pros and cons, weak points and strong points, when to use, and when not to use a method, a language or a technology.

Design first, then code!

The principle is, in general, not wrong. However, pragmatically, a software’s final structure, architecture… is not achievable as product of an immediate thought or a single design cycle. In most cases, the “first design” is certainly not the correct one. It’s not in a deterministic process that we can build software, complex product would always requires a lot of trial and fail. And from my experiences, good designs are sustainable solutions after a tedious process of experiments to eliminate wrong directions. We need coders of strong analysis and experimental skills rather than the “evangelic designers”!

Where are the documents?

We are going to make clear distinction: do we need coders who really understand what they are doing, or we just need some paper to present to customers? In countless cases did I see that coders do not understanding what they are doing: they don’t understand a feature, they don’t know how to archive that, they are unable to judge the pros and cons, they just mechanically copy and paste code from somewhere. Documents only provide rough, general views on the matters. If you’re going to mention about a static-web-page project, I would agree that document is something. But if you’re mentioning system programming, it’s the code that is the document!

Poor skills and wrong knowledges

This is simply put: countless! Just to name a few:

Poor skills: once, a coder being asked to fix a “null pointer exception”. What he did is adding a “if (pointer != NULL)” line into the code. It’s not fixing, it’s just hiding, fixing is find out why the pointer is NULL, not prevent it from being executed! Another time, another coder, getting frustrated under a crash situation, place a “try… catch” around the buggy code segment. This is again, not fixing, with this way of hiding, we’re just going to accumulate faultinesses until the software crashes silently for no reasons!

Object oriented programming rules: OOP is more beautiful in theory than in practice. OOP provides a nice way for modeling, but it come at costs: bloating code. It is not until the project grows above 1M LOC that OOP become a burden, that we would need to do the “functional decomposition” optimization tasks. It’s the execution (functional) tree that decides performance, not the inheritance tree that obscures runtime characteristics!

Design pattern rules: this is again, not true! I agree that patterns reflect some good coding practices, but software could never be built from the so call “patterns” (there hasn’t been any such proven process). I really don’t understand what is a “singleton” if it’s essentially (in C/C++ syntax) a static variable, I also don’t understand what we need from a “factory” if it’s essentially a “switch… case” structure!?

Management myths

Managers tend to forget what they’d learned when they were coders. There’re lots of myths in software management, just some examples:

  • Software people is of a same type and the same background.

  • We already have a book that’s full of standards and procedures for building software. That provide out people with everything they need to know!

  • If we get behind schedule, we can add more programmers and catch up.

  • Project requirements continually change, but change can be easily accommodated because software is flexible.

There have been extensive criticisms on various OOP models and OOP implementations (Java, C#, C++, MFC, Objective C, glib…) The AntiPatterns wiki and many other authors provide good anti-examples on the uses of patterns!

Linus Torvalds, being criticised: “the kernel has no obvious design”, had replied: “Linux is evolution, not intelligent designs”! The same applied for similarly complex projects!

Document is for understanding, but is not the understanding itself.

Software project management is the domain of vast diversity! No simple rules applied to a software process!

3d particles

Some funs with 3D effects. Just some years ago, rendering 3D particles like water, smoke, fire, fog… was an extremely hard task. I remember how struggling it was for me to build 3D models for a waterfall (with moving water) or a shouting-crowd stadium. It’s enjoyable to see how graphics has advanced in the past few years, these effects are now easily achievable.

Video above: the classical Utah teapot with steam coming out from its spout, rendered with Panda3D, the well-known open-source game engine originally released by Disney, which has a feature-rich C++ core with Python scripting for application development.

basic algorithms

The book is my primary source of interest while being a freshman, which presents a wide range of algorithms in a very coherent and systematic way. I remember “rescuing” this hard-copy from a Fahasa‘s junk pile for about 4 USD, which from that time on became a student’s most precious thing! You can read the soft-copy here.

This is among the subjects I was very fascinated the early years at university: algorithms, graph theory, geometry, image processing… I was not quite good at “symbolic” math (like algebra), but “visual” math offered me much inspiration. The thing I would remember most is Robert Sedgewick‘s Algorithms, a book that I’ve read through over and over again many many times. It is indeed the most important Computer Science textbook that beginners MUST read until today.

The Java applet below is “refurbished” from the code I wrote the first year at college, which visualizes the nature of different sorting algorithms (original code was written in Borland C++ 3.1 with BGI – Borland Graphics Interface). This is among my various attempts to visualize the knowledge collected from the book, which had taught me that even a simple thing like “bubble sort” is not that “very simple”! Let select an algorithm in the dropdown list and click ‘Start’ and see the differences!

My visualizations above are very early (1997), much prior to those demonstrations on wiki. Later on, I’d learned that the author R.Sedgewick put a great emphasis on algorithms’ visualizing himself, his work used PostScript. Many new ways of visualization are really impressive and easy to understand, such as this (using JavaScript).

I started with with C/C++ at school, then continue with C/C++, Java, Design Patterns… on various projects. Later I abandoned Design Patterns (and Java), then I abandoned C++. To me there’s no Design Patterns, there’s only data structures and algorithms! Would write another post on the bloating and non-sense usages of Design Patterns later on!

It seems that most software engineers today lack fundamental knowledges and skills. It’s quite apparent that you could not rely on a guy talking about architecture, GoF’s design patterns… all the time but can not state the algorithmic differences between a DFS (depth first search) and a BFS (breadth first search).

parallax

A “3D clip” made by myself just for fun, strictly speaking, this is not 3D video but rather a pseudo – 3D effect, parallax, (tiếng Việt: thị sai) created totally from still images (see on the left). My video is partially inspired by this excellent CSS – only parallax. It’s quite easy to figure out how to acquire this, but let read about the definition from wiki.

This is also a popular technique in game programming, some early (and current) games choose to reduce a full 3D scene to several layers, some use parallax – mapping to acquire a pseudo – spatial effect, all helps eliminating excessive 3D computations. Clip made from random still images captured at Khe Gà, Phan Thiết.

3d graphical user interface

The code is written in C++ base on Clutter 1.2.4 library. It shows basic widgets: tabbed container, scrolling container, list box, combo box, check box, edit box, button, label, radio button…

This is my personal project in which I tried to evaluate some new ideas and concepts in using 3D techniques for GUI (Graphical User Interface). It’s quite tiny indeed (about 6000 LOC – line of code), all written by myself in about a month (mostly in my free times at weekends). So please don’t blame me on some un-completed or un-polished features, they are just for testing the ideas only. I would try to examine the trend of applying 3D graphics to GUI, but first, let have a look at the video below.

1.   The first thing to consider is not 3D engines or hardwares, it is about usability. Many traditional (2D) GUI out there are already complex and obstructive. GUI is about information presentation and presentation should be really simple and clear so that even my grand mother can understand and use. I’ve been seeking, trying to explore many new ways invented to represent information in 3D (or 2.5D) space, and I could say only a very very small percent of them could make a usable value. Users have long been familiar with 2D, and yet 3D hasn’t been very much persuasive.

2.   3D hardwares can be categorized into 3 groups (as listed on the left), and the 3D engine can be configured to off-load calculations to hardware. With the 1st type of device, only bitmap operations could be off-loaded. With the 2nd type of device, many drawing operations (the path_xxx functions) can be off-loaded. The 3rd type of hardware is most valuable since we can have its finish for ourselves a lot of work.

It’s important to understand the target device our software stack would be running on. If it is an out-date machine with just some blitters, we should use paint-like (aka: bitmaps) operations, while on most modern PC, draw-like (aka: 2D vector) operations are more encouraging. While bitmaps may offer nicer and more customizable GUI, the cons is it lacks the scalable ability that vector has.

3.   The last is about software implementation. Many of the graphics concepts are first introduced in software, which then embedded to hardware, which then standardized by software (like OpenGL or DirectX) again. Thus, many elements of a graphics pipeline is the production of a long history of interactive evolution. A graphics pipleline is not a general framework, it depends on very detailed, in-depth techniques to be operational in real-world application.

Game & graphics are the domains where most formal software methods would easily failed. 3D graphics developers should have good knowledge on graphics in general (bitmap and vector drawing), geometry, linear algebra & discrete maths, deep understanding on data-structures and algorithms… are strong pluses, advanced tips & tricks in coding and optimization is a must (game & graphics programming has always been a hell of tricks from the age of dawn) and finally good understanding on 3D techniques (model, scenegraph, projecting, shading, clipping, lighting, effects…)

đường chúng ta đi


Album Đường chúng ta đi – 1976 và Album Tổ quốc yêu thương – 1978

Một chứng tích của lịch sử, album nhạc đỏ (thu âm năm 1976) với sự trình diễn của các ngôi sao nhạc vàng: Lệ Thu, Họa Mi, Hà Thanh, Thanh Tuyền, Thái Châu… Lệ Thu, Hà Thanh thì hẳn ai cũng đã biết, còn Họa Mi, Thanh Tuyền… là những giọng ca chuyên hát cho phòng Tuyên truyền của quân đội VNCH cũ… Một sự kết hợp lạ lùng nhưng vẫn hay trên một khía cạnh nào đó. Biết rằng điều này là khó nghe với khá nhiều người, nhưng âm nhạc vẫn vượt ra khỏi các biên giới chính trị, dù cho cái biên giới ấy nằm trong… chính phần ca từ các bài hát!

Theo như tôi biết, rất nhiều ca sĩ, nhạc sĩ miền Nam cũ đã chọn ở lại VN sau 1975 và phần nhiều cũng đã có những bước đầu hợp tác với chính quyền mới. Chỉ sau đó, khi điều kiện sống quá khó khăn, khi có quá nhiều những ngược đãi vật chất cũng như tinh thần thì họ mới chọn con đường trở thành “boat people” mà ra đi. Như Phạm Đình Chương, Thái Thanh… chỉ ra đi sau khi bị tuyên một cái án “cấm sáng tác và trình diễn vĩnh viễn” tại VN, như Hoàng Trọng còn ở lại VN mãi đến tận năm 1992…

Lá đỏ - Thái Châu 
Cuộc đời vẫn đẹp sao - Họa Mi, Phương Đại 
Hà Nội niềm tin yêu hy vọng - Lệ Thu 
Lên ngàn - Họa Mi 
Bóng cây Knir - Họa Mi 

Thôi thì khoan hãy bàn về cảm xúc trong các bài hát. Riêng về phần hòa âm thì có thể thấy miền Nam đi trước miền Bắc (lúc bấy giờ) rất xa trong chuyện hòa âm nhạc nhẹ. Và riêng về kỹ thuật hát thì một mình giọng ca Họa Mi cũng đã hơn đứt tất cả những ca sĩ nhạc viện được đào tạo chuyên nghiệp của miền Bắc như Lê Dung, Măng Thị Hội… (hãy nghe bài Bóng cây Knir và so sánh). Tôi có cảm giác rằng dù sao với tiếng Việt, lối hát rõ âm rõ chữ, nặng về luyến láy, hơi rung… vẫn là một lối hát truyền tải được tình cảm và phù hợp với cái tai âm nhạc Việt. Sớm muộn gì rồi lối hát này cũng sẽ trở lại…

la chanson d’orphée

Le ciel a choisi mon pays, pour faire un nouveau Paradis.
Au loin des tourments, danse un éternel printemps pour les amants.
Chante chante mon cœur la chanson du matin dans la joie de la vie qui revient!

Gây rung cảm tâm hồn nhiều khi không cần đến âm nhạc tinh tế và phức tạp. Chỉ một giai điệu, một lời hát đơn giản nào đó cũng đủ để gợi lại cả một khung trời kỷ niệm, ước mơ xa xưa… Chẳng có gì phải xấu hổ khi kể rằng bạn đã từng yêu một giai điệu, một khoảnh khắc nào đó của quá khứ, để rồi mãi cho đến tận hôm nay mới biết bản nhạc đó tên gì, do ai hát!

Lời Anh - A day in life of a fool 
Lời Việt - Bài ngợi ca tình yêu 

Vì có hề gì khi mà giai điệu đó đã (vô hình) đến và ở lại mãi mãi trong tim… Và đó lại là giọng ca đầy ma thuật, khỏe khoắn và quyến rũ Dalida… và cũng như những dáng nhạc đẹp khác, bài hát đã được chuyển thể qua rất nhiều ngôn ngữ khác.

đờn ca nhạc… nhậu

Chẳng là dạo gần đây bị tra tấn bởi thể loại này hơi nhiều, cảm thấy cần phải… chính thức thừa nhận nó như là “một phần tất yếu của cuộc sống”… Một thể loại âm nhạc có sức sống cực kỳ mãnh liệt, phổ biến trong triệu triệu quần chúng thính giả, có thể được trình tấu thâu đêm suốt sáng bên chiếu nhậu mà không hề nhàm chán. Một dòng chảy âm thầm khơi nguồn từ hàng chục năm về trước, và vẫn còn được nồng nhiệt mến mộ cho đến tận ngày hôm nay.

Mặc cho bao đổi thay, thăng trầm của lịch sử, mặc cho những ai có cố tình không thừa nhận, vâng, tôi vẫn sống, vì tôi là một phần, dù cho ai đó có gọi là hèn kém, của dòng máu Việt! Người ta có thể gọi tôi là “nhạc vàng”, nhạc “ủy mị”, nhạc boléro kẹo kéo rẻ tiền, đờn ca nhạc nhậu .v.v. nhưng các bạn thấy không, bình dân đại chúng vẫn xếp chúng tôi sánh vai cũng những Phạm Duy, Văn Cao, Lê Thương, Phạm Đình Chương… Với các vị đó, người ta có thể cảm thấy xa cách, “kính nhi viễn chi”, chứ với tôi, người ta hát mọi lúc, mọi nơi, có thể buột miệng hát cho vui bất kỳ lúc nào người ta thích!

Người ta có thể phải vận dụng hết tất cả cảm quan, hiểu biết để cảm âm nhạc bác học, còn với tôi, người ta hát tự nhiên như những tiếng chửi rủa hàng ngày! Không dùng từ ngữ quanh co tránh né, chúng tôi thẳng thắn bảo rằng: tôi ca không hay, tôi đàn nghe cũng dở…, vì sự thật vốn dĩ… đúng chính xác là như thế! Đã có những thời kỳ “bách hoa tề phóng, bách gia tranh minh” (hay còn gọi là “vàng thau lẫn lộn”) giống loài chúng tôi luôn đứng đầu về lượng sáng tác cũng như lượng khán giả mến mộ! Có thể những tác giả viết lịch sử âm nhạc cố tình lãng quên chúng tôi, nhưng các bạn biết không, quần chúng luôn có được thứ âm nhạc và nhạc sĩ mà họ mong muốn!

Bên đây chỉ là một số ít, rất ít trong những người anh em chúng tôi. Nếu các bạn muốn, tôi có thể liệt kê danh mục các tác giả, tác phẩm đến sáng ngày mai cũng không hết! Bên cạnh số lượng, chúng tôi còn có sức hòa nhập, hòa tan cực kỳ lý tưởng, người ta hát chúng tôi trong mọi xó xỉnh từ thành thị đến thôn quê, người ta có thể hát chúng tôi chung với những người anh em (đã từng ở phía bên kia chiến tuyến) như 5 anh em trên một chiếc xe tăng, Tiểu đoàn 307 .v.v. một cách hoàn toàn tự nhiên và hảo hợp. Bởi suy cho cùng chúng tôi vẫn là anh em một nhà, như 5 ngón tay trên một bàn tay… Chừng nào văn hóa âm nhạc nước nhà vẫn “trăm hoa đua nở” (hay còn gọi là “vàng thau lẫn lộn”), chúng tôi đã, đang và vẫn sẽ là một phần tất yếu trong cuộc sống hàng ngày của các bạn!

typeface

All names on the Vietnam wall in Washington DC was carved in Optima, a font designed by the legendary Hermann Zapf. Optima style is well-balanced between ancience and modernity, it’s said that Zapf used golden ratio in designing it!

Since it began long time ago, my obsession for typefaces has never stopped. From typography to calligraphy, from Latin letters to Chinese brush characters, from hand-writing to web fonts… typefaces represent the most basic, most intrinsic but most important to a visual identity: it’s not the thing they see, it’s the thing they read! Typeface, it’s not about a style of writing or printing, it’s about the long traditions of hand writing, wood and metal letters printing continue into the digital age, it’s about aesthetics!

Nowadays, for typography, www is still the “lowest common denominator”, where just a handful of typefaces meet. It’s really hard to demonstrate the beauty of typefaces on the web. Previously I had a post on web embedded font, other solutions exist using Flash or JavaScript to render fonts on web pages. Up-to the present day, I’ve never felt pleased with the aesthetics quality of any Vietnamese font yet!

Take a look at our major (printed) newspapers (e.g: Tuoi Tre, Thanh Nien…) and even art & designing magazines, most of them sticks to the very basic (and ugly) Arial or Verdana, why don’t they consider using more elegant ones like Helvetica or Palatino? (these have Vietnamese Unicode support already) Yet, there are also many nice free font families to use: Gentium, Liberation, DejaVu, Linux Libertine, Droid, Bitstream Vera

Look at the prices of professional fonts sold on many type foundries, you would understand values of the work! A font designer is somewhat similar to a sword-maker, their names don’t appear on publishing, book, newspaper… but those products bear the tacit pride of centuries-old craftsmanship. Image below: the flowery Zapfino, named after Hermann Zapf, shipped with Mac OS X, now serving as test-bed for many font-rendering engines.

3d

We are building something like this, a 3D user interface. Day by day, we’re witnessing more and more diversities in computer user interface: concepts, designs, look and feel, animations, effects… While some would stick to an bare – bone, obscured text console, the others prefer some fancy, eye – candy GUI with all its bells & whistles. Things are much easier now with many 3D libraries and tools. Remind me about how I did all the 3D things: polygon, mesh, texture, sprite, shading, lighting, scene – graph, etc… with C & assembly on DOS!