AP Assignment
AP Assignment
2020
ADVANCED
PROGRAMMING
ASSIGNMENT
TO
LECTURUER
Mr.A.R.A.RUJAHN
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.
J. Konsikan
CSD-15
J/IT/19/15/05
J/IT/19/15/05 2|Page
ADVANCED PROGRAMMING
CONTENTS
INTRODUCTION .................................................................................................................. 5
REFERENCES ................................................................................................................... 32
J/IT/19/15/05 3|Page
ADVANCED PROGRAMMING
LIST OF FIGURES
FIGURE 1 PROGRAMMING................................................................................................................... 6
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
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.
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 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
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.
J/IT/19/15/05 8|Page
ADVANCED PROGRAMMING
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:
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
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.
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.
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:
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.
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.
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.
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.
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.
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.
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
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.
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.
▪ 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
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.
▪ 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
This pattern uses an interface as a bridge, separating the functionality of concrete classes
from the functionality of interface implementer classes.
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.
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
J/IT/19/15/05 21 | P a g e
ADVANCED PROGRAMMING
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.
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 and.NET 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.
https://bitbucket.org/Konsikan/advanced_programming/src/master/LearningOutcome1
J/IT/19/15/05 22 | P a g e
ADVANCED PROGRAMMING
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.
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.
▪ Class Name
▪ Attributes
▪ Operations
J/IT/19/15/05 23 | P a g e
ADVANCED PROGRAMMING
▪ 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.
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.
J/IT/19/15/05 24 | P a g e
ADVANCED PROGRAMMING
https://bitbucket.org/Konsikan/advanced_programming/src/master/LearningOutcome2
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
https://bitbucket.org/Konsikan/advanced_programming/src/master/LearningOutcome3
J/IT/19/15/05 26 | P a g e
ADVANCED PROGRAMMING
▪ 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:
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.
DAO IMPLEMENTATION
J/IT/19/15/05 28 | P a g e
ADVANCED PROGRAMMING
Figure 24 HOME
LOGIN FORM
J/IT/19/15/05 29 | P a g e
ADVANCED PROGRAMMING
DASHBOARD VIEW
J/IT/19/15/05 30 | P a g e
ADVANCED PROGRAMMING
BILLING RECEIPT
J/IT/19/15/05 31 | P a g e
ADVANCED PROGRAMMING
REFERENCES
Hackr.io. 2021. OOPS Concepts In Java with Examples. [online] Available at:
<https://hackr.io/blog/oops-concepts-in-java-with-examples> [Accessed 21 March 2021].
Tutusfunny. 2021. Simple Pos with Bill Print Using Java and Mysql | Tutusfunny. [online]
Available at: <https://www.tutussfunny.com/simple-pos-with-bill-print-using-java-and-mysql/>
[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