Assignment 2 Software Engineering Fall 2021 Due Date Thursda
Assignment 2software Engineeringfall 2021due Date Thursday October 1
In this assignment, you will learn how to apply design patterns to solve problems in software components design.
You will work with one partner. The assignment involves providing solutions to four problems, each requiring selecting appropriate design patterns and creating class diagrams to structure the solutions.
Paper For Above instruction
Introduction
Design patterns are essential tools in software engineering, enabling developers to create flexible, reusable, and maintainable code. This assignment explores how specific design patterns can be applied to real-world problems involving vehicle customization, document processing, shipping cost calculation, and media inventory management.
Problem 1: Vehicle Customization with Seats
The first problem involves a manufacturing company that produces various vehicle types—cars, boats, and buses—with different seat options: luxury, leather, and cloth seats. The seats are supplied by three providers: Provider A, B, and C. Any vehicle may have any seat type from any provider, and a control unit (client code) can create vehicles based on manager requests.
To address this, the Factory Method and Abstract Factory patterns are most suitable. The Factory Method pattern allows for creating objects without specifying the exact class, while the Abstract Factory pattern enables creating families of related objects—in this case, seat types from different providers—without altering the client code.
Applying the Abstract Factory pattern, we can define an abstract factory interface to produce seats, with concrete factories for each provider. Vehicles will then accept a seat factory and use it to add seats accordingly. The class diagram includes:
- Vehicle: Abstract class or interface with subclasses Car, Boat, Bus.
- Seat: Abstract class with subclasses LuxurySeat, LeatherSeat, ClothSeat.
- SeatFactory: Interface with method createSeat().
- ProviderAFactory/BFactory/CFactory: Concrete factories implementing SeatFactory, returning specific seat instances.
Problem 2: Smart Control Unit for a Printer
The second problem involves designing a smart control unit for a printer that handles documents of types PDF, MS Word, and JPG. The system maintains a queue of print jobs and supports two operations: adding colored frames and backgrounds. Clients should be able to perform any operation on jobs and extend functionality as needed.
The Proxy and Command patterns are suitable here. The Command pattern encapsulates operations as objects, allowing flexible addition of new operations. The Proxy pattern can be used to manage access or enhance functionality (e.g., queuing, logging).
Using the Command pattern, we define an Operation interface with a method execute(), with concrete classes like AddFrameOperation and AddBackgroundOperation. The print jobs implement an interface or base class, enabling operations to be applied uniformly.
The class diagram includes:
- PrintJob: Interface or base class for document types, with concrete implementations PDF, MSWord, JPG.
- Operation: Interface with execute(PrintJob).
- AddFrameOperation and AddBackgroundOperation: Concrete implementations of Operation.
- PrintQueue: Manages collection of PrintJobs and applies Operations.
Problem 3: Shipping Cost Calculation
The third problem involves computing shipping costs based on destination—local, domestic, international—with different handling and delivery mechanisms for each. Handling is performed by company employees, contractors, or airplane staff; delivery is by car, train, or airplane.
The Strategy pattern fits this scenario, allowing selection of handling and delivery algorithms at runtime. Additionally, combining Factory Method for creating specific handling and delivery objects enhances modularity.
The class diagram may include:
- ShippingCostCalculator: Context class.
- HandlingStrategy: Interface, with concrete strategies EmployeeHandling, ContractorHandling, AirlineHandling.
- DeliveryStrategy: Interface, with concrete strategies CarDelivery, TrainDelivery, AirplaneDelivery.
- DestinationType: Enumeration or set of constants for local, domestic, international.
Problem 4: Video Store Management
The fourth problem describes a video store stocking tapes, CDs, and DVDs, with unique features such as bar coding, reservations, and querying stock availability. The system must facilitate rentals, returns, sales, and inventory queries, with a flexible search engine.
The design pattern combining Singleton, for the inventory management, Factory Method, for item creation, and Observer, for managing reservations and stock updates, would be appropriate. The Adapter pattern helps integrate scanning machinery.
The class diagram would include:
- MediaItem: Abstract class with subclasses Tape, CD, DVD.
- Inventory: Singleton class managing stock.
- Reservation: Class representing customer reservations.
- SearchEngine: Component with flexible querying capabilities.
Conclusion
Applying the appropriate design patterns ensures that software components are flexible, extendable, and easier to maintain. The patterns discussed—Abstract Factory, Command, Strategy, Singleton, and others—provide robust structures for solving complex design problems encountered in real-world applications such as vehicle customization, document processing, shipping, and media inventory management. These examples demonstrate the importance of understanding and implementing design patterns appropriately to create scalable and adaptable software systems.
References
- Gamma, E., Helm, R., Johnson, R., & Vlissides, J. (1994). Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley.
- Beck, K., & Andres, C. (2004). Extreme Programming Explained: Embrace Change. Addison-Wesley.
- Pressman, R. S. (2014). Software Engineering: A Practitioner's Approach. McGraw-Hill Education.
- Martin, R. C. (2008). Clean Code: A Handbook of Agile Software Craftsmanship. Prentice Hall.
- Buschmann, F., et al. (1996). Pattern-Oriented Software Architecture, Volume 1: A System of Patterns. Wiley.
- Shalloway, A., & Stroback, J. R. (2007). Design Patterns Explained: A New Perspective on Object-Oriented Design. Addison-Wesley.
- Fowler, M. (2003). UML Distilled: A Brief Guide to the Standard Object Modeling Language. Addison-Wesley.
- Johnson, R., & Vlissides, J. (1993). Pattern Languages of Program Design. Addison-Wesley.
- LePorte, N. (2016). Applying Design Patterns in Software Engineering. Journal of Software Development, 10(2), 35-44.
- Larman, C. (2004). Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development. Prentice Hall.