Life, the Internet, and Everything!

Good Programmer, Bad Programmer

Good Programmer, Bad Programmer

“My mind is clearer now. At last, all too well. I can see where we all soon will be”. – Judas in “Heaven on Their Minds” at the beginning of the rock opera “Jesus Christ Superstar”.

“My mind is in darkness now…” – Judas toward the end of the musical, after the betrayal for the 30 pieces of silver, and just before his suicide.

I’ve been working on a programming project – one I really should have done by now – and I’ve been feeling both of those emotions quite a bit lately. The project, for an unmentioned client, has been a mish-mash of decent to excellent programming styles, mixed with some of the worst I’ve seen for quite sometime.

This is pretty AS400/IBMi RPG specific, but here goes….

One of the key goals for the progression from “regular” RPG to RPGIV and eventually free format ILE RPG is the reduction in the reliance on indicators. Indicators are built in logical values, or flags, that were added to the original RPG programming language to aid with formatting reports and eventually (green screen) displays.

Coding

As the language grew, indicators were also relied upon for inline logic structures – you could check a variable’s value, set on an indicator, and then do something later in the program based on whether that indicator was on or off. The biggest problem with this approach was the resulting “spaghetti code” with all these scattered indicators controlling the execution of statements wildly and randomly in a program.

Over time, more logic constructs were added to the language so that indicators could be relied on less. By the time free format RPG made its debut, most programmers pretty much eliminated their use of indicators for logical decisions. They are still there, but their use has pretty much returned to formatting reports and screens.

SEE ALSO  How Often Does Thanksgiving Fall on November 22?

However, bad programming style is still bad programming style. Replacing indicators with poorly named variables is not much of an improvement. When your favorite programming guru says “avoid using indicators” the real message may actually be something more like “make your program more readable”.

Example:

If *in86
... some code ...
Endif

Is really not much different than

If wact = ‘Y’
... some code ...
Endif

You may know what “wact” is, but nobody else will without doing a search or using a split screen to keep definitions handy. Why not do something like

If cust_acct_status = “good”
... some code …
Endif

Old rule: “It was hard to write, so it ought to be hard to read”.

New rule: “Write programs so someone else can read them rather than just you. “

Click here for more information about 'Good Programmer, Bad Programmer'.

Tags: , , , , , , ,
Previous Post
Miscellany

How to Read the News

Next Post
Miscellany

Drowning in a Sea of Technology

Comments

    • Saranya sekhar
    • March 29, 2014
    Reply

    What Is The Best Programming Language To Learn And To Work In IT Industry? I wish to work in IT industry so please suggest me one of the best programming language to learn

    View Comment
    1. Reply

      Usually it all depends on what you are going to be coding. there is a quite steep dichotomy between programming languages. There adv/disv are as follows:
      C++
      advantages: its the best of all, it gives you the flexibility you need to write very sophisticated programs. hardcore programs like windows XP, adobe photoshop, even google’s Robot were all developed with c++(like i heard).
      though you can’t directly program the web with c++, most scripting languages embracing a sp/vbscript can all benefit from c++’s high supremacy, you can write programs in c++, and attach them to your webpages using asp/vbscript, most web viruses were all written with c++(not sure,not a web-virus programmer) .
      learn C++ and you will master every other language in one/two months(or even just weeks). they all inherited their styles from C/C++(c++ inherited its own style from c except for the class part).OOP language.

      Disadvantages: be ready and prepared to persevere a lot, it’s very hard to understand the concepts. its a “no-joking-around” langauge.

      Java
      Advantages: portable, very powerful language for developing secure, fast,sophisticated web applications. Most top businesses use it due to its high secured nature. used for programming most web games.OOP language.

      disadvantages: you sure can use it for writing applications but what is “do-able” is limited,its just not suitable for software programming. You must conform to its unique writing style or be sure to fight with a nagging compiler.

      C#
      Advantages: microsoft’s new multi-purpose language for both creating fast,secure software programs and professional web applications. A definite alternative to “not-wanting-to” learn c++,plus you can directly write web applications with it.

      C
      Advantages: though other languages existed before c, i would say this happens to be where all the real hard core hyper-dimensional software programming started(though basic,assenbly language,etc existed before c). suitable mostly for interacting with external hardware/handheld devices, and memory-conscious programs.NOT OOP at all.

      disadvantages: hard to debug. not object oriented at all. just learn c++ okay!!! lol.

      VISUAL BASIC
      Advantages: its as easy as microsoft word. easy to learn, friendly compiler, no strict programming stlye,you would write your first windows program in two minutes(actually you won’t be writing it yourself,hehe). if you are lazy, too curious to start writing programs, then be sure to go the easy-basic way. its somewhat powerful, after all whatever you can do with c++, you could do with visual basic as well(most things but not everything).

      disadvantages: when it comes to writing matured programs like Photoshop,etc, you would only be joking around if you use visual basic. it might be possible to use it for that purpose, but trust me, its probably going to be double the size of your hard disk,lol. don’t get me wrong though, visual basic’s reserves and power are unquestionable,okay!

      Fortran,cobol,pascal
      advantages: can still be used for writing memory-efficient applications. really good for beginners and easy to learn.

      disadvantages: Don’t even go there at all, if you really want to get a job, then just disable google search for any of them. only learn if you are looking to impress your girl-friend with a short easy-to-write “hello world” dos program.

      little advise, if you start learning c++, add extra week for mastering Stuff about Arrays(especially multi-dimensional), Pointers,inheritance classes/objects.they might appear easy, but they happen to be the blue-print of c++’s power.

      little program:
      in C++
      save as cpluplus.cpp using notepad
      #Include
      int main(){
      char choice;
      char go_cplusplus = “Welcome to the party”;
      cin>>choice:”enter your choice of language”;
      if(choice==”c++” or “cplusplus”)
      cout<

      View Comment
    • Candy
    • May 29, 2014
    Reply

    Saving And E Mailing My VB 6.0 Programming Project? My project is saved and working well form my computer but I cannot seem to save it properly on any removable storage device.

    Even when I sane a copy on my desk top( or any other location) it does not open and says some thing about the form location….

    help because I need to make a back up copy of the project and I also need to zip the file(i don’t know how to do this!!) to forward if via email to my tutor.

    View Comment
    1. Reply

      Make a folder for the project. Light up vb and the project. Go over to the forms tree and right click and “save-as” each form and module into the folder you made. Finally, go to “Save Project As…” and save your project in that same folder. Then zip it up if you want. That will package the vb project. If you want it to be executable, you need to use the setup kit provided with vb.

      Download Winzip to make your zip file.

      View Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: