Programming Fundamentals

1 - I can do better 2 - Jury's out 3 - Pretty darn good 4 - Splendiferous 5 - Awesometastic by 2 people | Log in to rate

Ranked #16,182 in How-To, #170,242 overall

Fundamentals of Computer Programming

I've been writing programs for computers since I was 13 when my Dad bought a Sinclair ZX80. Of course in those days I didn't really know what I was doing, I just wrote programs by trial and error with the help of the instruction manual. Later when I went to college I learned the fundamentals of structured computer programming using Pascal, but what I learned I've applied to several other computer languages including Java. I've often noticed that many people find themselves trying to write programs without really knowing the basics so I'm writing this lens as a basic primer as to how to write programs. I've been writing software professionally since 1988 so I hope I know what I'm talking about!

The 3 main processes of any computer program are Sequence, Selection and Iteration. I will describe these in full with the help of pseudo code examples. Pseudo code is a high level description of the program design which doesn't rely on any specific syntax and is intended to provide a logical overview without technical details. I will also provide some useful hints and tips which should help in the real world, particularly in the commercial environment.

Sequence 

Sequence concerns the order in which code is processed. Of course at the most basic level, code is processed sequentially, in other words it is processed line by line top down from beginning to end. For example a pseudo code version of a simple Hello World program might look something like this -

Begin program
Print "Hello World"
End program

Another version, which would work just as well as the one above, is this -

Begin Program
Call Subroutine PrintMessage
End Program

Subroutine PrintMessage
Print "Hello World"
End Subroutine

In this program there are two sections, a main body and something called a subroutine. In the main body, which in this pseudo code appears before the subroutine, the first and last lines are the same as in the first example and simply begin and end the program. The middle line of the main program calls the subroutine, a term which commonly refers to one or more lines of code which are grouped together in a program using a unique name, so in this example the subroutine is called PrintMessage.

Programming books on Amazon 

I've bought Head First Java and Head First Design Patterns from the Head First series of books and found them to be excellent!

Head First Design Patterns

Amazon Price: $29.67 (as of 12/27/2009) Buy Now

Head First HTML with CSS & XHTML

Amazon Price: $26.39 (as of 12/27/2009) Buy Now

Head First Java, 2nd Edition

Amazon Price: $29.67 (as of 12/27/2009) Buy Now

Head First Programming: A Learner's Guide to Programming Using the Python Language

Amazon Price: $31.49 (as of 12/27/2009) Buy Now

Head First Data Analysis: A Learner's Guide to Big Numbers, Statistics, and Good Decisions

Amazon Price: $31.50 (as of 12/27/2009) Buy Now

Selection 

under construction!

Iteration 

under construction!

Hints and tips 

Write your programs so other people can understand them

In 18 years the only programs I've encountered which have never had to be modified are the smallest data update programs. Everything else has either has bug fixes or modifications applied. In other words, anything more than a small one-off program will be changed, and almost certainly by more than one person which means some poor sucker has change your code.

What this means is that in almost every case it is better to design a program so that it is clear and readable for easy modification by other developers than to sacrifice clarity and maintainability in order to optimise performance. Most of the time spent developing a program is done not at the initial development but in modification.

Unfortunately anyone who works as a professional developer sooner or later encounters code written by a show-off. Technically this person is usually very capable and their programs work well, but they may employ seldom-used commands or maybe they just apply their own brand of "logic" to create a solution. Sometimes it's done to optimise performance, other times it just because they've read about something new and they want to use it. It wouldn't be so bad if they used comments to explain what they were doing, but that would be too easy wouldn't it? Best of all, more often than not by the time you get to update the code the author has long since disappeared to pastures new.

So remember, someone else is going to have to update or fix your code so make sure they're going to be able to understand it. Put in plenty of comments, especially around the more complex areas of code.

Your feedback is appreciated! 

submit
  • Reply
    Astrieanna Astrieanna Jun 4, 2009 @ 3:39 pm
    I'd like to see the rest of this lens finished =)

    I don't quite agree with your "Hints and Tips" -- programs should be written to perform at their best (since they'll be run more often than they are written). While you should include comments and well-named variables, good performance doesn't need to be sacrificed for simplicity.

    I don't think of the fundamentals the way you've divided them, which makes your lens that much more interesting to me. =)
  • Reply
    Frank Frank Jan 22, 2009 @ 12:35 pm
    man... sit down tonight and write more i'll Apreciate it
  • Reply
    fefe fefe Jan 23, 2008 @ 12:37 am
    Looking forward to seeing the rest of your lens. Noticed you have some Head First Books listed, they are awesome. I am reading the Head First Javascript book now.
  • Reply
    ChrisGray ChrisGray Jan 17, 2008 @ 10:16 am
    This is really useful stuff for anyone starting out.

by crist

I'm 41 years old and live in West Yorkshire with my wife Nicky, daughter Zoe, son Daniel and dog Nefyn.  I've been a software developer for 18 ye...

(more)

Explore related pages

Create a Lens!