Spencer Hire
Spencer Hire

Reputation: 763

Programming constructs

A wise man told me that to learn how a syntax works does not mean your a good programmer, but rather to grasp programming constructs like iterators and conditionals, thus, meaning you can pick up any syntax easier. How would one go about learning these constructs??

Upvotes: 1

Views: 313

Answers (2)

ose
ose

Reputation: 4075

The easiest construct you mention is a conditional. The basic pattern of a conditional is:

if <some-condition> then
    <do-action>
else
    <do-other-action>
end if

This basic pattern is expressed in many different ways according to the language of choice, but is the basic decision-making building block of any program.

An iterator is a construct which abstracts the physical layout of a data structure, allowing you to iterate (pass through) it without worrying about where in memory each element in the data structure is.

So, for example, you can define a data structure such as any of Array, Vector, Deque, Linked List, etc.

When you go to iterate, or pass through the data structure one element at a time, the iterator presents you with an interface in which each element in the data structure follows sequentially, allowing you to loop through with a basic for loop structure:

for <element> in <data-structure>
    <do-action>
end loop

As for other constructs, take a look at some books on Data Structures and Algorithms (usually a 2nd-year level computer science course).

Upvotes: 2

giorashc
giorashc

Reputation: 13713

Syntax is only a technical form of expressing your solution. The way you implement and the concepts you use in your solution are the ones who makes the different between a beginner and an experienced developer. Programming languages are the means not the wits !

Upvotes: 0

Related Questions