Thoughts On Programming Paradigms

@alvinSJ

I have some question about the usage of php.

As I am more to a design guy, I prefer class oop design than function oriented design, however there are some design pattern you can implement without oop, but maybe is optimized. For example, drupal should be a good cms framework, but the use of class oop is not widely used in the framework.

Do you have any thought on this?What is the current practice used by your company in php project? oop or functional, or mixture or both? What’s the benefit in the perspective?

@hongster

IMHO, people develop software to solve problems. Your client has a problem,
and he/she express problems in terms feature specifications. You analyse the
problem, model the solution, and implement the solution model. OOP,
Imperative Programming, Functional Programming, and Logical programming are
just alternative ways of analyzing problems and modeling solutions. In
another words, different programming paradigms use different approach to
analyse problems and model solution.

I personally disagree when people said that certain paradigm is better that
others. I also don’t think that there is a direct relationship between
performance and programming paradigms. For example I am developing a chess
game and I need to implement the AI engine. Programming the AI engine using
Prolog and Scheme may result in a more efficient software than
C++/Java/Python. If I use Java, I have to construct the whole rule-based
reasoning engine, and then provide data structure to capture the game rules.
For Prolog, this two features is natively built into the
Prolog interpreter and optimized. Implementing AI engine using Prolog may
result in shorter development time.

I don’t think that Drupal/Wordpress/Linux is not OO because of legacy
reason. I think the community chose that. OOP started in 1960s, and has
already gone mainstream in the 1980s. If you are a good/experienced software
architect, you can design a good (i.e. maintainable, flexible) software
using imperative programming. We attend schools that tells us how OOP is
better than other paradigms, yet everyday we see bad “OO” design that is
worse than WP’s and Linux’s design.

In my company, we performed OO analysis (UML modeling). As for the
implemented code, it is far from what is considered OO design (from a OO
purist perspective). I think the software I wrote has elements from
different programming paradigms.

Posted in Blog at November 5th, 2010. No Comments.

Learning From Lunar Lander

Lunar Lander is a sample game distributed with the SDK in <SDKDIR>/platforms/android-2.1/sample/ folder. It is available since Android 1.5. This project introduces 2D drawing on Canvas, handling KeyEvent, and using Thread. I think it is a good starting point for me to learn Android game programming.

For Lunar Lander, the main components are main LunarLander (Activity), a LunarView (SurfaceView), and a LunarThread (Thread). The layout XML defines a LunarView (for displaying the game scene), and a TextView for displaying in-game message (i.e. “Press up to play”, “Press up to resume”).

The LunarView contains a innerclass, LunarThread. LunarThread is the game engine. It runs the game loop and performs all the drawings and physics (game logic). LunarView delegates all KeyEvents to LunarThread.

As I am developing a game, I have used the Lunar as a template. There are some slight modifications. Instead of inner class, I made the game engine a separate class on its own. I want to separate the View from game engine.

Posted in Tao Of Programming at March 23rd, 2010. No Comments.

[Android] API Demos

Just post another entry at http://gtugkl.blogspot.com/2009/09/android-api-demos.html.

Share a helpful tip for learning Androd programming. The SDK package comes with examples that cover a variety of topics.

Posted in Tao Of Programming at September 6th, 2009. No Comments.

WTF is PAAMAYIM NEKUDOTAYIM?

Hello world! While PHP-ing, “Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in …” appeared in my browser. This is not the first time I see it, definitely not the last. So what is “T_PAAMAYIM_NEKUDOTAYIM”?

Paamayim Nekudotayim is the name of the scope resolution operator (::) in Hebrew.

Ref:

Posted in Blog at May 7th, 2009. No Comments.