

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Summary of the assignment of computer science
Typology: Lecture notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!
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.