代写代考 G6046 Software Engineering

G6046 Software Engineering
Seminar session: Class design
This exercise is designed to ensure that you understand:
 The concepts of cohesion, coupling and responsibility driven design

Copyright By PowCoder代写 加微信 powcoder

 How to apply these to an Object Oriented (OO) design problem.
Key concepts
Make sure you understand these basic OO concepts:
 Class: the organisational unit of an OO program. A class is used to represent a useful entity that forms part of a problem domain that we wish to model. A class can be broken down into state (attributes/fields) that describes what the class “is”, and behaviours (methods) that describe what the class “does”.
 Cohesion: the notion that a class models one entity and does it well. We aspire towards high cohesion.
 Coupling: the extent to which classes (and instances of classes – objects) interact with each other. We aspire towards low coupling.
 Responsibility driven design: the notion of considering what agent is responsible for storing some piece of data or performing some action when determining which class that functionality should reside in.
The Software Engineering examination paper routinely has an OO design question. The example in this session is drawn from a past paper.
You have been given an outline specification for a computer system to help manage stock for a new community upscaling facility.
“Margo and Barbara are starting a new community facility called ‘Bargo’ for upscaling and recycling household items. The idea is that members of the public can bring old sofas, chairs and electrical items that they no longer want and Bargo can then either restore the items and sell them for a profit or arrange for them to be disposed of in a safe and proper manner.
When someone donates an item to Bargo, they do not need to provide any identification. One of the Bargo team needs to record what the item is in the computer system. For sofas, they need to know how many people the sofa could seat, the condition rated from 1 (very poor) to 5 (excellent), the colour and the type of fabric. For chairs, we need the same data as sofas, except that all chairs only seat one person. For electrical items, we need a simple one line description of what the item is, the condition using the same rating system, and a record to show whether the item has been checked by an electrician to determine whether it is safe to use, as all unsafe electrical items need to be disposed of.
All items that are rated as 3 or better will be put up for sale. The computer system will need to identify which items in stock can be sold. Any item with a poorer rating, or deemed unsafe, must be disposed of. Each week, the computer system needs to produce a list of items to be disposed of. The sale items can be viewed by customers. In order to buy items at Bargo, customers need to open an

account. To do this they need to provide a name, address and an email address. Once they have opened an account, the computer system will keep a record of all purchases they make. A customer can also reserve an item for payment within 14 days. After 14 days, the item goes back to being on sale. For convenience, Bargo staff need to be able to recover data about customer reservations by using the customer name.”
Sketch out Java class definitions appropriate for coding this system. Describe the classes that will be needed and list the fields (public and/or private) and the methods that each class will need to implement. You do not need to provide any substantive source code for the classes, just their external interfaces and some outline of what they will require. You should show how your classes will interact together by means of a very high-level class diagram.
Several classes defined above will use collections of objects of other classes. Which of the available Java Collection types would be most appropriate for each of the collections? Give reasons for your choices.
Things to watch out for
 Consider how polymorphism can help (super/sub classes). This is a key feature of OO languages.
 Don’t confuse a class designed to represent a single thing with a collection class. Java allows for collections of any type.
 Aspire for high cohesion and low coupling.
A suggested model answer can be found on Canvas. There is no single right answer.
Dr Kingsley Sage Dr

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com