Sadp m2
Sadp m2
Module-2
Analysing a System
2.1 Overview of the Analysis Phase
The major goal of this phase is to address this basic question: what should the system do?
Requirements are often simple and any clarifications can be had via questions in the classroom,
e- mail messages, etc.
However, as in the case of the classroom assignment, there are still two parties: the user community,
which needs some system to be built and the development people, who are assigned to do the work.
It is not always the case that these activities occur in the order listed.
The purpose of requirements analysis is to define what the new system should do. Since the system
will be built based on the information garnered in this step, any errors made in this stage will result
in the implementation of a wrong system. Once the system is implemented, it is expensive to modify
it to overcome the mistakes introduced in the analysis stage.
Imagine the scenario when you are asked to construct software for an application. The client may
not always be clear in his/her mind as to what should be constructed.
First reason for this is that it is difficult to imagine the workings of a system that is not yet built.
Second reason Incompleteness and errors in specifications can also occur because the client does
not have the technical skills to fully realize what technology can and cannot deliver
Third reason for omissions is that it is all too common to have a client who knows the system
very well and consequently either assumes a lot of knowledge on the part of the analyst or simply
skips over the ‘obvious details’.
Let us proceed under the assumption that developers of our library system have available to them a
document that describes how the business is conducted. This functionality is described as a list of
what are commonly called business processes.
In addition, the system must support three other requirements that are not directly related to the
workings of a library, but, nonetheless, are essential.
• A command to save the data on a long-term basis.
• A command to load data from a long-term storage device.
• A command to quit the application. At this time, the system must ask the user if data is to be saved
before termination.
A real library would have to perform additional operations like generating reports of various
kinds, impose fines for late returns, etc.
Many libraries also allow users to check out books themselves without approaching a clerk.
Whatever the case may be, the analysts need to learn the existing system and the
requirements. As mentioned earlier, they achieve this through interviews, surveys, and study.
Use Case Analysis: It is a powerful technique that describes the kind of functionality that a user expects
from the system.
It is essentially a narrative describing the sequence of events (actions) of an external agent (actor)
using the system to complete a process.
It is a powerful technique that describes the kind of functionality that a user expects from the
system.
Use cases have two or more parties: agents who interact with the system and the system itself.
To initiate this process, we need to get a feel for how the system will interact with the end-user. We
assume that some kind of a user-interface is required, so that when the system is started, it provides a
menu with the following choices:
1. Add a member
2. Add books
3. Issue books
4. Return books
5. Remove books
6. Place a hold on a book
7. Remove a hold on a book
8. Process Holds: Find the first member who has a hold on a book
9. Renew books
10. Print out a member’s transactions
11. Store data on disk
12. Retrieve data from disk
13. Exit
Steps:
1 Member will give the details of name, address, phone number to the clerk
2 Clerk process the request through the system
3 System asks the details of the customer to be registered.
4 Clerk enters the necessary information of the member into the system.
5 System check the details of the member and if the member is a valid person, then generates member
identification number and display the necessary information at the output
6 Clerk provides the identification number to the user.
Steps:
1 Library receives the information about the books shipped from the publisher.
2 Clerk receives a request to process the addition of books to the catalog.
3 System asks the details of the identifier, title, and author name of the book to be added.
4 Clerk generates the necessary information of the book to be added into the system.
5 System adds the details of the book and displays the necessary information of the book at the output
and asks for any more books to be added.
6 If clerk replies affirmative, then same procedure is followed for the next set of books to be added.
Otherwise system quits the application.
Steps:
1 Member gives the set of books with the member identification number to the clerk at the
checkout counter and requests clerk to check out the books.
2 Clerk receives a request to check out the books and start checking in the system.
3 System asks the details of the user ID.
4 Clerk enters the user ID
5 System asks the details of the book ID.
6 Clerk enters the ID of the book to be checked out.
7 i) System checks whether the member possesses the book and generates a due date.
ii) System displays the book title, due date and asks if there is any more books to be processed
8 Clerk stamps due date on the book say yes, if there are books to be checked out. Otherwise no
when there are no books to be processed.
9 If yes, system continues to process from step 5 and asks only for book ID since customer ID is
same, otherwise system exits.
10 Customer collects the books and leave the checkout counter
Steps:
1 Member gives the set of books with the member identification number to the clerk at the checkout
counter and requests clerk to check out the books.
2 Clerk receives a request to check out the books and start checking in the system.
3 System asks the details of the user ID.
4 Clerk enters the user ID
5 System asks the details of the book ID.
6 Clerk enters the ID of the book to be checked out.
7 i) System checks whether the member is a valid person or not and then records the member has a
possession on the book and generates a due date based on the result of Rule 1.
ii) System displays the book title and due date.
iii) The system displays error message, if the Rule 2 is not satisfied and asks if there is any more
books to be processed.
8 i) Clerk stamps due date on the book and take the print out of the transactions, if the user is
requesting for print out.
ii) Clerk says yes, if there are books to be checked out. Otherwise no when there are no books to be
processed.
9 If yes, system continues to process from step 5 and asks only for book ID since customer ID is same,
otherwise system exits.
10 Customer collects the books and leave the checkout counter
Steps:
1. Member gives the set of books to be returned to the clerk at the checkout counter.
2. On receiving the request, clerk process the return books request in the system.
3. System asks the details of the book ID.
4. Clerk enters the ID of the book to be returned.
5. i) System checks whether the book is valid or not and then records that book is returned.
ii) System informs the clerk about the deadline of the book to be returned and asks clerk that if any
more books are to be returned.
6. i) Clerk says yes, if there are books to be returned, Otherwise no when there are no books to
be returned.
ii) Clerk checks the deadline of the book to be returned based on Rule 5.
7. If yes, system continues to process from step 3, otherwise system exits.
Steps:
Steps:
1 The clerk receives a request from the user to give member transactions
2 The system asks for the user ID of the member and the date for which the transactions are required.
3 The clerk enters the ID of the user and the date of the transactions required
4 If the ID is valid, the system outputs information about all transactions completed by the user on the
given date along with the details of book borrowed, book returned, hold placed and the title of the
book.
5 Clerk prints out the transactions and hands them to the user
Steps:
Steps:
Steps:
1 On receiving the request, clerk start processing to place a hold as per Rule 5 by notifying the
member who crosses the deadline.
2 The system asks book ID
3 The clerk enters book ID
4 i) The system checks for the hold whether it is expired or not
ii) If yes, the system records that there is no hold and ask for next books to be processed
5 i) If there is no hold, the book is then kept back to its designated location in the library and no
notification generated.
ii) Clerk replies the system yes or no for the next books to be processed
6 If the answer is yes, the system goes to Step 2; otherwise it exits
Steps:
The last major step in the analysis phase involves the determination of the conceptual classes and the
establishment of their relationships. Example, in the library system, some of the major conceptual classes
include members and books. Members borrow books, which establish a relationship between them.
1 Design facilitation: Via use case analysis, we determine the functional requirement of the system.
Obviously, the design stage must determine how to implement the functionality. For this, the designers
should be in a position to determine the classes that need to be defined, the objects to be created, and
how the objects interact. This is better facilitated if the analysis phase classifies the entities in the
application and determines their relationships.
2 Added knowledge: The use cases do not completely specify the system. Some of these missing details
can be filled in by the class diagram.
3 Error reduction: In carrying out this step, the analysts are forced to look at the system more carefully.
The result can be shown to the client who can verify its correctness.
4 Useful documentation: The classes and relationships provide a quick introduction to the system for
someone who wants to learn it. Such people can join the project to carry out the design or
implementation or subsequent maintenance of the system.
While using this approach, we must remember that natural languages are imprecise and that synonyms
may be found. We can eliminate the others as follows:
User: The library refers to members alternatively as users, so this is also a synonym.
Application form and request: Application form is an external construct for gathering
information, and request is just a menu item, so neither actually becomes part of the data
structures. Customer’s name, address, and phone number: They are attributes of a customer, so
the Member class will have them as fields.
Clerk: An agent for facilitating the functioning of the library, so it has no software
representation.
UML Diagram
(Unified Modeling Language Diagram)
In the above figure, system implies a conceptual class that represents all of the system.
This class is Library UML without any attributes and methods.
Figure 2.4 UML diagram showing the association of Library and Member
Figure 2.6 UML diagram showing the association of Library and Book
Figure 2.7 UML diagram showing the association Borrows between Member and Book
Figure.2.8 UML diagram showing the association Holds between Member and Book
All the conceptual classes and their associations are captured into a single diagram. To reduce complexity,
attributes of the Library, Member, and Book are omitted. As seen before, a relationship formed between
two entities is sometimes accompanied by additional information. This additional information is relevant
only in the context of the relationship.
Domain analysis is the process of analysing related application systems in a domain so as to discover what
features are common between them and which parts are variable. Thus, one of the goals of this approach is
reuse.
Examples include library systems, hotel reservation systems, university registration systems, etc. It is possible
to divide a domain into several interrelated domains.
Where does the knowledge of a specific domain come from? It could be from sources such as surveys,
existing applications, technical reports, user manuals, and so on.
A domain analyst analyses this knowledge to come up with Specifications, designs, and code that can be
reuse in multiple projects
The main UML tool employed here is the sequence diagram. In a sequence diagram, the designer specifies
the details of how the behaviour specified in the model will be realized. This process requires the system’s
actions to be broken down into specific tasks, and the responsibility for these tasks to be assigned to the
various players in the system.
Design
During the design process, a number of questions need to be answered:
7 Will the system use multiple computers? If so, what are the issues related to data and code
distribution?
Major subsystems
The first step in our design process is to identify the major subsystems. We can view the library system as
composed of two major subsystems:
1 Business logic: This part deals with input data processing, data creation, queries, and data updates.
This module will also be responsible for interacting with external storage, storing and retrieving data.
2 User interface: This subsystem interacts with the user, accepting and outputting information. It is
important to design the system such that the above parts are separated from each other so that they can
be varied independently.
The next step is to create the software classes. During the analysis, after defining the use case model,
We came up with a set of conceptual classes and a conceptual class diagram for the entire system.
In this phase there are two major activities.
1. Come up with a set of classes.
2. Assign responsibilities to the classes and determine the necessary data structures and methods.
In general, it is unlikely that we can come up with a design simply by doing these activities exactly once.
Several iterations may be needed and classes may need to be added, split, combined, or eliminated.
Library: Do we really need to make a class for this? To answer the question, let us ask what real library.
When a member thinks of a library, he/she thinks of borrowing and returning books, placing and removing
holds, i.e., the functionality provided by the library.
Borrows: This class represents the one-to-many relationship between members and books. In typical one-
to-many relationships, the association class can be efficiently implemented as a part of the two classes at the
two ends.
Holds: Unlike Borrows, this class denotes a many-to-many relationship between the Member and Book
classes. In typical many-to-many relationships, implementation of the association without using an
additional class is unlikely to be clean and efficient.
Sequence diagrams
Describe interactions among classes in terms of an exchange of messages over time.
User Interface
1 Add a member
2 Add books
3 Issue books 4 Return books
4 Renew books
5 Remove books
6 Place a hold on a book
7 Remove a hold on a book
8 Process holds
9 Print a member’s transactions on a given date
10 Save data for long-term storage
11 Retrieve data fromstorage
12 Help
13 Exit
1 In this phase, we code, test, and debug the classes that implement the
business logic (Library, Book, etc.) and UserInterface.
2 An important issue in the implementation is the communication via the
return values between the different classes: in particular between Library and
UserInterface.
Issuing Books
public void issueBooks() { Book result;
String memberID = getToken("Enter member id"); if
(library.searchMembership(memberID) == null) {
System.out.println("No such member"); return;
}
do {
String bookID = getToken("Enter book id"); result = library.issueBook(memberID,
bookID); if (result != null){
System.out.println(result.getTitle()+ " " + result.getDueDate());
} else {
System.out.println("Book could not be issued");
}
if (!yesOrNo("Issue more books?")) {
break;
}
} while (true);
}
The issueBookmethod in Librarydoes the necessary processing and returns a reference to the issued
book.
public Book issueBook(String memberId, String bookId) { Book book = catalog.search(bookId);
if (book == null) { return(null);
}
if (book.getBorrower() != null) { return(null);
}
Member member = memberList.search(memberId); if (member == null) {
return(null);
}
if (!(book.issue(member) && member.issue(book))) { return null;
}
return(book);
}
Printing Transactions
To process a hold, Libraryinvokes the getNextHold method in Book, which returns the first valid hold.
Java Serialization
• Our approach to long-term storage of the library data uses the Java serialization mechanism.
• In our Current example, Book and Hold can be serialized by simply declaring them to be
Serializable.
The Library, MemberList and Catalog objects are singletons: they cannot have more than one instance. Using
the serialization mechanism, it is now possible to serialize an object and then deserialize it to get a second
instance.
Library library = Library.instance(); Serialize library onto a disk file "library1";
Library library2 = Deserialized version of "library1"; Update library (add a member);
Update library2 (delete a book);
Converting the model into a working design is the most complex part of the software design process.
The sequence of topics so far suggests that the design would progress linearly from analysis to design to
implementation.
Conceptual, Software and Implementation Classes:
Finding the classes is a critical step in the object-oriented methodology. In the analysis phase, we found the
conceptual classes. These correspond to real- world concepts or things, and present us with a conceptual or
essential perspective.
As we go further into the design process and construct the sequence diagrams, we need to deal with the
issue of these conceptual classes. we are now dealing with software classes.
The last step is the implementation class, which is a class created using a specific programming language
such as Java or C++. The last step is the implementation class, which is a class created using a specific
programming language such as Java or C++.
The Facade Pattern: Library class that provided a set of methods for the interface and thus served as a single
point of entry to and exit from the business logic module. In the language of design patterns, what we created
is known as a facade.
• The primary motivation behind using a façade is to reduce the complexity by minimizing
communication and dependencies between a subsystem and its clients . The facade not only shields
the client from the complexity but also enables loose coupling between the subsystem and its clients.
Facades are not typically designed to prevent the client from accessing the components within the
subsystem.
Using a Facade
Where do we employ this? A situation in which we have:
1. A system with several individual classes, each with its own set of public methods.
2. An external entity interacting with the system requires knowledge of the public
methods of several classes.
Note: Explanation for sequence diagrams can be referred from use case analysis.