daad project “joint course on oop using java” on object oriented modeling in java (why &...
TRANSCRIPT
DAAD project “Joint Course on OOP using Java”
On Object Oriented modeling in Java On Object Oriented modeling in Java (Why & How)(Why & How)
Ana Madevska BogdanovaAna Madevska Bogdanova
Institute of informaticsInstitute of informaticsFaculty of Natural Sciences and MathematicsFaculty of Natural Sciences and Mathematics
Skopje, MacedoniaSkopje, Macedonia
DAAD project „Joint Course on OOP using Java“ © 2
AgendaAgenda
The motivation The need of introducing design patterns in
the first year of studies Incorporation in the concepts of the existing
OOP course Expected results
DAAD project „Joint Course on OOP using Java“ © 3
The motivationThe motivation
To start earlier with Java (DSA will improve) To introduce design patterns in OOP
DAAD project „Joint Course on OOP using Java“ © 4
The motivationThe motivation
The first two courses • Structured programming• Object oriented and visual programming
C++ is the represent of a OOP language The second course
• Encaptulation• Inheritance• Polymorphism
DAAD project „Joint Course on OOP using Java“ © 5
Where is Java in the curriculum?Where is Java in the curriculum?
Java is in the course Data Structures and Algorithms• Third semester• The course is too much• Introductory level of Java while listening to the
theory about Data structures
Discrepancy between programming the data structures and the theory
Solution?
DAAD project „Joint Course on OOP using Java“ © 6
The solutionThe solution
We will introduce Java in the second semester within the course OO programming• The students are ready to start to program data
structures immediately within the course DSA• No discrepancy
DAAD project „Joint Course on OOP using Java“ © 7
AgendaAgenda
The motivationThe need of introducing design
patterns in the first year of studies Incorporation in the concepts of the existing
OOP course Expected results
DAAD project „Joint Course on OOP using Java“ © 8
Another existing problem…Another existing problem…
Thinking in the design pattern level Introduced in the course of software
engineering in the 5th semester• Software design and architecture
In the first two programming courses the students mind is focused only on technical clarity in developing the OO system
DAAD project „Joint Course on OOP using Java“ © 9
Idea – introduce design patterns in the Idea – introduce design patterns in the first semesterfirst semester
In the OO programming course we can introduce some problems and discuss them with the students
• How to create OO model – to go through the process OO modeling
DAAD project „Joint Course on OOP using Java“ © 10
Why do that?Why do that?
Till now• We give them ready OO model and ask the
students to program it and use- Encaptulation- Polymorphism- Inheritance
New idea• Ask the students to BUILD the OO model for a
given problem• To broaden their point of view for the proper
programming• To be ready to learn more design patterns in the
latter courses
DAAD project „Joint Course on OOP using Java“ © 11
The levelsThe levels
1. OO basics• encapsultion, polymorphism, inheritance
2. OO principles 3. OO patterns
• 1. Strategy- Defines a family of algorithms, encapsulates each
one, and makes them interchangable- let the algorithm vary independently from clients
that use it
DAAD project „Joint Course on OOP using Java“ © 12
Why design patterns?Why design patterns?
This is what the students should learn in the first year of their studies.
Students learn that applying design patterns is like reusing experience. One can apply successful patterns to develop new software without reinventing new solution strategies.
DAAD project „Joint Course on OOP using Java“ © 13
How to do that?How to do that?
Teach Java course- Encaptulation- Polymorphism- Inheritance
Go further• Introduce a design pattern• Give a problem
- Start with straightforward model- Change something- Remodeling- … solution would be one of the design patterns
DAAD project „Joint Course on OOP using Java“ © 14
AgendaAgenda
The motivation The need of introducing design patterns in
the first year of studies Incorporation in the concepts of the existing
OOP course Expected results
DAAD project „Joint Course on OOP using Java“ © 15
The idea is to learn ONE design pattern Starting from scratch Choosing interesting problem
• Discuss with the students every step of developing the model by putting different subproblems as new requirements for the model
• The model must develop with the new requirements
DAAD project „Joint Course on OOP using Java“ © 16
1. The strategy pattern1. The strategy pattern
The idea is to guide the student through the process of implemeting the right Pattern Design to create the right OO model for the given problem.
Along the way they will understand the main OO principles - why to develop the software in that particular way1. Encapsulate what varies2. Program to interfaces, not implementation3. Favor composition over inheritance
DAAD project „Joint Course on OOP using Java“ © 17
Simple problemSimple problem
We chose a simple problem To explain the students that the only thing
that we can be certain about - is the change in every software development
No matter how well one designs an appliication, it must grow and develop over time
So, the first design pattern is about flexibility in the OO model
DAAD project „Joint Course on OOP using Java“ © 18
Inheritance?Inheritance?
To point the student that inheritance doesn’t always work well• Request - the behavior keeps changing across
the subclasses, and it is not appropriate every subclass to have that behavior.
DAAD project „Joint Course on OOP using Java“ © 19
The FIRST design principleThe FIRST design principle
Part of code that changes• New requirements• It is a behavior that should be parted from the rest
of the code
SO, the students should identify the aspects of the application that vary and separate them from the parts that don‘t change• “encapsulate “ it so it won‘t affect the rest of
the code
The result is• Less unintended consequences when changing the
code• More flexibility in the system
DAAD project „Joint Course on OOP using Java“ © 20
The SECOND design principle The SECOND design principle
We introduce another design principleProgram to an interface, not the
implementation The different behaviors will live in a
separate classes That way, the classes won‘t need to know
any of the implementation details for their own behaviors
DAAD project „Joint Course on OOP using Java“ © 21
The realizationThe realization
We will use an interface to represent each behavior and each implementation of the behavior will implement one of those interfaces.
Program to an interface really means program to a supertype
The concept of interface must not to be mixed up with the JAVA construct interface .
You can program to an interface, withouth using the actual construct interface.
We want to exploit polymorphism
DAAD project „Joint Course on OOP using Java“ © 22
Another difference with the current OOP Another difference with the current OOP coursecourse
We also plan to extend the knowledge of the students about the class relations in order to build more flexible models
Discovering class relations• Association
• Aggregation and Composition
• Inheritance(revisited)
DAAD project „Joint Course on OOP using Java“ © 23
Has-A can be better that Is-AHas-A can be better that Is-A
The THIRD design principle Instead of inheriting a certain behavior, the
objects get their behavior by composing with the right behavior object.
The students learn the third design principle• …favor composition over inheritance• …creating systems using composition provides a
great deal of flexibility.
DAAD project „Joint Course on OOP using Java“ © 24
AgendaAgenda
The motivation• To start earlier with Java (DSA will improve)• introducing design patterns
The need of introducing design patterns in the first year of studies
Incorporation in the concepts of the existing OOP course
Expected results
DAAD project „Joint Course on OOP using Java“ © 25
Expected results of introducing JAVA and Expected results of introducing JAVA and design patterns in JAVAdesign patterns in JAVA
As mentioned in the motivation part• More prepared students to embrace the higher
level of producing OO modeling early - in their first OO course
• They will be ready to learn more OO design patterns in the latter courses
• Ready to develop OO models on their own in the different courses in the latter semesters.
• learning JAVA in this course will make DSA course more comprehendible in the third semester- Students wouldn't have to learn the basics of
JAVA, they will use it for simulating data structures covered with the course