ADVANCED PROGRAMMING
2020
ADVANCED
PROGRAMMING
ASSIGNMENT
TO
LECTURUER
[Link]
BY
JKONSIKAN
J/IT/19/15/05
J/IT/19/15/05 1|Page
ADVANCED PROGRAMMING
ACKNOWLEDGEMENT
The success and final outcome of this assignment required a lot of guidance and assistance
from many people and I extremely fortunate to have got this all along the completion of my
assignment work. Whatever I have done is only due to such guidance and assistance and
would not forget to thank them.
My deepest thanks to lecturer, [Link] for giving an opportunity to do this
assignment work and providing me support and guidance which made me complete the
assignment on time, I extremely grateful to him for providing such a nice support and guidance.
Because I managed to complete this assignment within the time and also, He make necessary
correction as and when needed with attention and care.
I also extend my heartfelt thanks to my family and friends.
J. Konsikan
CSD-15
J/IT/19/15/05
J/IT/19/15/05 2|Page
ADVANCED PROGRAMMING
CONTENTS
INTRODUCTION .................................................................................................................. 5
I. LEARNING OUTCOME 1 – [LO1] .................................................................................. 6
II. LEARNING OUTCOME 2 – [LO2] ................................................................................ 23
III. LEARNING OUTCOME 3 – [LO3] ................................................................................ 26
IV. LEARNING OUTCOME 4 – [LO4] ................................................................................ 27
REFERENCES ................................................................................................................... 32
PLAGIARISM REPORT ...................................................................................................... 33
J/IT/19/15/05 3|Page
ADVANCED PROGRAMMING
LIST OF FIGURES
FIGURE 1 PROGRAMMING................................................................................................................... 6
FIGURE 2 IMPERATIVE PROGRAMMING PARADIGM ....................................................................... 7
FIGURE 3 CHARECTERISTICS OF OOP ............................................................................................. 8
FIGURE 4 EXAMPLE CONSTRUCTOR ................................................................................................ 9
FIGURE 5 EXAMPLE INHERITANCE .................................................................................................. 10
FIGURE 6 EXAMPLE VARIABLES ...................................................................................................... 11
FIGURE 7 EXAMPLE METHOD OVERLOADING ............................................................................... 12
FIGURE 8 EXAMPLE ABSTRACTION ................................................................................................. 13
FIGURE 9 EXAMPLE ACCESS MODIFIERS ....................................................................................... 14
FIGURE 10 EXAMPLE METHOD ......................................................................................................... 15
FIGURE 11 EXAMPLE POLYMORPHISM ........................................................................................... 15
FIGURE 12 EXAMPLE INTERFACES .................................................................................................. 16
FIGURE 13 EXAMPLE ENCAPSULATION .......................................................................................... 16
FIGURE 14 EXAMPLE STATIC BLOCK .............................................................................................. 17
FIGURE 15 DESIGN PATTERNS ........................................................................................................ 18
FIGURE 16 EXAMPLE SINLGETON PATTERN .................................................................................. 19
FIGURE 17 EXAMPLE BRIDGE PATTERN ......................................................................................... 20
FIGURE 18 EXAMPLE STATE PATTERN ........................................................................................... 21
FIGURE 19 UML DIAGRAM TYPES .................................................................................................... 23
FIGURE 20 EXAMPLE UML DIAGRAM ............................................................................................... 24
FIGURE 21 UML DIAGRAM FOR GIVEN SCENARIO ........................................................................ 25
FIGURE 22 EXAMPLE DESIGN FOR DESIGN PATTERN ................................................................. 27
FIGURE 23 DAO IMPLEMENTATION .................................................................................................. 28
FIGURE 24 HOME ................................................................................................................................ 29
FIGURE 25 ADMIN LOGIN FORM ....................................................................................................... 29
FIGURE 26 CUSTOMER ADD ............................................................................................................. 30
FIGURE 27 DASHABOARD VIEW ....................................................................................................... 30
FIGURE 28 BILLING RECEIPT ............................................................................................................ 31
J/IT/19/15/05 4|Page
ADVANCED PROGRAMMING
INTRODUCTION
In this module I have learned 4 learning outcomes. This assignment in based on the Advanced
Programming learning out comes. OOP is an object- oriented programming techniques that
combines data and instructions for processing that data into an object that can be used within
the program. Object-oriented programming provides concepts that help modelling complicated
systems of real world into manageable software solutions. LO1: Analyze template pattern
types and examine main components relevant to the object-oriented programming model.
LO2: Build several UML class diagrams. LO3: Write code that meets design patterns. LO4:
Examine situations in terms of design trends.
J/IT/19/15/05 5|Page
ADVANCED PROGRAMMING
I. LEARNING OUTCOME 1 – [LO1]
ASSES RISKS TO IT SECURITY.
[P1, M1, D1]
PROGRAMMING
Figure 1 PROGRAMMING
The process of designing and creating an executable computer program to achieve a specific
computing result or perform a specific task is known as computer programming.
PROGRAMMING PARADIGMS
A programming paradigm is a way of thinking about and organizing the features of a program.
Programming paradigms vary in terms of how a program's execution and control are specified,
as well as the components that make up the program.
Types of Programing Paradigms:
PROCEDURAL LOGIC
PROGRAMMING PARADIGMS PROGRAMMING
STRUCTURED FUNCTIONAL
PROGRAMMING IMPERATIVE DECLARATIVE PROGRAMMING
OBJECT- DATABASE
ORIENTED PROCESSING
PROGRAMMING APPROACH
J/IT/19/15/05 6|Page
ADVANCED PROGRAMMING
IMPERATIVE PROGRAMMING PARADIGM
Figure 2 IMPERATIVE PROGRAMMING PARADIGM
Imperative programming is a programming paradigm that employs statements that alter the
state of a program.
An imperative program is made up of commands for the machine to execute, similar to how
the imperative mood in natural languages expresses commands.
Example:
int total = 0;
int number1 = 5;
int number2 = 10;
int number3 = 15;
total = number1 + number2 + number3;
From assigning values to each variable to the final addition of those values, each
statement changes the state of the program.
The program is specifically told how to add the numbers 5, 10, and 15 together using
a series of five statements.
STRUCTURED PROGRAMMING
It is a programming paradigm aimed at refining the quality, clarity, and development
time of a computer program by creating wide use of the structured control flow
concepts of selection.
PROCEDURAL PROGRAMMING
Procedural Programming is likely to be a modern developer's first programming paradigm.
Procedural code, in its most simple form, is the code that tells a computer how to complete a
task in logical steps.
J/IT/19/15/05 7|Page
ADVANCED PROGRAMMING
OBJECT-ORIENTED PROGRAMMING
Object Oriented Programming (OOP) is a programming model in which real-world objects are
treated as separate entities with their own state that can only be changed by built-in
procedures known as methods.
Objects are encapsulated into modules, which contain both local environments and methods,
since they operate independently. Message passing is used to communicate with an entity.
FEATURES OF OBJECT-ORIENTED PROGRAMMING
▪ Emphasis is on data than procedures Objects are used to categorize programs.
▪ The aim of data structures is to characterize objects.
▪ The data structure ties together methods that operate on an object's data.
▪ External functions are unable to access the data since it is hidden.
▪ Methods are how objects interact with one another.
▪ When new methods and data are required, they can be easily added.
▪ Follows the bottom-up approach in program design
CHARACTERISTIC OF OBJECT-ORIENTED PROGRAMMING
Figure 3 CHARECTERISTICS OF OOP
J/IT/19/15/05 8|Page
ADVANCED PROGRAMMING
OBJECTS & CLASSES
In an object-oriented method, objects are run-time entities. An individual, a bank account, a
place, or a set of data can all be represented by an object. User-defined data types, such as
lists and vectors, can also be represented.
The definition of the class can be used to transform an object's entire collection of code and
data into a user-defined data type. A class is referred to as a "data-type," and an object is
referred to as a "variable" of that type. After a class is created, any number of objects can be
created.
Object
Data Person
Name
Basic Pay
Salary () Method
Tax ()
CONSTRUCTOR
In Java, a constructor is a special method for initializing objects. When a class object is
generated, the constructor is named. It's possible to use it to set the default values for object
attributes:
Figure 4 EXAMPLE CONSTRUCTOR
J/IT/19/15/05 9|Page
ADVANCED PROGRAMMING
INHERITANCE
The mechanism by which objects of one class inherit properties from objects of another class
is known as inheritance. The definition of hierarchical grouping is supported by inheritance. A
bird called Robin, for example, is a member of the class, not a mammal, which is also a
member of the Animal class.
Types of Inheritance:
▪ Single
▪ Multiple
▪ Multilevel
▪ Hybrid
ANIMAL
MAMMAL NOT MAMMAL
DOG TIGE HEN ROBI
R N
Figure 5 EXAMPLE INHERITANCE
J/IT/19/15/05 10 | P a g e
ADVANCED PROGRAMMING
VARIABLES
A variable is a type of named storage that our programs can access. Variables are divided
into three categories in Java.
▪ Class variables: Also known as static variables, are declared in a class but outside of
a method, constructor, or block using the static keyword.
▪ Instance variables: Variables that are declared outside of a method but are declared
in a class. When space in the heap is allocated for an object, a slot is created for each
instance variable value.
▪ Local variables: Declared in methods, constructors, and blocks, among other locations.
When a method, constructor, or block is entered, a local variable is generated, and the
variable is destroyed when the method, constructor, or block is exited.
Figure 6 EXAMPLE VARIABLES
J/IT/19/15/05 11 | P a g e
ADVANCED PROGRAMMING
METHOD OVERLOADING
It's possible to provide different parameter lists and meanings for methods of the same
name. This is called method overloading. When objects must perform similar tasks but with
different input parameters, method overloading is necessary.
Figure 7 EXAMPLE METHOD OVERLOADING
J/IT/19/15/05 12 | P a g e
ADVANCED PROGRAMMING
ABSTRACTION
A method is a program module that consists of a set of statements that perform a specific task.
Invoke or call a method from another method to execute it; the calling method makes a method
call, which invokes the called method.
The abstract keyword is a non-access modifier, used for classes and methods:
▪ Abstract class: Is a constrained class that cannot be used to create objects.
▪ Abstract method: Can only be contained in an abstract class, and it does not have a
body. The body is provided by the subclass.
Figure 8 EXAMPLE ABSTRACTION
J/IT/19/15/05 13 | P a g e
ADVANCED PROGRAMMING
ACCESS MODIFIERS
Modifiers in Java are divided into two categories: access modifiers and non-access modifiers.
The accessibility or scope of a field, method, constructor, or class is specified by the access
modifiers in Java. The access modifier can be used to modify the access level of fields,
constructors, methods, and classes.
▪ Private: A private modifier's access level is limited to the class. It isn't accessible
outside of the class.
▪ Default: A default modifier's access level is limited to the package. It's not possible to
get to it from outside the package.
▪ Protected: A protected modifier's access level is both inside the package and outside
the package through a child class.
▪ Public: A public modifier's access level is visible everywhere. It can be accessed from
within and outside the class, from within and outside the package, and from within and
outside the package.
Figure 9 EXAMPLE ACCESS MODIFIERS
J/IT/19/15/05 14 | P a g e
ADVANCED PROGRAMMING
METHOD
A method is a block of code that only executes when it is invoked. Parameters are data that
can be passed through a method. Methods, also known as functions, are used to carry out
particular tasks.
Figure 10 EXAMPLE METHOD
POLYMORPHISM
Polymorphism is a main OOP concept that refers to the tendency to take several different
types. An operation, for example, behaves differently in different situations. The operation's
behavior is dictated by the type of data used.
For example, think of a superclass named Animal that has a method called animalSound().
Subclasses of Animals could be Pigs, Cats, Dogs, Birds - And they also have their own
employment of an animal sound.
Figure 11 EXAMPLE POLYMORPHISM
J/IT/19/15/05 15 | P a g e
ADVANCED PROGRAMMING
INTERFACES
An interface is a type of "abstract class" that is used to group together similar methods that
have empty bodies. The "implement" class provides the body for interface methods that don't
have one. You must override all of an interface's methods when implementing it. By default,
interface methods are abstract and public.
Figure 12 EXAMPLE INTERFACES
ENCAPSULATION
The aim of encapsulation is to keep "important" data out of the hands of users. To access and
change the value of a private variable, include public get and set methods. Control over class
attributes and methods is strengthened. Can make class attributes read-only or write-only.
The programmer can make adjustments to one section of the code without affecting the others.
Data protection has been strengthened.
Figure 13 EXAMPLE ENCAPSULATION
J/IT/19/15/05 16 | P a g e
ADVANCED PROGRAMMING
STATIC BLOCK
Java has a static block (also known as a static clause) that can be used to perform static
initializations on a class. This code in the static block is only run once: when the class is loaded
into memory for the first time. Examine the performance of the Java program below, for
example.
Figure 14 EXAMPLE STATIC BLOCK
BENEFITS OF OOP
▪ Re-usability
▪ Data Redundancy
▪ Code Maintenance
▪ Security
▪ Design Benefits
▪ Better productivity
▪ Easy troubleshooting
▪ Polymorphism Flexibility
J/IT/19/15/05 17 | P a g e
ADVANCED PROGRAMMING
DESIGN PATTERNS
Figure 15 DESIGN PATTERNS
The best practices used by experienced object-oriented software developers are defined by
design patterns. Style patterns are solutions to common issues that software developers face
when developing software. Several software engineers utilized trial and error to arrive at these
solutions over a long period of time.
ADVANTAGES OF DESIGN PATTERNS
▪ They can be used in a variety of projects.
▪ They provide solutions that aid in the definition of the device architecture.
▪ They record software engineering encounters.
▪ They make an application's architecture more transparent.
▪ Since they were built on the expertise and experience of expert software developers,
they are well-proven and tested solutions.
TYPES OF DESIGN PATTERNS
▪ Creational design patterns
▪ Structural design patterns
▪ Behavioral design patterns
▪ J2EE patterns
J/IT/19/15/05 18 | P a g e
ADVANCED PROGRAMMING
CREATIONAL PATTERNS
Rather than instantiating objects directly with the new operator, these design patterns offer a
way to create objects while hiding the creation logic. This allows the software more
independence in evaluating which items are needed for a given use case.
There are following 6 types of creational design patterns.
▪ Prototype Pattern
▪ Factory Method Pattern
▪ Singleton Pattern
▪ Builder Pattern
▪ Object Pool Pattern
▪ Abstract Factory Pattern
Singleton Pattern
The singleton pattern is one of Java's most basic design patterns. This design pattern is
classified as a creational pattern because it offers one of the most effective ways to
construct an object. This pattern uses a single class that is in charge of creating an object
while ensuring that only one object is generated.
Advantages
▪ Interfaces can be implemented by singletons.
▪ Parameters for singletons can be transferred.
▪ The instances of singletons can be switched out (such as for testing purposes)
▪ Since singletons can be treated polymorphically
▪ several implementations are possible.
Figure 16 EXAMPLE SINLGETON
PATTERN
J/IT/19/15/05 19 | P a g e
ADVANCED PROGRAMMING
STRUCTURAL PATTERNS
These design patterns deal with the composition of classes and objects. Inheritance is a term
that is used to construct interfaces and determine how to combine objects to create new
functionalities.
There are ensuing 7 types of structural design patterns.
▪ Adapter pattern
▪ Flyweight pattern
▪ Bridge pattern
▪ Proxy pattern
▪ Decorator pattern
▪ Facade pattern
▪ Composite pattern
Bridge Pattern
Simply "decouple the functional abstraction from the implementation so that the two can
differ independently," according to the Bridge Pattern. The Handle or Body Pattern is
another name for the Bridge Pattern.
Advantages
▪ It allows the implementation and the user interface to be segregated.
▪ It increases the extensibility of the device.
▪ It helps the client to be unaware of implementation specifics.
This pattern uses an interface as a bridge, separating the functionality of concrete classes
from the functionality of interface implementer classes.
Figure 17 EXAMPLE BRIDGE PATTERN
J/IT/19/15/05 20 | P a g e
ADVANCED PROGRAMMING
BEHAVIORAL PATTERNS
The relationship and accountability of artifacts are the focus of behavioral design patterns.
The interaction between the objects in these design patterns should be such that they can
effectively communicate with one another while remaining loosely coupled.
There are 12 types of structural design patterns:
▪ Chain of Responsibility Pattern ▪ Memento Pattern
▪ Command Pattern ▪ Observer Pattern
▪ Interpreter Pattern ▪ State Pattern
▪ Iterator Pattern ▪ Strategy Pattern
▪ Mediator Pattern ▪ Template Pattern
▪ Null Object ▪ Visitor Pattern
State Pattern
A class's behavior varies depending on its state in the State pattern. This design pattern
is classified as a behavior pattern. Build objects that represent various states and a context
object whose behavior changes as its state object changes in the State pattern. "The class
activity shifts depending on its state," according to a State Pattern.
Advantages
▪ The state-specific activity is maintained.
▪ Any state transitions are made clear.
▪ It's used when there are a lot of multipart conditional statements in the operations
that are dependent on the state of an entity.
Figure 18 EXAMPLE STATE PATTERN
J/IT/19/15/05 21 | P a g e
ADVANCED PROGRAMMING
RELATIONSHIP BETWEEN OBJECT ORIENTED PARADIGM AND DESIGN PATTERNS
Object Oriented Programming and Design Patterns are not always related. Object Oriented
Programming is used in a significant range of design trends.
A design pattern is a technique for designing programs that is widely used. The method of
determining a field's universal pattern language can be applied to functional programming,
bridge building, or, finally, architecture. Some programming patterns fit into the OOP, which is
a particular conceptual paradigm.
Design Patterns are well-known methods to resolving problems in OOP programming.
Knowing design trends will help you save time when deciding how to solve a problem.
Some design patterns, such as the Visitor Pattern, allow you to do things that would otherwise
be difficult or complicated, such as introducing new features to a set of classes without them
thinking about it. An interface or virtual methods that each class implements will be created
using standard OOP techniques. This is in violation of the OOP open/closed principle.
Patterns are used widely in the Java [Link] systems, so programmers use them without
ever learning them. The Decorator pattern is used for the majority of the classes in the Java
IO namespace.
CONCLUSION
The main relationship between object-oriented paradigms and design patterns is that we
would almost inevitably use design patterns if we want to use OOP in programming for useful
code. Design trends aid in the implementation of the object-oriented paradigm's properties.
The importance of strict adherence to the programming model and design pattern is essential.
The model defines the style of programming, while design trends describe the solutions to
common problems that occur during the development of computer programs. As a
consequence, in programming, object-oriented paradigms and design trends are critical.
Design approaches are based on functional ideas that have been successfully repeated. The
transformation from research to design to design to implementation is referred to as design
formats. A design approach is a simplified version of a continuous solution that solves a
problem in a specific situation.
CODES EXAMPLES FOR LO1
[Link]
J/IT/19/15/05 22 | P a g e
ADVANCED PROGRAMMING
II. LEARNING OUTCOME 2 – [LO2]
DESIGN A SERIES OF UML class diagrams.
[P3, P4, M2]
CLASS DIAGRAM
A class diagram in the Unified Modeling Language is a type of static structure diagram in
software engineering that depicts the structure of a system by displaying the system's classes,
their attributes, operations, and object relationships.
UML CLASS DIAGRAM
Figure 19 UML DIAGRAM TYPES
In the Unified Modeling Language (UML), a class diagram is a static structure diagram that
depicts the structure of a system by displaying the system's classes, attributes, operations (or
methods), and relationships among objects.
Essential elements of UML class diagram are:
▪ Class Name
▪ Attributes
▪ Operations
J/IT/19/15/05 23 | P a g e
ADVANCED PROGRAMMING
PURPOSE OF UML DIAGRAMS
▪ Analysis and implementation of an application's static view.
▪ Describe a system's roles.
▪ Component and deployment diagrams are built on this foundation.
▪ Forward and reverse engineering are two forms of engineering.
BENEFITS OF USING UML TOOLS
▪ Data models for even the most complex information systems are depicted in class
diagrams. It gives a high-level overview of the application's layout before digging into
the code.
▪ This will significantly decrease the amount of time spent on repairs.
▪ It assists in the comprehension of an application's general schematics.
▪ Allows for the creation of informative charts that highlight the code that needs to be
programmed.
DESIGN & BUILD CLASS DIAGRAM
The most popular UML diagrams used for software application creation are class diagrams. It
is important to understand the class diagram drawing process. Class diagrams have a lot of
properties to consider when drawing them, so we'll look at them from the top down. A class
diagram is a graphical representation of the system's static view that depicts various aspects
of the application. The entire scheme is represented by a series of class diagrams.
Example Bridge pattern UML diagram:
Figure 20 EXAMPLE UML DIAGRAM
J/IT/19/15/05 24 | P a g e
ADVANCED PROGRAMMING
CODE FOR GIVEN SCENARIO
[Link]
UML DIAGRAM FOR GIVEN SCENARIO
Figure 21 UML DIAGRAM FOR GIVEN SCENARIO
CONCLUSION
UML is a common language for defining, designing, and visualizing software system objects.
A class is an object's blueprint. A class diagram depicts the various types of objects in the
structure as well as the various types of relationships that occur between them. It helps study
and design of the static view of a software application Class diagrams are most popular UML
diagrams used for software application creation Before digging into the code, take a look at
the Class Diagram to get a sense of how the program is organized. It certainly cuts down on
maintenance time.
J/IT/19/15/05 25 | P a g e
ADVANCED PROGRAMMING
III. LEARNING OUTCOME 3 – [LO3]
IMPLEMENT CODE APPLYING DESIGN PATTERNS
[P3, M3, D3]
[Link]
J/IT/19/15/05 26 | P a g e
ADVANCED PROGRAMMING
IV. LEARNING OUTCOME 4 – [LO4]
INVESTIGATE SCENARIOS WITH RESPECT TO DESIGN PATTERNS
[P4, M5, D4]
DAO DESIGN PATTERN ON MY JUSTIFICATION
In general, object-oriented design patterns display relationships and relationships between
classes or objects without defining end-use classes or related objects. I used the Data Access
Object (DAO) design pattern in this learning outcome 3. In the structural design pattern, DAO
is used. Structural Design trends are concerned with how larger structures can be generated
by combining classes and objects.
▪ The Data Access Object Interface - specifies the operations that can be performed on
a model object.
▪ Concrete class for Data Access Object - This class implements the above interface.
This class is in charge of retrieving information from a data source, which may be a
database storage mechanism.
▪ Model Object - A basic POJO with get methods for storing data retrieved with the DAO
class.
Example Design:
Figure 22 EXAMPLE DESIGN FOR DESIGN PATTERN
J/IT/19/15/05 27 | P a g e
ADVANCED PROGRAMMING
ADVANTAGES
The advantages of using the DAO template pattern The DAO (Data Access Object) design
pattern is a clear example of object-oriented concepts of abstraction and encapsulation.
Persistence logic is separated into a separate layer called Data access layer, which allows
applications to respond safely to changes in the persistence mechanism.
▪ Item retrieval calls are common.
▪ The general create/read/update/delete flow can be replicated for other DAOs once the
general layout is set.
▪ It also organizes where you can put the code that deals with persistence. Distinguishes
the business logic from the rest of the code.
DAO IMPLEMENTATION
Figure 23 DAO IMPLEMENTATION
J/IT/19/15/05 28 | P a g e
ADVANCED PROGRAMMING
ELECTRICITY BILLING SYSTEM DESIGN IDEA
Figure 24 HOME
LOGIN FORM
Figure 25 ADMIN LOGIN FORM
J/IT/19/15/05 29 | P a g e
ADVANCED PROGRAMMING
CUSTOMER DETAILS ADD
Figure 26 CUSTOMER ADD
DASHBOARD VIEW
Figure 27 DASHABOARD VIEW
J/IT/19/15/05 30 | P a g e
ADVANCED PROGRAMMING
BILLING RECEIPT
Figure 28 BILLING RECEIPT
J/IT/19/15/05 31 | P a g e
ADVANCED PROGRAMMING
REFERENCES
[Link]. 2021. OOPS Concepts In Java with Examples. [online] Available at:
<[Link] [Accessed 21 March 2021].
Medium. 2021. What is a Singleton?. [online] Available at:
<[Link] [Accessed 21 March
2021].
Tutusfunny. 2021. Simple Pos with Bill Print Using Java and Mysql | Tutusfunny. [online]
Available at: <[Link]
[Accessed 21 March 2021].
[Link]. 2021. What is Class Diagram?. [online] Available at:
<[Link]
diagram/> [Accessed 21 March 2021].
[Link]. 2021. classifying-relationships-between-object-oriented-design-patterns. [online]
Available at: <[Link]
between-object-oriented-design-patterns> [Accessed 21 March 2021].
J/IT/19/15/05 32 | P a g e
ADVANCED PROGRAMMING
PLAGIARISM REPORT
J/IT/19/15/05 33 | P a g e