Programming: The Parts

"Crap, what the heck is this...."

This line is what I'm experiencing all the time with many of my associates. Truly, I cannot see what the heck they up to with their programs. If a program is a painting, then those are like playgroups pastel drawing!

There are couple of important things they've forget. Those are rules of thumb:
  1. Comments.
  2. Modulatization.
  3. Layers.
  4. Coupling: Craps don't fit in!
We must understand that a program is a flow of doing something. Let me tell you the history.

Take a look of these piece of primitive codes:

mov ax, bx
st
nop

At the above, we said that copy ax to bx, and then store and then stop. You see, even primitive codes have their own story.

And then, at the more advance, we have a wonderful group of codes that can be called many times. They are called subprograms, methods, procedures, etc. It was intended to create new philosophy called: RE-USE. Now, don't be like modern Christians that know what love is but not live with it.

RE-USE is a beautiful phrase of one for a job. Think of this, specialized part of program to handle something. Specialized means they are good at it, no need to do it in others. It means, doctors are there to cure someone, pilots are drivers of airplanes, banci salons are there to distribute gossips. Doctors don't fly a plane, banci salons don't cure illness, and pilots not there to distribute gossips among us.

This terms lead us to the term of modularization. Now, don't be frightened by the word. It just an advance philosophy of programming. It means, everyone in this world have their own functions. That's why God creates us distinctly. Each of us has our own part. No need to be shame of what you are! God has a plan for you!

If every one become apostles, where are the disciples? If everyone are priests/priestess, who would be the missionary? Who would be a whitness of God's love?

Every subprograms (call them methods or procedures, whatever) has its function. So, we don't need to ask a commedian to join our cause to wage a war (I can imagine the Three Stooges goes to war, but Charlie Chaplin do the salutation?). Distinct each subprogram so that we can use them with efficient manner.

Next, can you imagine, would you willing to eat in a restaurant where the cashier is sweeping the floor and the chef is wash someone's puke from the floor and then the chef go to the kitchen and cook something for you while you pay money to the cashier. After that, the cashier bring you your fave meals. Uhm, yammy, it's great! Not!

Even if they have washed their hands, we still felt disguisting of their doing in our memory. That's why in a restaurant (a good one, sanitized one) have front office, kitchen, and steward in different position. That's the same with programming. We differentiate each part of a program to do specific things.

Think of this way, can you eat a beaf stick after you saw the chef butchered the cow. See how it is cretinized in instance in front of your eyes? That's why elite restaurants doesn't show their kitchen in public!

That's why, they separate model and view! Leave the bitchy stuff in some parts, let the other parts become a public relation (or you could call them interface).

Good programs do such thing! They differentiate the levels. They called them layers. They called them API (Application Programming Interface, not Java's API) a.k.a. library.

Think of organization of society: Low paid labor do the hardwork, man at the office do their business and then politicians gave their speech to said that this nation is growing up. The more level of a part in hierarchy, the more it become intelligence and simple. This is called wrapper. A WRAPPER is a subprogram that binds several subprograms in previous level to do specific things. This philosophy called ENCAPSULATION.

Ah, shoot! I'm beginning to be bored here! Argh..! One more to go!

Do you feel empty? "Bengawan Solo" rings a bell to you? How many people ended their life by suicide! How many people lost they will to fight after their SO (Significant Other, if some geek read this one). How many people singing Skeeter Davis' song? Or a crappy band: Peter Pan's?

This called coupling. How many subprograms/programs may failed, or instantly doing weird stuff after we change a line of code in a subprograms? How many nights we've spend wondering around why our programs start to print Segmentation Fault? How many nights we are whinning after seeking answer to the fallen programs?

Good programs don't terminate themselves after a serious error. Good handler is needed! Each programs must not dependant too. OK, this is not what coupling about. Forget about this paragraph.

Crap! I'm bored now! See further what coupling is in om Google.

Ok, let me explain a little bit. When your lover start to bitching you, your heart start to empty. That's why, some people like Pope (and pastors) and Sidharta (and monks) stops to entrust their heart to a person but God alone. So that their heart can be full of peacefull things. Although their hearts still carring for other person, but they are independent. They are gracefully living alone like Lone Ranger and singing Godsmack's song.

Let me summarized this:
  1. Comments let your program be traceable and identified.
  2. Programs are best being modularize so that we can maintain them. We can quarantine bugs and examine flaws in our design.
  3. Lower layer do the dirty works, the above layer arrange them beautifully. Like Web Service encapsulate TCP/IP, UDP/IP creation. Or, like System.out.println() encapsulates the converting object into string section and printing section.
  4. The degree of a part of a program (or a program) dependent to other (part) programs is called coupling. Good designed program try to lower coupling.

Comments

  1. Anonymous8:05 AM

    good programmer know how to write codes. great programmer know how to reuse codes :D

    btw, does lone ranger live alone?

    ReplyDelete
  2. #tino:

    Sourceforge? :D

    Yup, with his horse and his silver gun.

    ReplyDelete
  3. - admit it, pilots also bring gossips :P
    - never got segmentation faults, guessing why though... wekekek :P

    ReplyDelete

Post a Comment

Popular Posts