What is this?
Let’s
assume that you have no programming experience at all, but have used computers
(by now, that’s just about everyone).
So, why do you want to learn about programming? Are you being forced to because of a class
you’re enrolled in, are you having problems communicating with a geek, are you
looking to impress a friend, or do just want to try something completely
different? Whatever your reason, we’ll
start off with a basic explanation of computer programming and discuss some of
the ways that programs are used.
You can find multiple definitions for the word program, the one we’ll use here is this
A program is a planned
sequence of events or structured activities.
Now
that we know what computer programming is, the next question is, why do it? Well I’m not going to get into an explanation
of computers and what they’re good for, but let’s just say that a computer is a
machine that can be used to carry out instructions that perform computations,
control a device, process information, etc. – the list is only limited by our
imaginations. Simply know this boys and
girls, computers and computer programs
make the world a better place! So, this is how it goes – you write a computer program that has the instructions you
want performed, load the program on a computer, tell the computer to execute
the program, and that’s pretty much it.
Sounds pretty simple, eh? It
really is that simple, at least conceptually.
Let’s say that you want to write a program to display on your computer
screen a welcome message and the current time, like this
Hello, World!
The current time is 2012-12-21 12:00:00 PST
You know what you want the computer to do, so you just put those instructions in the program and that's it, right? But wait a minute, how do you write it so that the computer will do what you want it to do? I mean, how do you write a
program so that the computer will understand and carry out your instructions? This is where computer-programming languages become important.
Programming Languages: An Overview
Programming
languages have been around for a long time.
Some of the earliest were used for things like player pianos and textile
machines (specifically, piano roles are programs for player pianos). A computer programming language is used to
create inst ructions for the activities you want a computer to perform. So if a programming language was based on a natural language (say English), the
simple program we mentioned above might have the following instructions:
- Display the message
“Hello, World!”
- Display the current date
and time.
If
a computer could execute these instructions “as-is”
– in other words it understood English – you could just create a new file, type
in these instructions, and tell the computer to process the file (i.e. execute the program). On your monitor you would then see the
welcome message followed by the current date and time! Unfortunately, computer programs (at least the
vast majority in use today and the ones we’ll discuss here) are not written in
natural languages; they are written in artificial
programming languages. This is because
computers don’t understand English, they understand the language of computers,
which is to say they live in the land of bits, bytes, registers, instruction
sets, and numerous other things incomprehensible to people who don’t inhabit
the world of Geek! So, in order to write
a computer program you have to learn a new language!
Programming for Everyone is designed to give the reader an introduction to computer programming. The book is
written for a very general audience and focuses on providing you
with a detailed understanding of the basic concepts. It's also
great for programmers who want to learn about other programming
areas (e.g. logic programming, computer graphics, games, etc.) they
may not have experience in. Whatever your age or background, Programming for Everyone will help you to understand computer programming!
Showing posts with label objective-c. Show all posts
Showing posts with label objective-c. Show all posts
Monday, December 24, 2012
Sunday, December 23, 2012
Why Object-Oriented Programming?
OOPs!
Object-oriented programming (OOP) is a style of computer programming that emphasizes the creation and use of software objects to write programs. You can think of a software object as a model, in software, of a thing or concept. A software object provides a representation (in software) of the characteristics or attributes of the thing/concept being modeled along with a definition of the things it can do. The attributes (aka its properties) that define an object are typically things the object has or is; for example if you were modeling a person the set of attributes would include height and weight. The things an object can do (aka its behaviors), are generally the actions that it can perform (for a person object this could be things like run, jump, speak, etc.). Now before we go any further let’s try to clarify this with an example; we are going to develop an object-oriented model of an atom (e.g., hydrogen, oxygen, etc.).
Now a very simplified model of an atom might include the following properties:
OK, now we have a software model for an atom, so what’s next? Well, you get a software object to perform an operation (i.e. a behavior) by sending a message to it with the operation you want performed. For example, if you send the message Get Element to an atom object it will determine the chemical element name for the atom and return that information as text (e.g., it might return the text “Hydrogen” or “Helium”). Object-oriented software design is all about creating software objects of this sort and using them to build software applications. Programmers create networks of interacting objects to implement all sorts of applications.
Now there are literally thousands of programming languages, and an OOP language is just one of many options for writing programs. So why build this software using objects, why not use another approach? Well, compared to other programming styles, OOP has a variety of benefits and here are just a few of them:
In summary, OOP is one of the most common programming paradigms in use today and is supported by many programming languages. If you want to learn more about OOP there are plenty of books and online resources available. So what are you waiting for, dive in and start programming using OOP!
Programming for Everyone is designed to give the reader an introduction to computer programming. The book is written for a very general audience and focuses on providing you with a detailed understanding of the basic concepts. It's also great for programmers who want to learn about other programming areas (e.g. logic programming, computer graphics, games, etc.) they may not have experience in. Whatever your age or background, Programming for Everyone will help you to understand computer programming!
Object-oriented programming (OOP) is a style of computer programming that emphasizes the creation and use of software objects to write programs. You can think of a software object as a model, in software, of a thing or concept. A software object provides a representation (in software) of the characteristics or attributes of the thing/concept being modeled along with a definition of the things it can do. The attributes (aka its properties) that define an object are typically things the object has or is; for example if you were modeling a person the set of attributes would include height and weight. The things an object can do (aka its behaviors), are generally the actions that it can perform (for a person object this could be things like run, jump, speak, etc.). Now before we go any further let’s try to clarify this with an example; we are going to develop an object-oriented model of an atom (e.g., hydrogen, oxygen, etc.).
Now a very simplified model of an atom might include the following properties:
- Protons (number of protons of the atom)
- Neutrons (number of neutrons of the atom)
- Electrons (number of electrons of the atom)
- Get Element (determine the chemical element name [e.g. hydrogen, helium, etc.] of the atom).
- Get Mass (determine the atomic mass of the atom).
- Illustrate (display a diagram of the atom).
- Perform Fission (split the nucleus – very dangerous, perform at your own risk!!).
- Create (create an Atom object with the desired number of protons, neutrons, and electrons).
![]() |
| Atom Object |
OK, now we have a software model for an atom, so what’s next? Well, you get a software object to perform an operation (i.e. a behavior) by sending a message to it with the operation you want performed. For example, if you send the message Get Element to an atom object it will determine the chemical element name for the atom and return that information as text (e.g., it might return the text “Hydrogen” or “Helium”). Object-oriented software design is all about creating software objects of this sort and using them to build software applications. Programmers create networks of interacting objects to implement all sorts of applications.
Now there are literally thousands of programming languages, and an OOP language is just one of many options for writing programs. So why build this software using objects, why not use another approach? Well, compared to other programming styles, OOP has a variety of benefits and here are just a few of them:
- OOP is a natural tool for modeling things in software, whether they are real-world entities, abstract concepts, and/or processes. This can reduce complexity and make the program structure more clear.
- Because you can create software objects that completely define the properties (i.e. states) and behavior of a thing being modeled, they can be reused in a variety of ways. You can use them to build things that are related and descend from a common parent (in OOP this technique is called inheritance), or things that are built up from other objects (this technique is called composition).
- It's easy to make internal changes to an object, as it is self-contained. When an object is designed properly, changes to its implementation do not affect any other part of a program, since the interface that the external world has to the object is specified by its operations (i.e. methods).
- Object-oriented software is extensible, meaning that making updates or adding new features doesn’t require a complete rewrite of a program. Often, you can update object-oriented software by introducing a few new objects and/or modifying some existing ones.
- As well-defined objects are self-contained and used through a published interface, they can be maintained separately. This makes maintaining programs easier, along with locating and fixing problems. For large programs this feature is especially important.
In summary, OOP is one of the most common programming paradigms in use today and is supported by many programming languages. If you want to learn more about OOP there are plenty of books and online resources available. So what are you waiting for, dive in and start programming using OOP!
Programming for Everyone is designed to give the reader an introduction to computer programming. The book is written for a very general audience and focuses on providing you with a detailed understanding of the basic concepts. It's also great for programmers who want to learn about other programming areas (e.g. logic programming, computer graphics, games, etc.) they may not have experience in. Whatever your age or background, Programming for Everyone will help you to understand computer programming!
Saturday, December 22, 2012
What Programming Style(s) Do You Use?
So, what programming style(s) do you use?
A programming style (aka, paradigm) can be considered the approach (i.e. the techniques and styles) used to write a program. Its key characteristics include the concepts and abstractions used to represent the basic elements of a program (such as its variables, methods, objects, etc.), and the steps that make up a computation (assignment, evaluation, continuations, data flows, etc.). Several common programming paradigms are:
For example, what type of language would be a good choice for creating an electronic library card catalog? Since a card catalog provides information on a book such as its name, description, location in the library, etc. (in other words descriptive information), then a language that supports declarative programming would be a good choice. If you need to create a program that solves a given set of linear equations for a set of inputs (i.e., mathematical functions), then a language that supports functional programming would be appropriate. On the other hand, if you need to create a program that will be used to perform inventory management for a library (place orders, support different types of inventory items [e.g. books, electronic media], track shipping, etc.) then an OOP language might be appropriate.
In summary, consider choosing your programming language based on the programming paradigm(s) it supports.
Programming for Everyone is designed to give the reader an introduction to computer programming. The book is written for a very general audience and focuses on providing you with a detailed understanding of the basic concepts. It's also great for programmers who want to learn about other programming areas (e.g. logic programming, computer graphics, games, etc.) they may not have experience in. Whatever your age or background, Programming for Everyone will help you to understand computer programming!
A programming style (aka, paradigm) can be considered the approach (i.e. the techniques and styles) used to write a program. Its key characteristics include the concepts and abstractions used to represent the basic elements of a program (such as its variables, methods, objects, etc.), and the steps that make up a computation (assignment, evaluation, continuations, data flows, etc.). Several common programming paradigms are:
- Declarative programming focuses on describing what something is by identifying its attributes and characteristics, defining its mathematical relations, specifying its rules, etc. A programming expression written with a declarative programming language is referentially transparent; this means that it always produces the same result for a given set of inputs and doesn’t modify the state of another part of the program.
- Functional programming is a type of declarative programming that emphasizes the creation of computer programs as referentially transparent mathematical functions.
- Imperative programming defines solutions through sequences of commands for a computer to perform. In contrast to functional programming, imperative programming defines a program in terms of its state (i.e. memory). In addition, unlike declarative programming it can modify state.
- Structured programming aims to improve the clarity, quality, and development time of a program by making extensive use of program flow structures. OOP is a style of structured programming that combines data with the operations you can perform on that data.
For example, what type of language would be a good choice for creating an electronic library card catalog? Since a card catalog provides information on a book such as its name, description, location in the library, etc. (in other words descriptive information), then a language that supports declarative programming would be a good choice. If you need to create a program that solves a given set of linear equations for a set of inputs (i.e., mathematical functions), then a language that supports functional programming would be appropriate. On the other hand, if you need to create a program that will be used to perform inventory management for a library (place orders, support different types of inventory items [e.g. books, electronic media], track shipping, etc.) then an OOP language might be appropriate.
In summary, consider choosing your programming language based on the programming paradigm(s) it supports.
Programming for Everyone is designed to give the reader an introduction to computer programming. The book is written for a very general audience and focuses on providing you with a detailed understanding of the basic concepts. It's also great for programmers who want to learn about other programming areas (e.g. logic programming, computer graphics, games, etc.) they may not have experience in. Whatever your age or background, Programming for Everyone will help you to understand computer programming!
Subscribe to:
Posts (Atom)
