VB_Lecture_1
VB_Lecture_1
l2socts
https://classroom.google.com/c/NTkyNDY2OD
QxMzM3?cjc=l2socts
2
Course Work Marking Schema
⚫ Two Assignments (15%)
⚫ The required tasks in the labs (5%)
⚫ Two Quizes (10%)
⚫ Midterm Exam (20%)
3
Topics to Be Covered
⚫ Event-Based Programming
⚫ Creating a Swing-Based Window
⚫ Advanced OOP Concepts
⚫ Common Programming Errors
⚫ How to Write a Clean Code
4
What is visual programming
language?
Any language that uses the graphics or blocks
that are already defined with the code and you
just need to use those blocks without worrying
about the lines of code is known as a visual
programming language.
5
Why we study visual
programming language?
⚫ Practice learning and using a large, complex API
⚫ Most modern application programs use sophisticated
graphics and have powerful graphical user interfaces
⚫ Spreadsheets
⚫ Word processing
⚫ Web browsers
⚫ Email programs
⚫ Its important to extend our knowledge from writing crude
console-based programs to portable graphical
applications
8
Why we study visual
programming language?
⚫ Today, the majority of the programming languages are
text-based
⚫ i.e. we have to write the lines of code to perform the specific task
like in C or C++ programming but in visual programming
language this task is replaced by graphics or blocks like
components then can be joined logically to perform the task
9
Examples of visual
programming languages
There are n numbers of visual programming languages and
the few which are in the top list is given below:
⚫ Scratch: With the help of this language users can create,
stories and games without writing any lines of code in this
you just have to create the logic and assemble the blocks.
⚫ Blockly: Used to create block-based programming
language and editors, and also to generate code from
blocks to javascript lua dart python and PHP, etc.
⚫ mBlock language: It is used in programming robots.
11
Applications of Visual
Programming language
VPL can be used in multiple domains like multimedia,
educational purpose, video games, automation. Let’s see
them in brief:
⚫ Multimedia: VPL helps users create multimedia without
worrying about the real code or other complex features.
It narrows down to specific functions and with the help of
those functions, multimedia is created.
⚫ Educational Purpose: Scratch VPL, etc are used to help
students in their projects and make them familiar with the
coding.
⚫ VideoGames: VPL helps to create the videogames
without writing lines of codes Ex- Scratch VPL is used to12
make videogames.
Advantages of Visual
Programming Language
1. Easy to convert ideas into reality for example you don’t know
how to code so you can start with VPL (Visual Programming
Language). and then switch to actual coding
2. Visuals are easy to grasp i.e. to develop something in visual
programming language requires less efforts
3. It includes a variety of built in objects that are required while
creating something using VPL.
4. It is a beginner-friendly also anyone will be able to derive the
logic without worrying about writing lines of code
5. Adding a user-specific code is also available and simple as it
allows to create of blocks as per the convenience of the user
13
Disadvantages of Visual
Programming Language
1. These languages require more memory as they use
graphics, as a result, their execution is also slow and a
large amount of memory is occupied by them.
2. They can only work in an operating system like windows,
mac, or any other operating system which supports
graphics.
3. As the inbuilt functions are not sufficient so you have to
add your custom code as a result it is cumbersome.
4. Only limited functions are present in these languages.
14
Disadvantages of Visual
Programming Language
5. Adding our custom code as a block requires coding
knowledge or else you have to work with limited functions
which are provided with the language.
6. As a computer engineer, it is not a good idea to use VPL
as most of the tech giants like FAANG or other tech
companies work on textual languages like JAVA, HTML,
etc, rather than VPL.
7. For the long run VPL might not be that much useful as in
a regular language you can explore more in it but in VPL
at one point you will get bored by using the same it.
15
Regular vs. Visual
Programming Languages
Regular Languages Visual Programming Language
1. It is a programming It is a programming language that uses
language that only graphics or blocks in place of text.
uses text.
2. Customization and There are not that much customizable as
flexible applications the blocks or graphics that contain the
can be created using codes are limited and after that, we need
regular languages to add our custom code as a block.
3. These are quite fast This is not fast and efficient as every
and efficient block has some code with it so it takes
time and also it has graphics with it.
16
Regular vs. Visual
Programming Languages
Regular Languages Visual Programming Language
5. requires time to learn as any school student will be able to
the user has to get familiar grasp the VPL and create the
with the language syntax applications
then code in it
6. These require less memory This requires more memory as it has
as compared to VPL graphics so to store them more
memory is used.
7. These are quite fast as These are slow as compared to
compared to VPL as they regular languages as it has graphics.
don’t have graphics.
8. Examples: Javascript, C, Examples: Java Swing, Visual Basic,
C++, Java, Python Etc. Visual C#, Visual C++, Mblock,17
Blockly, Scratch Etc.
C/C++ vs. Java vs. VB.net/C#
GUIs
⚫ C/C++ GUI
⚫ C and C++ are interesting because they are commonly the go-to
language for graphics rendering.
⚫ However, this is not because they are easy to use in said
environments, but because of the fact that they are compiled.
⚫ The compilation into native machine code usually means they
outperform most other languages, which is very important if an
application (such as a game) requires high FPS.
⚫ While there are cross-platform GUI libraries available for C/C++,
they are not the easiest to use simply due to their complex nature
compared to other languages.
⚫ If speed is very important, you may want to consider using C/C++
in a graphical environment.
⚫ If, however, you only intend to use a few buttons, edit boxes, and
18
⚫ It is a logical entity.
Student
Recap - OOP Concepts
Unified Modeling Language (UML) - Graphical Class
Representation
⚫ There are three kinds of relationships in UML:
⚫ Associations
⚫ If two classes in a model need to communicate with each
other, there must be link between them.
⚫ An association denotes that link.
One to One
Student Instructor
Student Instructor
1..*
Recap - OOP Concepts
Unified Modeling Language (UML) - Graphical Class
Representation
⚫ There are three kinds of relationships in UML:
⚫ Associations
⚫ The example indicates that every Instructor has one or more
Students:
Student Instructor
1..*
Recap - OOP Concepts
Unified Modeling Language (UML) - Graphical Class
Representation
⚫ There are three kinds of relationships in UML:
⚫ Associations
⚫ We can also indicate the behavior of an object in an
association (i.e., the role of an object) using rolenames.
teaches learns from
Student Instructor
1..* 1..*
member of
1..* 1..*
Student Team
1 president of 1..*
Recap - OOP Concepts
Unified Modeling Language (UML) - Graphical Class
Representation
⚫ There are three kinds of relationships in UML:
⚫ Associations
⚫ Aggregation is a special type of association that models a
whole- part relationship between aggregate and its parts.
⚫ Aggregation indicates a relationship where the child can exist
separately from their parent class. Example: Automobile
(Parent) and Car (Child). So, If you delete the Automobile, the
child Car still exist.
Recap - OOP Concepts
Unified Modeling Language (UML) - Graphical Class
Representation
⚫ There are three kinds of relationships in UML:
⚫ Associations
⚫ Aggregation is a special type of association that models a
whole- part relationship between aggregate and its parts.
⚫ For example, the class college is made up of one or more
student. In aggregation, the college class will remain even if
the student is not available.
Solution:
• 1 or more Pets associated with 1 PetOwner
• Each pet has exactly one PetOwner
Recap - OOP Concepts
Example: Describe the below UML diagram
Recap - OOP Concepts
Example: Describe the below UML diagram
Solution:
• 1 Bank associated with 0 or more Accounts
• Each Account is associated with exactly one bank
• Checking, Savings, and MoneyMarket are derived from
Account class
Recap - OOP Concepts
Example: Draw UML diagram for the below system
⚫ A bank system contains data on customers(identified by
name and address) and their accounts.
⚫ Each account has a balance and there are 2 type of
accounts: one for savings which offers an interest rate,
the other for investments, used to buy stocks.
⚫ Stocks are bought at a certain quantity for a certain price
(ticker) and the bank applies commission on stock
orders.
Recap - OOP Concepts
Solution:
Recap - OOP Concepts
Example: Consider the following class diagram, write true
or false of the following
Recap - OOP Concepts
Example: Consider the following class diagram, write true
or false of the following
1. The class Vehicle does not contain any attributes. ( )