Monday, September 12, 2016

Programming made simple.

With the advent of DevOps, more and more people are finding the needs to do basic programming.  While the need to do programming for "non-programmers" is mounting, I see that a lots of people is looking at programming as a tall mountain and they are finding this hurdle difficult to overcome.

This blog post has the intent to try to make programming a easy task for "non-programmers". This post is for programming in general and is not any programming language specific.

All programming language can be simplified into 3 basic operations or ingredients.  These are the building blocks for all programming languages be it the simple "Hello World" or as complicated as artificial intelligent software.

The 3 basic building blocks are:
  1. Assignment
  2. "If-then-else" / conditional statemen
  3. Iterations

Assignment

Most computer program has to deal with data manipulation.  Often time a block of memory is reserved called a variable.  This variable should be named and also with a meaningful name to remind even the author of the program as to what the variable is for. Some programmers are lazy and name their variables x, y and/or foo instead of meaningful name such as return_code, username ... etc.  (As a side point, when developing a a software program, all the logics seem so obvious but then 3 months down the road in the middle of the night, we might be scratching our head asking, why did I write this logic).

Anyways, getting back to the topic, assignment is when we assign a value to a variable.  Depending on the programming language, some variable are very strict in the type of the variable.  If a variable is reserved/declared as integer, we can only assign a number value to this variable.  There are other programming language such as Python that the type is not checked by the interrupter/compiler.  Type checking is another big topic that we can look into and in this post we will just concentrate on the 3 building blocks of computer programming.

Example of variable assignment in go:

var string1 string
string1 = "Hello World!" 
fmt.Printf("I just wrote my first program: "%s", string1)

Depending on the context, the variable "string1" may not be a good name to use as it did not reveal how this variable is being used.

If-then-else or conditional statement

This is called the conditional statement and different programming language has different syntax to express the conditional statement but the concept is the same.  Depending of the condition (or the value of certain variables) the program will execute different sets of logic.


The format is:

if condition A {
 do something
} else {
 do some other thing
}

The "else" part is where condition A is not true.  Or we can be checking the condition in anther way:

if condition A is not true "
 do something
} else {
 do some other thing
}

For example:


if _, err := checkMonthIndexSize(i); err != nil {
fmt.Printf("\n%s\n", err)
} else {
fmt.Printf("\nSlice is initialized correctly (len = %d)\n", i)
}

The above logic is written in go and it is only for demonstrating purpose.  This is a more complex construct of the if-then-else logic where we we execute a function and depending on the return value or error condition of the function to decide if we should print out an error message or a informational message.


The if statement is checking for the return value of the function checkMonthIndexSize().  I have not include the function as I am only trying to illustrate the "if-then-else". The function checkMonthIndexSize() returns a value where we choose to ignore and the build in error checking feature of the go language.

In fact this is taken from the demo program that I have written for one of the episodes in "30-days-in-committmas 2015".  If you are interested you can find the podcast here in YouTube

Iterations

Programming usually involve in doing the same operation multiple times or depending on the value of a variable.

Most programming languages have the "for-loop" and the "while-loop".

Example of a for-loop:

for i := 6; i < 12; i++ {
fmt.Printf(" [%d] := %s\r\n", i, string1[i])
}

Usually a "for-loop" will do 3 things:
Assign a value to a variable and this case i := 6
check certain condition and in this case if ( value of the valuable is less than 12)
increment the value of i by one and in this case i++ or it can also be i = i + 1)

Example of a while-loop


while ( condition is true) {
 print a "dot" on the screen
}

This is good for user interface.  Let say we are doing a file transfer using ftp and we can see the progress by seeing dots being printed to the screen and we know the file transfer is still happening.  (Over simplified example for file transfer logic for illustration only).

So we can see this value assignment and condition checking is being used in the for-loop or while-loop.

Happy programming

Of course there are more to programming but this post is trying to help you get over the barrier and start programming.  You can see there 3 basic elements in very complex programs.

Of course there are data structure and object oriented approach plus other features to programming for the complex programs but we can use these 3 basic building blocks to start.  We got to start somewhere.

So: Happy ProgrammingImage result for Happy face



39 comments:

  1. Superb i really enjoyed very much with this article here. Really its a amazing article i had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent
    article.thank you for sharing such a great blog with us. expecting for your updation.
    Digital Marketing Company in Chennai

    ReplyDelete
  2. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    Manpower Consultancy in Chennai

    ReplyDelete
  3. Are you looking for free Google+ Circles?
    Did you know you can get them AUTOMATICALLY & ABSOLUTELY FOR FREE by registering on Like 4 Like?

    ReplyDelete
  4. Good blog, thanks for sharing this useful information.
    Click More Details Visit Our Website

    Texus
    Texus Systems

    ReplyDelete
  5. Thank you for sharing this informative article. I hope this will help the App Developers in Kenya to make programming simple.

    ReplyDelete
  6. Informative Blog. Thank you for sharing
    aws training in chennai

    ReplyDelete
  7. This is just the kind of information that I had been looking for a long time. Thank you very much for posting this blog its very nice.Please contact us for Oracle Fusion Cloud Financials Training details in our Erptree Training Institute

    ReplyDelete

  8. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.

    python Training in Bangalore | python Training in Bangalore

    ReplyDelete
  9. A bewildering web journal I visit this blog, it's unfathomably heavenly. Oddly, in this present blog's substance made purpose of actuality and reasonable. The substance of data is informative
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  10. A bewildering web journal I visit this blog, it's unfathomably heavenly. Oddly, in this present blog's substance made purpose of actuality and reasonable. The substance of data is informative
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  11. A befuddling web diary I visit this blog, it's incredibly grand. Strangely, in this present blog's substance made motivation behind fact and sensible. The substance of information is instructive
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  12. Thank you for sharing your thoughts and knowledge on this topic. This is really helpful and informative, as this gave me more insight to create more ideas and solutions for my plan. I would love to see more updates from you.

    Wordpress Health Checkup

    ReplyDelete
  13. Thanks for sharing
    We are the best piping design course in Hyderabad, India. Sanjary academy Offers Piping Design Course and Best Piping Design Training Institute in Hyderabad. Piping Design Institute in India Piping Design Engineering.
    Piping Design Course
    Piping Design Course in india
    Piping Design Course in hyderabad

    ReplyDelete
  14. Nice Post
    Sanjary kids is the best playschool, preschool in Hyderabad, India. Start your play school,preschool in Hyderabad with sanjary kids. Sanjary kids provides programs like Play group,Nursery,Junior KG,Serior KG,and Teacher Training Program.
    play school in hyderabad
    Preschool in hyderabad
    Preschool teacher training course in hyderabad
    pre and primary teacher training course in hyderabad

    ReplyDelete
  15. Do you understand there's a 12 word phrase you can say to your partner... that will induce deep emotions of love and impulsive appeal to you buried inside his heart?

    That's because deep inside these 12 words is a "secret signal" that triggers a man's instinct to love, adore and care for you with his entire heart...

    12 Words That Trigger A Man's Love Instinct

    This instinct is so hardwired into a man's brain that it will make him try harder than ever before to take care of you.

    As a matter of fact, triggering this dominant instinct is so mandatory to getting the best ever relationship with your man that the instance you send your man a "Secret Signal"...

    ...You'll immediately find him expose his heart and mind for you in a way he's never expressed before and he will identify you as the one and only woman in the galaxy who has ever truly appealed to him.

    ReplyDelete
  16. I have been searching for a useful post like this on salesforce course details, it is highly helpful for me and I have a great experience with this Salesforce Training who are providing certification and job assistance. Salesforce CRM certification in Gurgaon

    ReplyDelete
  17. I have been searching for a useful post like this on salesforce course details, it is highly helpful for me and I have a great experience with this Salesforce Training who are providing certification and job assistance. Salesforce training Gurgaon

    ReplyDelete
  18. What a fantastic post! This is so chock full of useful information I can't wait to dig deep and start utilizing the resources you have given me. your exuberance is refreshing

    you've outdone yourself this time

    This is probably the best, most concise step-by-step guide I've ever seen on how to build a successful blog. i am also writing blog about the  kindly review it french language institute in delhi .

    ReplyDelete
  19. Useful posts, I really appreciate your writing skills and your hard work. You are providing such deep information, that's why I would love to see more blogs about this subject. I am inspired by you and I am also writing about the Canada work visa . Please review it.

    ReplyDelete
  20. I really like the blog and I hope people will have a new blog, thanks for the blog
    wordpress
    blogspot
    youtube
    កាស៊ីណូអនឡាញ

    ReplyDelete
  21. I like viewing this web page which comprehend the price of delivering the excellent useful resource free of charge and truly adored reading your posting. Thank you!
    Data Science Certification Course

    ReplyDelete
  22. I would like to say that this blog really convinced me to do it and thanks for informative post and bookmarked to check out new things of your post…
    Data Science Institute in Noida

    ReplyDelete
  23. Just a shine from you here and have never expected anything less from you and have not disappointed me at all which i guess you will continue the quality work. Great post.
    Data Science Training in Gurgaon

    ReplyDelete
  24. I just got to this amazing site not long ago was actually captured with the piece of resources you have got here and big thumbs up for making such wonderful blog page!
    Data Scientist Course

    ReplyDelete
  25. The blog and data is excellent and informative as well your work is very good and I appreciate well hopping for some more informative posts.
    Business Analytics Course in Gurgaon

    ReplyDelete
  26. Having read your article. I appreciate you are taking the time and the effort for putting this useful information together.

    ReplyDelete