Sunteți pe pagina 1din 9

CST438 CSUMB online program

Final Exam Spring 2019(b)

Name ________Cody Dill__________________________

Directions.

● Edit this file with your responses and submit as a word docx or PDF file.
○ use a size 11 or 12 type font and single space.
● This is open book exam. You may use textbook and other resources from the course and online.
But do your own research and do not ask other people (in or outside of class) for any help. You
can of course ask your instructor for clarification on a question.
● Sign the academic honesty statement below.

I have not received nor given an unauthorized help with this exam. This exam is entirely my own work.

___________ _____________________________

Signature

Problem Points
1 15
2 15
3 15
4 15
5 15
6 15
7 20
8 20
9 20
Total 150

1
CST438 CSUMB online program
Final Exam Spring 2019(b)

For questions 1-3, write a short essay (single space font size 12 between ½ and 1 page).
1. In a software project, is it better to start with the design and coding of the views or the
model? There is no right or wrong answer to this question. Explain your reason for whatever
way you would do a project. [In your answer you might consider these things: suppose you had
done BDD or UML scenarios as part of gathering user requirements. Would that change your
answer? In developing a rails application, is it better to start with model and then do controllers
and views?]
a. During the process of coming up with the design, I like to start with the views. This is
because I am more of a visual person and when developing the views, I can see how the page
looks. From that point, I can see what changes I make in the views and then start on the
models/controllers after I understand what the application will look like. With the current
project that my teammate and I are working on, I started with the views to get a visual of the
home page. From that point on we built outwards and created the other aspects of the website.
If I had done BDD or UML scenarios as part of gather user requirements it wouldn’t have
changed my original answer. Due to the type of person I am, I must have a visual to see the code
and changes in real time. I tend to run into a wall when I’m programming and unable to see the
results. There is something satisfying of writing lines of code and then being able to see how it
has made an effect on the project. During the construction of our project, I took over the design
of the website because I had experience with it prior. I can sit at my computer for hours getting
it to look a certain way and then plugging in the data. Developing this application in rails has
been quite the challenge since it was foreign to me. There was a lot to learn in a short amount
of time which makes it difficult to really grasp the concept. However, there have been many
great resources out there that have assisted with the understanding of Rudy and Rails. The
language itself is helpful when developing website applications and dealing with databases. We
have found great commands that have assisted with the creation of new files and getting data
into the database. When the project first was installed there were talks between my partner and
me about switching what we accomplished from this class to a MySQL database. However, as
we are coming to a close to the project, we have come to find the usefulness from Rudy and
Rails. Thus, we decided to continue using the language and build off this project for our
capstone. Since we have the skeleton done for the project it will benefit us with additional
features we would like to add. Overall, this class has been a great opportunity to learn about
Rudy & Rails and grasp an understanding as to what it is capable of doing.

2
CST438 CSUMB online program
Final Exam Spring 2019(b)

2. You are in sprint number 12 of an agile software project and a colleague says “We really
need to redesign the way we are handling the rules for enrolling into a course when the course
has prerequisites and corequisites. The code has become very complicated and has too many
special cases and it been easy to make a mistake.” Another team member says, “We don’t have
time right now. We need to be working to deliver code for the changes the customer proposed
at the last sprint meeting. Just keep the current design for now.” How would you respond to
these two comments?
a. This scenario depends on a few things to decide which option would be the best to pursue.
The first would be if the customer would like to have a new design for how the rules are for
enrolling into a course. If they were okay with this then there would have to be an
understanding of the delay for the previous request. However, if the customer doesn’t want this
redesign but it happens anyway then who will get charged for the extra hours worked on this
project? This could also lead to an unhappy customer if they are not consulted first of the
changes. Therefore, going with the second comment would be the ideal solution for the
situation because it is what the customer wanted. It would be beneficial to have another
meeting with the client and discuss changing the rules to better the enrolling process. They
would be able to get the input from the customer and see if there is anything else that would be
preferred as well. There is no point of going above and beyond what the customer wants
without their consent for the go ahead. I have been in this situation with my current position
when I was asked to create a script to assist with inventory. The program would grab all the
information about the computer and store the data received into a networked folder. My
supervisor requested this script to made within a few days’ time. However, I took it upon myself
to extend the request to get additional information from the PC. After adding additional
features, it was a delay to over a week which affected all the technicians because they were
supposed to use the script for the inventory process. I had to explain to my supervisor why the
application was delayed but he was content with the delay because of the extra features.
Therefore, it worked on in my situation but that would not always be the case. When it comes to
a company developing an application for a customer price is the key factor. There is only x
amount of dollars to pay the developers to create what the customers want. So, there is no
point for these developers to go outside what the user requested because they will take more
time which will be more money.

3
CST438 CSUMB online program
Final Exam Spring 2019(b)

3. What does the term “non-functional” requirement refer to? What is special about “non-
functional requirements”?
a. The term non-functional requirement covers all the remaining requirements which are not
covered by the functional requirements. They specify criteria that judge the operation of a
system, rather than specific behaviors. A few examples of non-functional requirements are
performance, scalability, capacity, availability, reliability, recoverability, maintainability,
serviceability, security, manageability, data integrity and usability. These functionalities are
given regarding a new project because the customer will expect these to happen even if they
are not asked for. They are the quality characteristics or quality attributes of an application. The
non-functional requirement sets the boundaries for testing purposes and performance. It is the
system shall be a requirement instead of the system shall do the requirement. It aids with the
functionality that the customer requests from the developers because the application may have
users of its own using it. Therefore, user functionality needs to be able to work without a bump.
b. An example of a non-functional requirement that I can relate to is with this project. When I
am using the AWS service, I expect that I will be able to use any of its features without any
performance issues. When I need to migrate to another computer, I expect that there will be no
issues with connectivity due to it being stored on the cloud. With the project that is getting
developed, it has been shown to the client that will use it. They had features that have been
requested but they expect the non-functional features to work all the time. This is a given
because without them the application wouldn’t be efficient and there would be no point in
developing it. The user would complain about performance, reliability, maintainability or many
other things. Therefore, testing needs to be done to guarantee that there will be no issues and
that maintaining the application will be something that can be done.

Short answer questions

4. Read the article https://en.wikipedia.org/wiki/Mock_object about Mocks, fakes, and stubs.


Give an example (preferably something from your project) where using a mock object might be
necessary for testing.
a. A mock function would have been useful to use for testing the data going into the database.
We are currently working on functionality that will allow the user to import an excel
spreadsheet to the database. However, the function looks for an ID number in the spreadsheet
and associated it when an ID number in the database. It would have been great to run tests to
make sure the IDs match between the database and spreadsheet. Since the data could be from a
different spreadsheet but the IDs match therefore the data would be replaced. Having a test for
this situation would have been great to see how a new design would eliminate this problem.

5. Validation versus filters


a. Give an example of something that would best be implemented using a validation method in
the Active Record class?
i. In the application we allow the user to add new data to the database and give them that
functionality to add anything. However, we had to set it up if the user wasn’t entering any data

4
CST438 CSUMB online program
Final Exam Spring 2019(b)

into one of the rows that it would give an error message. Thus, we developed a method in the
models that check for validation. It looks to see if anything was entered into the box and if there
wasn’t it kicks back a message to the users. They would have to enter data or a placeholder until
there is a value to go in that spot.

b. Give an example of something that would best be implemented using a before_action filter
in the Controller class?
i. The before_action would have worked great for our show, edit and destroy functionality that
offers the user on the tables. This could implement the functionality for the task depending on
which one is selected by the user. Since there is additional functionality for the before_action
feature it could be useful.

6. What are fixtures and what are they used for in rails?
a. Fixtures are a way of organizing data that can be tested against. The data is stored into a
YAML file which is creating when a model is created. Fixtures allow testing the application to
help debug it more efficiently and ensure the desired functionality is working. It allows the test
data to be managed and tested against real data.

5
CST438 CSUMB online program
Final Exam Spring 2019(b)

Question 7-9 pertain to a Rails application that has a Student resource. The Student model contains
attributes of name, email, grade_point_average, credits, start_date and photo.

1. Complete the code for a rails integration test that tests the Student controller update action
with simulated input to get the processing of the following form

The HTML source is shown below

<!DOCTYPE html>
<html><head> head statements not shown </head>
<body>
<p>
<a href="https://9913cbdc3a774388a20e22fe6df51efd.vfs.cloud9.us-
west-2.amazonaws.com/students">Students</a>
<a href="https://9913cbdc3a774388a20e22fe6df51efd.vfs.cloud9.us-
west-2.amazonaws.com/sections">Class Schedule</a>
<a href="https://9913cbdc3a774388a20e22fe6df51efd.vfs.cloud9.us-
west-2.amazonaws.com/courses">Course Catalog</a>Logged in as
admin@csumb.edu Role:Admin
<a
href="https://9913cbdc3a774388a20e22fe6df51efd.vfs.cloud9.us-west-
2.amazonaws.com/logout">Log Out</a>
</p>

<hr>
<h1>Editing Student</h1>

6
CST438 CSUMB online program
Final Exam Spring 2019(b)

<form class="edit_student" id="edit_student_7"


enctype="multipart/form-data"
action="https://9913cbdc3a774388a20e22fe6df51efd.vfs.cloud9.us-west-
2.amazonaws.com/students/7" accept-charset="UTF-8"
method="post"><input name="utf8" type="hidden" value="✓"><input
type="hidden" name="_method" value="patch"><input type="hidden"
name="authenticity_token"
value="LLmAHrc7vsWU4UQiKtiRywip6xesxn+lP1Apig5iz9JqKhmw2bCd8I4FCTx33SG
LO+sBtUHPM4hX/kzBQ/mSrQ==">

<div class="field">
<label for="student_id">Id</label>
<label for="student_7">7</label>
</div>

<div class="field">
<label for="student_name">Name</label>
<input type="text" value="John Jackson" name="student[name]"
id="student_name">
</div>

<div class="field">
<label for="student_email">Email</label>
<input type="text" value="jjackson@csumb.edu"
name="student[email]" id="student_email">
</div>

<div class="actions">
<input type="submit" name="commit" value="Update Student" data-
disable-with="Update Student">
</div>
</form>

<a href="https://9913cbdc3a774388a20e22fe6df51efd.vfs.cloud9.us-west-
2.amazonaws.com/students/2">Show</a> |
<a href="https://9913cbdc3a774388a20e22fe6df51efd.vfs.cloud9.us-west-
2.amazonaws.com/students">Back</a>

</body></html>

Simulate a name change from “John Jackson” to “John Rebock” with a changed email value to
“jrebock@csumb.edu”.

Complete this integration test class. Complete the def statement, and params: passed to the
put method. Code the assert statements needed do the verification that the email and name

7
CST438 CSUMB online program
Final Exam Spring 2019(b)

were successfully updated in the database. Also verify that the text “Student successfully
updated” is returned in the second <p> tag of html output.

def _update_________
student7 = students(:student7)
put student_url(student7), params:{:name, :email}
follow_redirect!

code verification statements here!

@name. changed?

@email. changed?

Name.changes

Email.changes
end

2. The following code is part of the StudentController update method

[1] # PATCH/PUT /students/1


[2]# PATCH/PUT /students/1.json
[3]def update
[4] respond_to do |format|
[5] if @student.update(student_params)
[6] format.html { redirector @student,
[7] notice: 'Student was successfully updated.' }
[8] format.json { render :show, status: :ok, location: @student }
[9] else
[10] format.html { render :edit }
[11] format.json { render json: @student.errors, status: :unprocessable_entity }
[12] end
[13] end
[14]end

[15] def student_params


[16] params.require(:student).permit(:name, :email)
[17]end

a. What is the purpose of the student.update method on line [5]?

The purpose of student.update checks the student parameters to verify

b. What is the purpose of the student_params method on line [15]?

8
CST438 CSUMB online program
Final Exam Spring 2019(b)

i. It creates a new object which allows certain elements to be updated.

3. Given the rails statement


@student = Student.find(params[:id])

a. What does this statement do?


i. It is a part of the display form which allows the data to be shown.
b. How would you retrieve a list of all Students from the database?
i. I would create a private function in the controller called def student. Then do
params.require(:student).permit(attributes). Then it the views folder I would
create a html page and create a (% @students.each do |stu| %> then a <%=
stu.attributes %>
c. How would you retrieve a list of Students that have less than 25 credits?
i. I would create a conditional statement to check the attribute credits and
determine which students have more than 25.
d. Have less than n-credits, n-credits is a variable?
i. Create a functionality in the views that allows the user to input a number. Then
it would check for the user’s input and run the report based upon their number.

S-ar putea să vă placă și