Professional Documents
Culture Documents
MODULE 6
Computer Programming (Java) – Grade 12
Quarter 3 – Module 6: Object Oriented Design Principles in Java
Republic Act 8293, Section 176 states that no copyright shall subsist in any
work of the Government of the Philippines. However, prior approval of the
government agency or office wherein the work is created shall be necessary for
exploitation of such work for profit. Such agency or office may, among other things,
impose as a condition the payment of royalties.
This learning material hopes to engage the learners in guided and independent
learning activities at their own pace and time. Further, this also aims to help learners
acquire the needed 21st century skills especially the 5 Cs, namely: Communication,
Collaboration, Creativity, Critical Thinking, and Character while taking into
consideration their needs and circumstances.
In addition to the material in the main text, you will also see this box in the
body of the module:
As a facilitator you are expected to orient the learners on how to use this
module. You also need to keep track of the learners' progress while allowing them to
manage their own learning. Moreover, you are expected to encourage and assist the
learners as they do the tasks included in the module.
For the Learner:
This module was designed to provide you with fun and meaningful
opportunities for guided and independent learning at your own pace and time. You
will be enabled to process the contents of the learning material while being an active
learner.
Posttest - This measure how much you have learned from the
entire module.
EXPECTATIONS
PRETEST
DIRECTIONS: Identify the following Object Oriented Design Principle. Write your
answer on the space provided.
__________ 1. This principle states that there should never be two functionalities in
one class.
__________ 2. This principle is closely related to The Interface Segregation Principle
and The Single Responsibility Principle.
__________ 3. This design principle is no duplication of code and pretty easy to modify
behaviour.
__________ 4. This object oriented design principle which prevents someone from
changing already tried and tested code.
__________ 5. These are generalized pieces of advice or proven good coding practices
that are used as rules of thumb when making design choices.
RECAP
DIRECTIONS: On the space provided, discuss and enumerate what you have learned
from the previous lesson.
LESSON
Design patterns are also abstractions or generalized good practices, but they
provide much more concrete and practical low-level advice, and are related to entire
classes of problems rather than just generalized coding practices. Some of the most
important design principles in the object oriented paradigm are listed below:
There should not be more than one reason for a class to change or a class
should always handle single functionality. If you put more than one functionality in
one Class in Java it introduce coupling between two functionality and even if you
change one functionality there is chance you broke coupled functionality which
require another round of testing to avoid any surprise on production environment.
One should often prefer composition over inheritance when designing their
systems. In Java, this means that we should more often define interfaces and
implement them, rather than defining classes and extending them.
The Interface Segregation Principle (ISP) states that the client should never be
forced to depend on an interface they aren't using in its entirety. This means that an
interface should have a minimum set of methods necessary for the functionality it
ensures, and should be limited to only one functionality.
Always program for interface and not for implementation this will lead to
flexible code which can work with any new implementation of interface. So use
interface type on variables, return types of method or argument type of methods in
Java.
Delegation Principle
RUBRICS:
10 8 5 1
The program The program The program The program
showed at least 5 showed 3 different showed only 2 showed none of
different Design Design Principle different Design any of the Design
Principle and has and somewhat Principle and Principle and no
explanation complete incomplete explanation
explanation
WRAP-UP
DIRECTIONS: Answer the following questions below, and write your answer in the
space provided.
1. Based on what you have learned in this lesson, what do you think is importance
of Design Principle in your program? What makes it easier to do something when
you follow the Principles?
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
POST-TEST
_________ 1. Do all the stuff by yourself and do not delegate it to the other class.
_________ 2. One should often prefer composition over inheritance when designing
their systems.
_________ 3. The acronym “DRY” in the Object Oriented design Principles means
Don’t Ruin Yourself.
_________ 4. The design principle are more abstract and generalized.
_________ 5. The Interface Segregation Principle (ISP) states that the client should
be forced to depend on an interface they are using in its entirety.
KEY TO CORRECTION
5. Design Principles 5. FALSE
4. The Open/Closed Principle 4. TRUE
3. The Delegation Principle 3. FALSE
2. Liskov Substitution Principle 2. TRUE
1. The Single Responsibility Principle 1. FALSE
PRE TEST POST TEST
References
Websites:
10 Object-Oriented (OOP) Design Principles Java Programmers Should Know,
Accessed January 11, 2021, 02:15:45 PM, shorturl.at/ikCG5
Object Oriented Design Principles in Java, Accessed January 12, 2021, 11:05:13
AM, https://stackabuse.com/object-oriented-design-principles-in-java/