Assignment 3
Design Pattern
Mustafa Mohammad Ghazanfar 2011329
12/16/2013
Strategy Pattern:
Strategy pattern can be used in cases where behaviours of certain elements can be separated from other parts as independent processes. For example designing a strategy pattern for a car would result in multiple functions like brakes, boot, windows etc. All will have separate functions yet come together to complete the car. This pattern works by encapsulating all the functions as separately as possible and all the while keeping the client encapsulated from majority of the algorithm. The main advantage of this is weak coupling but the pattern also suggests that the client should have proper knowledge of the algorithm he wishes to change any part of it.
Iterator pattern
The iterator pattern is applied in scenarios where multiple repetitions are necessary for example an enrolment program where a list of thousands of students needs to be added to a database based a detail like a birthday. The Iterator pattern would be implemented to go through each student and each date to match the data after which it is added to the system. This pattern normally applies an Iterator that acts like a list for a program that does not favour decoupling and using a looping mechanism the whole list is traversed to serve a function. Its advantage is that it allows for large data processing through its lists, disadvantage the limited application i.e. many programs do not allow for decoupling in their algorithm.
Adapter Pattern
Adapter pattern is applied in situations where you are provided a class to be implemented into your code but the functions are called through different methods and variables. The functions remain the same in principle but need to be adapted to your current program. Like a real life adapter this pattern links what we have and what we need through clever function definition and interpretation. The main advantage is this allows the