[go: up one dir, main page]

0% found this document useful (0 votes)
4 views31 pages

SIT 103 Introduction L1

The document outlines the course SIT 103 Visual Programming, focusing on developing Windows applications with a Graphical User Interface using event-driven and object-oriented programming paradigms. It covers essential programming concepts, paradigms, and introduces Visual Basic.NET and the .NET framework, detailing its components and object-oriented programming concepts such as classes, inheritance, encapsulation, and polymorphism. The content is designed for students who have completed the prerequisite course SCS101 and aims to enhance their programming skills.

Uploaded by

kimmaurice4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views31 pages

SIT 103 Introduction L1

The document outlines the course SIT 103 Visual Programming, focusing on developing Windows applications with a Graphical User Interface using event-driven and object-oriented programming paradigms. It covers essential programming concepts, paradigms, and introduces Visual Basic.NET and the .NET framework, detailing its components and object-oriented programming concepts such as classes, inheritance, encapsulation, and polymorphism. The content is designed for students who have completed the prerequisite course SCS101 and aims to enhance their programming skills.

Uploaded by

kimmaurice4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

SIT 103

VISUAL PROGRAMMING
Pre-requisites: SCS101
J. Kamiri
Department of Information Technology
Preamble
• Most people are familiar with the existing tasks the computer can
perform.
• You have also learnt the basics of programming in SCS 101.
• You were exposed on how to command computers to perform various
tasks.
• i.e software-instructions you write to command computers to perform
actions and make decisions that controls computer hardware.
• In this unit you will go a step further and learn how to develop
windows application that have a Graphical User Interface (G.U.I).
• This unit uses Event-driven and object-oriented programming
paradigms.
Programming Concepts (Refresher)
• Program-it is a sequence of instructions, statements, and series of
codes that instruct a computer to perform certain tasks.
• Programmer-this is a person who writes computer programs
• Programming-This is the act of writing, coding, testing and running a
series of instructions to perform a certain task.
• Programming language-This is an organized collection of symbols
with syntax and semantics to prepare computer programs.
• Modules-smaller programs units, also known as subsets of a program
Programming Paradigms (Refresher)
• A programming paradigm is an approach to solving programming
problems
• A programming paradigm may consist of many programming
languages.
• Programming paradigms are the result of people’s ideas about how
programs should be constructed
• A programming language can belong to more than one paradigm
• They include: Procedural/sequential, Object-oriented, Event-
Oriented, Functional, Scripting, modular
Programming Paradigms (Refresher) Cont.
Imperative/procedural/sequential paradigm
• Designs a program that follows a series of instructions in a sequential
manner.
• i.e it follows top-bottom approach in program execution.
• Example C programming
Functional Programming:
• In this paradigm, a program consists of functions and uses functions in a
similar way as used in mathematics
• Execution involves functions calling one another.
• Example FOTRAN
Programming Paradigms (Refresher) Cont.
Scripting:
• Scripting is a very “high” level of programming which glues together different
programs.
• Scripts are written in presence of core programming language, though they are
different from the core programming language
• They are mostly used in website development and mobile application
development. Example: JavaScript is used to make a website to be responsive.
Modular:
• Divides the program into sections known as modules, each module is developed
independent of one another then the modules are integrated to create the final
program.
• Majority of programming especially event-driven and OOP apply modular
approach
Programming Paradigms (Refresher) Cont.
Object-Oriented Programming
• This paradigm uses classes and objects.
• It has other concepts such as inheritance, polymorphism,
encapsulation, etc. Example, Java, C++, Python, Visual Basic
Event-driven Programming
• Programming that is based on user events such as clicking a button,
hoovering a mouse, etc. These user actions are called events
• Mainly uses a Graphical user Interface (GUI)
• Example; Visual Basic programming, Java
Introduction to Visual Basic.Net
• Visual Basic is a third-generation event-driven and Object-Oriented
programming language first released by Microsoft in 1991. It evolved
from the earlier Disk Operating System(DOS) version called BASIC.
• BASIC means Beginners' All-purpose Symbolic Instruction Code.
• Since then Microsoft has released many versions of Visual Basic, from
Visual Basic 1.0 to the final version Visual Basic 6.0.
• Visual Basic is a user-friendly programming language designed for
beginners, and it enables anyone to develop GUI window applications
easily.
Cont.
• In 2002, Microsoft released Visual Basic.NET(VB.NET) to replace
Visual Basic 6.
• Thereafter, Microsoft declared VB6 a legacy programming language in
2008.
• Fortunately, Microsoft still provides some form of support for VB6.
• VB.NET embraces concepts of Object-Oriented programming and
implements them using Event-driven programming.
The .NET framework
• .NET is a software framework that is designed and developed by
Microsoft. The first version of the .Net framework was 1.0 which
came in the year 2002.
• It is a virtual machine for compiling and executing programs written in
different languages like C#, VB.Net, etc.
• .Net is used to develop Form-based applications for windows, phone
applications, and Web-based applications.
• The framework supports more than 60 programming languages which
include: C#, F#, VB.NET, J#, VC++, JScript.NET, APL, COBOL, Perl,
Oberon, ML, Pascal, Eiffel, Smalltalk, etc.
The .NET framework Components
1. CLR (Common Language Runtime)
• CLR is the basic and Virtual Machine component of the .NET
Framework.
• It is the run-time environment in the .NET Framework that runs the
codes and helps in making the development process easier by
providing various services such as:
• remoting, thread management, memory management, robustness, etc.
• It acts as an interface between the framework and operating system.
• Basically, it is responsible for managing the execution of .NET programs
regardless of the .NET programming language.
• Moreover, it provides security, type-safety, interoperability, and
portablility.
CLR Procedure of Converting Source Code to Machine Code

CLR (Just in Time


MSL and Meta-data Compiler):
Source Code (Net .Net language
(Portable Converts Machine Language
Technologies) compiler
Executable file) Intermediate Code
to Machine code
The .NET framework Components Cont.
2. FCL (Framework Class Library)
• It is the collection of reusable, object-oriented class libraries and
methods, etc that can be integrated with CLR.
• Also called the Assemblies. It is just like the header files in C/C++ and
packages in java. Installing the .NET framework basically is the installation of
CLR and FCL into the system.
3. CTS (Common Type System)
• It specifies a standard that represent what type of data and value can
be defined and managed in computer memory at runtime.
• A CTS ensures that programming data defined in various languages should
interact with each other to share information.
The .NET framework Components Cont.
4. CLS (Common language Specification)
• It is a subset of common type system (CTS) that defines a set of rules
and regulations which should be followed by every language that
comes under the .net framework.
• A programming language that adheres to CLS is able to easily
integrate with other programming languages thus promoting
interoperability between various applications.
Object-Oriented Programming Concepts
Supported by VB.Net
• OOP concepts are the features that differentiate OOP languages from
other paradigms. They include:
• Objects
• Classes
• Inheritance
• Abstraction
• Encapsulation
• Polymorphism
OOP Concepts: Object
• An Object it is the basic run-time entity in an object-oriented
programming. Programing problem is analyzed in terms of objects and
nature of communication between them.
• Any real-life entity can become an object in OOP.
• In |VB.net an object can be a piece of an application, like a control or a
form.
• When you create an application in visual basic you are constantly interacting with
objects in the form of controls.
• An object is an instance/ case of a class that stores values of the attributes
defined in the class.
• This means that an object emanates from a class therefore each object must belong
to a class
Cont.
• An object has three main characteristics:
• Identity – this is the unique name used to identify the object
• State- features or characteristics that define an object.
• Behavior- Functionality of an object. i.e what an object does
• For example a dog is a real-life entity.
• Identity- name of the dog (E.g Bosco)
• State include things such as- Breed, Age, color,
• Behavior- what a dog does such as (barking, wagging tale, sleep, Eat)
• Try and think of other real-life entities that can form objects then
enumerate their identity, state, and behavior.
OOP Concepts: Classes
• A class is a collection of similar objects which is created by a programmer
as a user-defined data type.
• A class can consist as many objects as possible so long as those objects
share common characteristics.
• The programmer has to be careful when creating a class because the class
influences the objects that can be contained in it.
• For example: think of a programmer who wants to develop a program that
deals with automobiles.
• If the programmer creates a class known as Vehicles, then inside that class there can
be objects such as cars, lorries, vans, buses, pick-ups, trailers. This is so because all
these objects have common characteristics that qualify them to be vehicles such as
they all have engines, wheels, windscreen, steering wheel, pedals etc.
• Therefore the class Vehicles is more of a general class.
Cont.
• Approach two if the programmer wants to be more specific towards a
particular category of vehicles such as cars.
• Then he can create a class known as Cars and then inside it have objects such
as Toyota Corolla, BMWX1, Audi A3, Volkswagen Golf, etc. all these cars have
some common characteristics such as they all have four wheels.
• A class consists of data members and member functions, which can
be accessed and used by creating an instance of that class.
• i.e elements of a class can only be accessed by creating an object of that class.
• It represents the set of properties or methods that are common to all
objects of the class.
OOP Concepts: Inheritance
• Inheritance is an important pillar of OOP. It is the capability of a class
to derive properties and characteristics from another class.
• So when we create a class, we do not need to write all the properties
and functions again and again, as these can be inherited from another
class that possesses it.
• Thus, Inheritance allows the user to reuse the code whenever
possible and reduce its redundancy.
• For example if you have two classes (1) Class Animal and (2) class
pets.
• You don’t have to repeat common characteristics of class animal in class pets
inheritance can help class pets to acquire these properties.
Types of Inheritance
• Hierarchical Inheritance:
• In this relationship, multiple derived classes can inherit features from a single
base class.
• A single derived class can inherit features from multiple base classes.
• A base class is a class that is inherited from while a derived class is one that
inherts from another class.
Types of Inheritance Cont.
• Hierarchical Inheritance cont:
• It can also be represented using the diagram below in which a single derived
class inherits from multiple base classes.
Types of Inheritance Cont.
• Multi-level inheritance:
• This is where a derived class can inherit features from other derived classes
Types of Inheritance Cont.
• Hybrid inheritance:
• This is a combination of more than one types of inheritance. For example a
derived class can have both hierarchical and multiple inheritance
OOP Concepts: Abstraction
• Data abstraction refers to providing only essential information about the
data to the outside world and hiding the background details or
implementation.
• Consider a real-life example of a person sending money via mpesa, the person only
knows that by following a series of steps and finally pressing the send button the
money is sent.
• The user is never concerned about how the money moves from one account to
another.
• Data abstraction is one of the most essential features of OOP.
• With abstraction a developer is able to develop software that is user
friendly.
• For instance with a GUI a lot of background processing and algorithm is
hidden from the user.
Cont.
• Data Abstraction has been applied in each and every software and
even gadgets that we use on a daily basis.
• For example think of your student portal, once you open it a login page
appears you input your registration number and password, if they are correct
you are logged in if not you are given an error message.
• So database details, control structures, and other algorithms used are hidden
from you as a general user.
• In some OOP languages such as JAVA abstraction within a class can be
defined by creating an abstract class.
OOP Concepts: Encapsulation
• Encapsulation is defined as the wrapping up of data under a single unit.
• It is the mechanism that binds together code and the data it manipulates.
• In OOP classes play the vital role of encapsulating data and properties
within them.
• For example if you have a class known as Box with properties such as width, legth,
height, color etcs. When you refer to an instance of class box (i.e an object of class
box) you as well or automatically consider the properties that are defined in that
class.
• In Encapsulation, the variables or data of a class are hidden from any other
class and can be accessed only through any member function of their class
in which they are declared. So it is also known as data-hiding.
Cont. Example of Encapsulation
• Consider a real-life example of encapsulation, in a company, there are different
sections like the accounts section, finance section, sales section, etc.
• The finance section handles all the financial transactions and keeps records of all
the data related to finance.
• Similarly, the sales section handles all the sales-related activities and keeps
records of all the sales. Now there may arise a situation when for some reason an
official from the finance section needs all the data about sales in a particular
month.
• In this case, he is not allowed to directly access the data of the sales section. He
will first have to contact some other officer in the sales section and then request
him to give the particular data.
• This is what encapsulation is. Here the data of the sales section and the
employees that can manipulate them are wrapped under a single name “sales
section”.
OOP Concepts: Polymorphism
• The word polymorphism means having many forms. In simple words,
we can define polymorphism as the ability of a message to be
displayed in more than one form.
• For example, A person at the same time can have different
characteristics. Like a man at the same time is a father, a husband, an
employee, a son, a brother, a citizen etc.
• So the same person posses different behavior in different situations.
This is called polymorphism.
• Polymorphism allows for the same method to be used in different
parts of a program or in different classes to have different meanings.
Cont. Example
• Here is an example. We have a base class known as animal with a method known
as sound () and two derived classes cat and Dog. However, class Cat implements
method sound () as {Meow} while in class Dog sound() is implemented as {bark}
The End

You might also like