联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codehelp

您当前位置:首页 >> Java程序Java程序

日期:2020-11-24 08:58

Page 1 of 9 COS
1802/159.251
MTUI DISD
MASSEY UNIVERSITY
MANAWATU AND DISTANCE CAMPUSES
EXAMINATION FOR
159.251 SOFTWARE ENGINEERING DESIGN AND CONSTRUCTION
SEMESTER TWO 2018
_________________________________________________________________________________________________________
Time allowed is THREE (3) Hours.
This paper contains EIGHT (8) questions
Candidates must answer ALL EIGHT (8) questions
Questions are not of equal marks
Write your answers to all applicable questions in the Blue Answer Book supplied
Students may NOT remove any part of this question paper from the exam room.
The exam paper will be made available on the University Library website.
Page 2 of 9 COS
Question 1 – Design and DRY [8 marks]
Assume you have to design a student registration system for an university. In this system,
students are represented as instances of a class Student with several properties (id,
firstName, lastName, dob). A desktop graphical user interface (GUI) for this application is
provided by the class StudentEditor, and instances of Student are stored as xml
documents using a structure defined by the XML schema students.xsd.
a) For this kind of application, a design based on tiers (layers) is often used. Name the
tiers (layers) you would here, and describe the dependencies between these tiers !
[3 marks]
b) At some stage, a new boolean attribute isExtramural must be added to the Student
class. This will also require changes to the schema and the editor (form)
StudentEditor (a new text field must be added). Discuss the DRY principle using
this example, and which technologies can be used to facilitate this kind of change.
[3 marks]
c) Later, your client decides to change the application by providing a web-based user
interface. Using your answer to a) , describe the benefits of the tiered (layered)
design to facilitate this.
[2 marks]
Page 3 of 9 COS
Question 2 – Logging and Orthogonality [6 marks]
a) Explain the concept of orthogonality using log4j loggers, levels and appenders as an
example! Discuss which language features in Java are used in order to achieve
orthogonality in log4j !
[4 marks]
b) What will be printed on the console if the following script is executed?
[2 marks]

Logger logger = Logger.getLogger("mylogger");
Appender appender = new ConsoleAppender(new SimpleLayout(),ConsoleAppender.SYSTEM_OUT);
logger.addAppender(appender);
logger.setLevel(Level.ERROR);
logger.error("error1");
logger.info("info1");
logger.warn("warn1");
logger.debug("debug1");
logger.setLevel(Level.DEBUG);
logger.error("error2");
logger.info("info2");
logger.setLevel(Level.INFO);
logger.warn("warn2");
logger.debug("debug2");

Page 4 of 9 COS
Question 3 – Testing [8 marks]
Assume you build a tax calculator library that has a method double distance(Point,Point)
that computes the distance between two points in space. The algorithm used only works
for points with non-negative coordinates, otherwise, an IllegalArgumentException is
thrown.
a) Let’s assume you have created test cases for 1,000 different input values using a
spreadsheet. All tests succeed, i.e., they calculate the expected value. Can you
conclude from this that distance(Point,Point) is correctly implemented ?
[2 marks]
b) Describe how you would use junit features to efficiently implement such a large
number of tests. Explain how this feature(s) works !
[2 marks]
c) The handling of negative input values is part of the specification of the
distance(Point,Point) method. How would you test this?
[2 marks]
d) An alternative to testing negative input values is to exclude them from all tests by
adding a precondition that the input values must be non-negative. Which junit
feature can be used to implement this, and how does this work ?
[2 marks]
Page 5 of 9 COS
Question 4 - Organising Code [4 marks]
Explain the advantages of convention over configuration using the Java getter and setter
convention !
Page 6 of 9 COS
Question 5 - Shell and Scripting [8 marks]
a) In a shell session, when you enter the command:
grep "abc" file.txt
It produces no output, indicating the command found no matches. How would you
determine if the same command was successful in a shell script?
[2 marks]
b) What are environment variables used for? List some commonly used environment
variables.
[1 marks]
c) With examples, explain the concepts of redirection and piping in the Unix shell.
[3 marks]
d) Permissions are used to control access to files. Describe the permissions for script.sh
in the following listing.
[2 marks]
cd ~
ls -l
-rw-rw-r-- script.sh
Page 7 of 9 COS
Question 6 - Source Code Management [8 marks]
a) What is the purpose of using a linter such as Checkstyle or a code formatter (e.g.
google-java-format) in collaborative software development?
[1 mark]
b) What is the key difference between an older version control system such as CVS
and Git?
[1 mark]
c) A development team has released the first version of a software, tagged the release
as v1 and it has been built and shipped to a set of customers. The developers are
now working on features for version 2. Meanwhile, a customer reports a bug for
version 1.
Explain how the developers would use Git (with git commands and commit graph)
during development, and to contribute a bugfix for version 1 and also to apply the
fix on version 2, release a patched version and ship to customer as v1.1 without the
newer features in v2
[6 marks]
Page 8 of 9 COS
Question 7 - Issue Tracking and Licensing [4 marks]
a) Describe how you would use an issue tracker in collaborative software
development and what information it records and tracks.
[3 marks]
b) What is the main difference between permissive licenses such as the BSD/MIT
license and the GPL, a copyleft license?
[1 marks]
Page 9 of 9 COS
Question 8 - Metrics [6 marks]
a) Discuss how lines of code metrics can be misleading in assessing developer
productivity
[2 marks]
b) Define logical, physical lines of code and cyclomatic complexity. For the sorting
method listed below in Java, calculate these metrics.
[4 marks]
public void bubbleSort(int[] arr) {
boolean swapped = true;
int j = 0;
int tmp;
while (swapped) {
swapped = false;
j++;
for (int i = 0; i < arr.length - j; i++) {

if (arr[i] > arr[i + 1]) {
tmp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = tmp;
swapped = true;
}
}
}
}
+ + + + + + + +

版权所有:留学生程序辅导网 2019 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。