Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

cs 342 homework details and summary, Lecture notes of Computer Science

Summary of the assignment of computer science

Typology: Lecture notes

2021/2022

Uploaded on 11/22/2023

rookie-mouse
rookie-mouse 🇺🇸

2 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Ashma Koirala
CS 342
11/01/23
For this homework, I used the Template Method design pattern to design a
Multi-app downloading application in JavaFX. The Template Method design pattern
allows you to define the skeleton of an object or algorithm in a superclass and lets
subclasses override methods or attributes without changing the superclasses structure.
In my example, I used an abstract class called Downloader to define the skeleton of
what a downloader should contain and created different download objects to overwrite
different methods which may differ between download objects. For example, my
program contained two different types of downloads, a Baccarat downloader and a
calculator downloader. These two objects differed in the way they’re downloaded
because the Baccarat downloader contained more files such as the game file, game
settings, and controller settings, whereas the calculator download only contained the
calculator application file itself. For this reason, only the initiateDownload method was
overwritten in each subclass while still containing the structure of the Downloader
superclass.
When it comes to the Template Method design pattern, there are some pros and
cons. One pro is that you are able to override parts of a larger algorithm without having
to change the other parts of the algorithm. Another pro is that you are able to use the
superclass to your advantage to ensure that you can reuse code which may stay the
same throughout the subclasses. The Template Method design pattern also enforces
structure throughout similar objects, which indirectly improves the organization of code.
Some cons to this design pattern is that it may get harder to maintain the sequence of
code as your superclass becomes more widely used. This can make you start
implementing methods of the superclass that aren’t needed throughout objects, making
it harder to maintain the structure of the superclass.
In summary, although the Template Method design pattern may be hard to
maintain structure as it is more widely used, it is a great design pattern for related
pf2

Partial preview of the text

Download cs 342 homework details and summary and more Lecture notes Computer Science in PDF only on Docsity!

Ashma Koirala CS 342 11/01/ For this homework, I used the Template Method design pattern to design a Multi-app downloading application in JavaFX. The Template Method design pattern allows you to define the skeleton of an object or algorithm in a superclass and lets subclasses override methods or attributes without changing the superclasses structure. In my example, I used an abstract class called Downloader to define the skeleton of what a downloader should contain and created different download objects to overwrite different methods which may differ between download objects. For example, my program contained two different types of downloads, a Baccarat downloader and a calculator downloader. These two objects differed in the way they’re downloaded because the Baccarat downloader contained more files such as the game file, game settings, and controller settings, whereas the calculator download only contained the calculator application file itself. For this reason, only the initiateDownload method was overwritten in each subclass while still containing the structure of the Downloader superclass. When it comes to the Template Method design pattern, there are some pros and cons. One pro is that you are able to override parts of a larger algorithm without having to change the other parts of the algorithm. Another pro is that you are able to use the superclass to your advantage to ensure that you can reuse code which may stay the same throughout the subclasses. The Template Method design pattern also enforces structure throughout similar objects, which indirectly improves the organization of code. Some cons to this design pattern is that it may get harder to maintain the sequence of code as your superclass becomes more widely used. This can make you start implementing methods of the superclass that aren’t needed throughout objects, making it harder to maintain the structure of the superclass. In summary, although the Template Method design pattern may be hard to maintain structure as it is more widely used, it is a great design pattern for related

objects which contain similar parts within an algorithm, allowing you to reuse code and only change parts that may differ within their subclasses.