Programming Methods 1
A programming language is a language in which computer programs are developed or written and before one can use this language he or she should understand and have knowledge of the basic principles of programming
Objectives
- Explain what is meant by a program
- Understand who is a programmer
- Explain what programming language means
- Describe the various language models
- Identify and describe the generations of programming languages and point out their differences
- Identify and describe the basic concepts of Object-Oriented Technology
We will Discuss
- What is a program?
- What is a programming language?
- Who is a programmer?
What is a Program?
There are many definitions of what a program is, the following are some acceptable examples;
- A program is a group of related instructions that aim to perform a task(s).
- A complete set of instructions a computer can interpret and follow to perform a task(s).
- A set of instructions for a computer(s) to follow.
- The complete algorithm for computer(s) to solve specific problems.
What is a Programming Language?
Programming Language Like us computers also has the language they “speak” which is machine language.
- A programming language is a language in which computer programs are written.
- A language that allows humans to interact with computers.
Programming Language Models
- Imperative languages
- Functional Language
- Logic Programming
- Object-oriented Languages
- Declarative Languages
- Scripting Languages
- Parallel Languages
Explanations to Language Models
- Imperative languages: These are comprised of commands and control structures e.g. C, Pascal, Fortran, and Assembly.
- Functional Languages: Based on lambda calculus contains function definitions and function applications
- Logic Programming: It is made up of a complete collection of statements on a specific logic e.g. Prolog.
- Object-oriented Languages: These are used to create objects(modules) that interact with each other. They have the characteristics of real-life objects e.g Java, Eiffel, Simula, and Smalltalk-80 Language Models
- Declarative Languages: They are used to give a general idea as to how the various parts of a program are related (variables and functions)
- Scripting Languages: They usually work with larger applications to perform simple or complex tasks e.g. VBScript and javascript.
- Parallel Languages: Structured data or processes that communicate with each other e.g. Ada and C#
Language Generations
• First Generation(1GL): Also known as machine language is numerical(binary) and machine-dependent. Programs in 1GL are executed fastest compared to other generations. It's very difficult writing machine code.
• Second Generation(2GL): The 2GL permitted the use of symbolic instructions and addresses. Also known as the assembly language it was easier to use and understand than machine code.
• Third Generation(3GL): These languages are machine-independent, making it easier to cross-platform programs. This leaves time for the programmer to focus more on the logic of the program. Language Generations
• Fourth Generation(4GL): Non-procedural programming languages that allow the programmer to focus on what he/she wants and not how to do it.
• Fifth Generation(5GL): The 5GL focuses on creating intelligent programs such as artificial intelligence(A.I.) and fuzzy logic. It provides the groundwork for creating programs using natural language(N.L.).
Object-Oriented Programming(OOP)
OOP simply seeks to let developers envision their programs as real-world objects which work together. As such developers construct systems based on components rather than structures(as was previously done).
Object
• What is an object?
• What are the characteristics of objects?
• What can an object never be?
Object
An object can be taught as an instance of a class. An object can be said to be an example of a class. Objects have state and behavior State are the attributes or characteristics of the object Behaviour are the methods or functions of the object
An Object can be
- Some physical thing in the real world
- A representation of reality
- A tangible or visible thing.
- A thing to which action or thought can be directed.
- Passive i.e. doing nothing until activated
- Active continually monitoring until condition change
An Object can never be
- A value
- A process
- Time
Classes
It is an extensible template for creating objects, providing the initial value of state(variables) and implementations of behavior (functions /methods)
- Attribute: It is a property of a class. The things that help define the class
- Property: The characteristics of an object(mostly associated with data structure).
Classification
This is the process of examining the shared attributes and behaviors to create or describe classes(groups) of objects
Classes are defined by specifying data (attributes) and behavior (functions/methods)
Types of Class
- Abstract class: Declare member variables and member functions e.g. general description of a car without specific details of length, height, etc.
- Concrete class: Define member variables and member functions e.g. a house’s detailed plan including concise measurements(blueprint)
Encapsulation and Abstraction
Encapsulation: This is a process of hiding the system’s operational functions from users of the system. It is employed as a technique to ensure the continued efficiency of the system
Abstraction: This is the process of hiding the functionality of classes from other objects that are not needed by the system. It aids in the reusability of code. Here, the software system only uses the components it requires and the rest are not visible to all objects within the system.
Messages and Operations
• Message: Objects communicate with each other through messages.
• Methods: The ability of an object to perform an action is its method(operation/function).
Relationships
a) Inheritance
b) Association
c) Multiplicity
Inheritance
• The process whereby objects inherit attributes from other objects and classes inherit their attributes from other classes. Types of Inheritance
• Multiple inheritances: A child class inherits from two or more super classes. Super Class Super Class Child Class
Types of Inheritance
• Hierarchical Inheritance: A child class inherits from a parent class which inherits from a grandparent and so on. Parent Class Grandparent Class Child Class Types of Inheritance
• Multi-Level Inheritance: A child class inherits from a super class which in turn inherits from another super class. Super Class Super Class Child Class Types of Inheritance
• Mixed Inheritance: An inheritance that combines any two or more of the other types of inheritance.
Association
• Association: It is how one object is connected or relates to another object.
Types of Association
• One-to-One
• One-to-Many
• Many-to-Many Multiplicity
It is simply the number of objects associated with a class. one object may be related to one class or multiple classes may be related to one object or many objects may be related to many classes
Polymorphism
• It’s a term that is used to define methods that have the same name but return different values. That is, their core functions and return types are not the same even though they have similar names.
Comments
Post a Comment