This document contains comprehensive notes from Lecture 15 of the CO2401 course on Software Development. The lecture focuses on Structural and Behavioral Design Patterns, which are essential tools for solving common software design problems in a flexible and reusable manner.
University of Central Lancashire Preston (UClan)
Unknown
Software Development (CO2401)
All documents for this subject (20)
Seller
Follow
BpoBpo
Reviews received
Content preview
CO2401: Software Development
Lecture 15
Structural Patterns
1. Composite Pattern
o Problem:
Used when an application’s model can be represented as a
tree structure, such as an order containing products packed
in boxes within boxes.
Challenge: Calculating the total price of such an order.
o Solution:
Use a common interface for both products and boxes, with a
method to calculate the total price.
For a product: Return its price.
For a box: Iterate over its contents, summing up prices,
including any additional costs like packaging.
2. When to Use:
o Implement a tree-like structure in your object model.
o Enable client code to treat simple and complex elements uniformly.
3. Pros and Cons:
o Benefits:
Simplifies working with complex tree structures.
Allows new element types to be added without breaking
existing code.
o Drawbacks:
Difficulty in providing a common interface for classes with
significantly different functionalities.
Adapter Pattern
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller BpoBpo. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $4.52. You're not tied to anything after your purchase.