Lecture 28 - Quizzes 5 and 6: Maintenance & Security / Professional Issues

Lecture Date: Thursday, December 5

General Info

Each of the six quizzes in the course is expected to take around 30 minutes to complete. On each quiz day, there will be two quizzes based on whatever the latest two major subject areas of the class were:

  • Quiz Day 1: Software Process and Requirements
  • Quiz Day 2: Architecture & Design and Verification & Validation
  • Quiz Day 3: Maintenance & Security and Professional Issues

All quizzes are bound by the Honor System as any other assessment at UVA. You are forbidden to speak of specifics of any assessment with other students who have not yet taken the assessment.

Each quiz is worth 10000 XP. Each question will be graded wholistically. That is, each question can either earn full XP, no XP, or a single partial level of XP. For example, a quiz with 5 questions might assign 2000 XP to each question, and each question could earn 2000 XP, 1000 XP, or 0 XP. (There are some exceptions for questions with sub questions.) Students will have the opportunity to earn back at least a portion of missed XP during the Final Exam period.

Maintenance & Security Knowledge Assessment

  • Expect to answer questions regarding:
    • Design Patterns - You don't have to have them memorized, but you may be given one to evaluate, and you definitely need to know why they are important.
    • Maintenance - Why is it the most costly of the phases? What are the different types of maintenance - perfective, adaptive, corrective? Why would developers want to do continuous refactoring, identifying code smells? What skills does a developer need to have to be good at maintenance?
    • Security - Know in general what can be done during each phase of development to engineer more secure software.

Professional Issues Knowledge Assessment

  • Expect to answer questions regarding:
    • Basic questions regarding software licensing, particularly around GPL, MIT, and BSD.
    • What is a EULA and how are they used?
    • Given a particular ethics problem, what would you do? (you do not need to have the code memorized, but you should know the general overall concept of what the code is asking you to do - we will provide relevant parts of the code as needed)
    • Why do you think a developer might not follow the code of ethics?
more ...

Lecture 27 - SE Code of Ethics cont.

Lecture Date: Monday, December 3

Guided Practice H: SE Code of Ethics Today

We complete our discussion of the SE Code of Ethics and see how it could apply to some scenarios.

We will then complete the content of the semester with a review before Quizzes 5 and 6 on Thursday.

Software Engineering Code of Ethics @ Computer.org

Announcements:

  • Check your Dashboard to ensure everything is correct!

Today's Slides:

Slides - Professional Issues

Audio Recording (11:00 Lecture):

more ...

Lecture 26 - Project Workday

Lecture Date: Tuesday, November 26

We are giving you today to work with your team on your project before going home for Thanksgiving. You do not need to come to Rice 130 today, but do try to work with your team at some point.

Announcements:

  • Check your Dashboard to ensure everything is correct!

No Slides Today

No Audio Recording (11:00 Lecture)

more ...


Lecture 24 - Engineering Software Security cont.

Lecture Date: Tuesday, November 19

Wrapping up security today with an in-class activity looking at some info on Django security and how it relates to your project. In the activity we may ask you to look at one or more of these websites:

Announcements:

  • See the email regarding how Quizzes 5 and 6 will work, along with the final exam periods.
  • Note that the Tuesday before Thanksgiving Break is now a "Project Workday."

Today's Slides:

Slides - Engineering Software Security

No Audio Recording (11:00 Lecture)

more ...

Lecture 23 - Engineering Software Security

Lecture Date: Thursday, November 14

Securing software is not an afterthought. But too often developers treat it as such, particularly newer developers. We'll discuss some key points to consider when building software with security in mind.

Announcements:

  • The SEAS 60: "Especially at this stressful time of year it’s common for many of us to need some extra help, and I want to remind you to treat your mental health the same as you would any other health-related matter. If you find that you’re struggling with depression, anxiety, or stress management, or even if you can’t quite identify what’s wrong, please consider contacting Counseling and Psychological Services for support. Please be aware that if you have seen Liz Ramirez-Weaver in the past and are used to using her open office hours, I’m afraid that these will not be held for the remainder of the semester due to overwhelming demand. Please make an appointment through CAPS. If you find yourself or a friend in crisis, you can walk into CAPS during business hours, call CAPS on Call after hours, or call 911."

Today's Slides:

Slides - Engineering Software Security

Audio Recording (11:00 Lecture):

more ...

Lecture 22 - Code Smells

Lecture Date: Tuesday, November 12

How does your code smell?

Announcements:

  • Regrades for Quizzes 3 and 4 are due TODAY!

Today's Slides:

Slides - Code Smells

Audio Recording (11:00 Lecture):

more ...

Lecture 21 - Maintenance

Lecture Date: Thursday, November 7

Guided Practice H: Maintenance In-Class Today

"Maintenance" is too often a dirty word in software development... but really only the most skilled developers are good at it! Why does this happen? What skills do you need to be successful?

Announcements:

  • Reminder that regrade requests for the quizzes are due by 11:59 PM on Tuesday, Nov 12.
  • Please check your Dashboard each week in lab and report any issues to your TAs! It's better to fix them now than at the end of the semester!
  • Let's have a talk about the status of your projects and what's coming up...
  • Let's also talk about the final...

Today's Slides:

Slides - Maintenance

Audio Recording (11:00 Lecture):

more ...

Lecture 20 - Design Patterns

Lecture Date: Tuesday, November 5

Today we will discuss software design patterns. These are similar to the architecture patterns we have already discussed in theory, but are more around specfific programming solutions, rather than high-level solutions.

Announcements:

  • Quizzes should be returned today! Regrades are due in one week!

Today's Slides:

Slides - Software Design Patterns

Audio Recording (11:00 Lecture):

Adapter Pattern

import math

class Square_Peg:

    side_length = 0

    def __init__(self, side_length):
        self.side_length = side_length

    def make_fit(self, hole):
        if self.side_length < hole.get_max_square_peg_size():
            print("Square_Peg with side_length", self.side_length, "fits!")
        else:
            print("Square_Peg with side_length", self.side_length, "won't fit!!!")


class Round_Hole:
    def __init__(self, radius):
        self.radius = radius
        print("Round_Hole: max Square_Peg size is", self.get_max_square_peg_size())

    def get_max_square_peg_size(self):
        return self.radius*math.sqrt(2)

# One possible solution is:

class Square_Peg_Class_Adapter(Square_Peg):
    def __init__(self, side_length):
        Square_Peg.__init__(self,side_length)


    def make_fit(self, hole):
        if self.side_length > hole.get_max_square_peg_size():
            amount_to_reduce = self.side_length - hole.get_max_square_peg_size()
            print("Square_Peg with side_length", self.side_length, "is currently too big!")
            print("    reducing size by", amount_to_reduce)
            self.side_length = self.side_length - amount_to_reduce
            print("Trying Square_Peg with with new side_length", self.side_length, "!")

        if self.side_length <= hole.get_max_square_peg_size():
            print("Square_Peg with side_length", self.side_length, "fits!")
        else:
            print("Square_Peg with side_length", self.side_length, "won't fit!!!")



class Square_Peg_Object_Adapter:
    def __init__(self, peg):
        self.peg = peg

    def make_fit(self, hole):
        if self.peg.side_length > hole.get_max_square_peg_size():
            amount_to_reduce = self.peg.side_length - hole.get_max_square_peg_size()
            print("Square_Peg with side_length", self.peg.side_length, "is currently too big!")
            print("    reducing size by", amount_to_reduce)
            self.peg.side_length = self.peg.side_length - amount_to_reduce
            print("Trying Square_Peg with with new side_length", self.peg.side_length, "!")

        if self.peg.side_length <= hole.get_max_square_peg_size():
            print("Square_Peg with side_length", self.peg.side_length, "fits!")
        else:
            print("Square_Peg with side_length", self.peg.side_length, "won't fit!!!")

print("TESTING SMALL AND LARGE SQUARE PEG ----")
hole = Round_Hole(5)
peg = Square_Peg(5)
peg.make_fit(hole)

peg = Square_Peg(10)
peg.make_fit(hole)

print("\n\nTESTING CLASS ADAPTER -----------------")
peg_adapter = Square_Peg_Class_Adapter(10)
peg_adapter.make_fit(hole)

print("\n\nTESTING OBJECT ADAPTER ----------------")
peg_adapter = Square_Peg_Object_Adapter(peg)
peg_adapter.make_fit(hole)

Expected output:

TESTING SMALL AND LARGE SQUARE PEG ----
Round_Hole: max Square_Peg size is 7.0710678118654755
Square_Peg with side_length 5 fits!
Square_Peg with side_length 10 won't fit!!!


TESTING CLASS ADAPTER -----------------
Square_Peg with side_length 10 is currently too big!
    reducing size by 2.9289321881345245
Trying Square_Peg with with new side_length 7.0710678118654755 !
Square_Peg with side_length 7.0710678118654755 fits!


TESTING OBJECT ADAPTER ----------------
Square_Peg with side_length 10 is currently too big!
    reducing size by 2.9289321881345245
Trying Square_Peg with with new side_length 7.0710678118654755 !
Square_Peg with side_length 7.0710678118654755 fits!

Observer Pattern

class Scoreboard:
    def __init__(self):
        self._observers = set()
        self._current_score = 0

    def attach(self, observer):
        observer._subject = self
        self._observers.add(observer)

    def detach(self, observer):
        observer._subject = None
        self._observers.discard(observer)

    def _notify(self):
        for observer in self._observers:
            observer.update(self._current_score)

    @property
    def current_score(self):
        return self._current_score

    @current_score.setter
    def current_score(self, new_score):
        self._current_score = new_score
        self._notify()


class Observer:
    def __init__(self):
        self._subject = None
        self._observer_state = None

    def update(self, arg):
        pass


class ConcreteObserver(Observer):
    def update(self, arg):
        self._observer_state = arg
        print("Observer sees new score!!:", self._observer_state)


def main():
    scoreboard = Scoreboard()
    concrete_observer = ConcreteObserver()
    concrete_observer2 = ConcreteObserver()
    scoreboard.attach(concrete_observer)
    scoreboard.attach(concrete_observer2)
    scoreboard.current_score = 123


if __name__ == "__main__":
    main()

Singleton Pattern

public class Singleton {

    private int value = 0;

    private Singleton() {}

    private static class SingletonHolder {
        private static final Singleton INSTANCE = new Singleton();
    }

    public static Singleton getInstance() {
        return SingletonHolder.INSTANCE;
    }

    public void setValue(int x) {
        this.value = x;
    }

    public int getValue() {
        return this.value;
    }
}
Singleton mySing1 = Singleton.getInstance();
Singleton mySing2 = Singleton.getInstance();

if(mySing1 == mySing2) {
    System.out.println("Same!");
}
else {
     System.out.println("Not Same!");
}

System.out.println(mySing1.getValue());
mySing2.setValue(4);
System.out.println(mySing1.getValue());

Abstract Factory Pattern

abstract class PhraseFactory {

    public static final int COOL = 0;
    public static final int LAME = 1;

    public static PhraseFactory getFactory(int TYPE) {
        PhraseFactory factory = null;
        if(TYPE == COOL) {
            factory = new CoolPhraseGenerator();
        }
        else if(TYPE == LAME) {
            factory = new LamePhraseGenerator();
        }
        return factory;
    }

    public abstract String getPhrase();
}
PhraseFactory myPhraseGenerator = PhraseFactory.getFactory(PhraseFactory.COOL);
System.out.println(myPhraseGenerator.getPhrase());

myPhraseGenerator = PhraseFactory.getFactory(PhraseFactory.LAME);
System.out.println(myPhraseGenerator.getPhrase());

Code adapted from examples provided at http://sourcemaking.com.

more ...

Lecture 19 - Quizzes 3 & 4: V&V / Architecture

Lecture Date: Thursday, October 31

General Info

Each of the six quizzes in the course is expected to take around 30 minutes to complete. On each quiz day, there will be two quizzes based on whatever the latest two major subject areas of the class were:

  • Quiz Day 1: Software Process and Requirements
  • Quiz Day 2: Architecture & Design and Verification & Validation
  • Quiz Day 3: Maintenance & Security and Professional Issues

All quizzes are bound by the Honor System as any other assessment at UVA. You are forbidden to speak of specifics of any assessment with other students who have not yet taken the assessment.

Each quiz is worth 10000 XP. Each question will be graded wholistically. That is, each question can either earn full XP, no XP, or a single partial level of XP. For example, a quiz with 5 questions might assign 2000 XP to each question, and each question could earn 2000 XP, 1000 XP, or 0 XP. (There are some exceptions for questions with sub questions.) Students will have the opportunity to earn back at least a portion of missed XP during the Final Exam period.

Verification & Validation Quiz

Architecture & Design Quiz

No Audio Today

more ...