CISC/CMPE320 - Prof. McLeod

Slides:



Advertisements
Similar presentations
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
Advertisements

System Design: Decomposing the System
1 Decomposing the System Requirements  Specifications (Use cases)  Design --classes **entity **boundary **control --sequence diagrams --CRC cards **responsibilites.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 1 due today, 7pm. RAD due next Friday in your Wiki. Presentations week 6. Today: –Continue.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 4 is due Nov. 20 (next Friday). After today you should know everything you need for assignment.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Lecture Videos will no longer be posted. Assignment 3 is due Sunday, the 8 th, 7pm. Today: –System Design,
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Today: –Review declaration, implementation, simple class structure. –Add an exception class and show.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 2 sample solution is posted. Assignment 3 is posted. Due Nov. 6. Today: –Continue Software.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 3 is due Sunday, the 8 th at 7pm. Problems with assn 3? Discuss at your team meeting tonight.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 4 is due Nov. 20 (next Friday). SDD document framework should be set up in your Wiki by now.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 3 is due Sunday, the 8 th at 7pm. Today: –Two simple binding examples. –Function Hiding.
Today… Modularity, or Writing Functions. Winter 2016CISC101 - Prof. McLeod1.
Computer System Structures
Memory Management.
Jim Fawcett CSE 691 – Software Modeling and Analysis Fall 2000
Non Functional Requirements (NFRs)
Architecture & System Performance
Chapter 17 - Component-based software engineering
Software testing
Chapter 1: Introduction
Run-time organization
CISC/CMPE320 - Prof. McLeod
CISC/CMPE320 - Prof. McLeod
CISC/CMPE320 - Prof. McLeod
Introduction to Computers
Fall 2017 CISC124 9/21/2018 CISC124 First onQ quiz this week – write in lab. More details in last Wednesday’s lecture. Repeated: The quiz availability.
CISC/CMPE320 - Prof. McLeod
CISC/CMPE320 - Prof. McLeod
Advanced Programming Behnam Hatami Fall 2017.
CMPE212 – Stuff… Exercises 4, 5 and 6 are all fair game now.
CISC124 Assignment 4 on Inheritance due next Monday, the 12th at 7pm.
CISC101 Reminders Slides have changed from those posted last night…
CISC124 Quiz 1 marking nears completion!
Fall 2018 CISC124 12/1/2018 CISC124 Note that the next assignment, on encapsulation, is due next Wednesday at 7pm – not Friday. The next Quiz is not until.
Fall 2018 CISC124 12/3/2018 CISC124 or talk to your grader with questions about assignment grading. Fall 2018 CISC124 - Prof. McLeod Prof. Alan McLeod.
CISC101 Reminders Assn 3 due tomorrow, 7pm.
CISC/CMPE320 - Prof. McLeod
An Introduction to Software Architecture
CISC124 Assignment 4 on Inheritance due next Friday.
CISC/CMPE320 - Prof. McLeod
CISC/CMPE320 - Prof. McLeod
CISC/CMPE320 - Prof. McLeod
Chapter 2: Operating-System Structures
CISC/CMPE320 - Prof. McLeod
CISC/CMPE320 - Prof. McLeod
CISC/CMPE320 - Prof. McLeod
CISC/CMPE320 - Prof. McLeod
CISC/CMPE320 - Prof. McLeod
Fall 2018 CISC124 2/22/2019 CISC124 Quiz 1 This Week. Topics and format of quiz in last Tuesday’s notes. The prof. (me!) will start grading the quiz.
CISC/CMPE320 - Prof. McLeod
CISC/CMPE320 - Prof. McLeod
CISC/CMPE320 - Prof. McLeod
CISC/CMPE320 - Prof. McLeod
Fall 2018 CISC124 2/24/2019 CISC124 Quiz 1 marking is complete. Quiz average was about 40/60 or 67%. TAs are still grading assn 1. Assn 2 due this Friday,
CISC/CMPE320 - Prof. McLeod
CISC/CMPE320 - Prof. McLeod
CMPE212 – Reminders Assignment 3 due next Friday.
Decomposing the System
CISC101 Reminders Assignment 3 due next Friday. Winter 2019
Chapter 17 - Component-based software engineering
CMPE212 – Reminders Quiz 1 marking done. Assignment 2 due next Friday.
Chapter 11: Integration- and System Testing
CSE 153 Design of Operating Systems Winter 2019
Winter 2019 CMPE212 5/25/2019 CMPE212 – Reminders
Chapter 2: Operating-System Structures
CISC101 Reminders Assignment 3 due today.
CMPE212 – Reminders Assignment 2 due next Friday.
SPL – PS2 C++ Memory Handling.
Presentation transcript:

CISC/CMPE320 - Prof. McLeod Winter 2013 CISC/CMPE320 2/16/2019 CISC/CMPE320 SDD “Due” this Friday evening – Nov. 2 in Confluence. Assignment 3 is now due Nov. 6 (a week from today). Note: please use your queensu email address with your git client. Fall 2018 CISC/CMPE320 - Prof. McLeod Prof. Alan McLeod

CISC/CMPE320 - Prof. McLeod Today Finish up System Design. Then, back to C++: Using the Heap, Cont. Not Using the Heap Properly – Common Memory Errors. Fall 2018 CISC/CMPE320 - Prof. McLeod

CISC/CMPE320 - Prof. McLeod Layering Two general kinds: Open Architecture and Closed Architecture (don’t confuse “Open” with “Non-Proprietary”, here!). Fall 2018 CISC/CMPE320 - Prof. McLeod

Closed Architecture, in General Most Abstract Level 1 Subsystem A Level 2 Subsystem B Subsystem C Subsystem D Level 3 Subsystem E Subsystem F Subsystem G Least Abstract Fall 2018 CISC/CMPE320 - Prof. McLeod

Closed Architecture, Cont. You cannot go from level 3 back to level 1 without going through level 2. Subsystems A, B and E represent a complete Vertical Slice of the architecture, but subsystems D and G would not. Fall 2018 CISC/CMPE320 - Prof. McLeod

Closed Architecture, Cont. A layer can only access the layer immediately above or below it. (In Java you can construct a closed object hierarchy.) In an Open Architecture you can skip layers. Fall 2018 CISC/CMPE320 - Prof. McLeod

Closed Architecture Example – OSI Model Stands for “Open Systems Interconnection” Most Abstract Application Key Presentation CORBA or Java RMI Connection Session Message Transport Packet Network TCP/IP Frame DataLink Bit Physical Ethernet Fall 2018 CISC/CMPE320 - Prof. McLeod Least Abstract

Open Architecture Example Application Swing AWT You can get improved performance by bypassing the Swing layer. (Nowadays, JavaFX replaces the Swing and AWT layers). OS Fall 2018 CISC/CMPE320 - Prof. McLeod

CISC/CMPE320 - Prof. McLeod Layering and Coupling The emergency response database system: The Database subsystem is directly coupled to the other three subsystems, making these subsystems vulnerable to changes in Database design. ResourceManagement MapManagement IncidentManagement Database Fall 2018 CISC/CMPE320 - Prof. McLeod

Layering and Coupling, Cont. Add a layer: Storage will have a more stable interface. If Database changes then only Storage will have to be modified. Less coupling to Database! ResourceManagement IncidentManagement MapManagement Storage Database Fall 2018 CISC/CMPE320 - Prof. McLeod

CISC/CMPE320 - Prof. McLeod Layering, Cont. Usually have a tradeoff. Limit to the number of layers formed by partitioning: “Common Wisdom” says that developers can handle a maximum of 9 layers of abstraction. Often as little as 3 layers is just fine! 7 ± 2 Fall 2018 CISC/CMPE320 - Prof. McLeod

CISC/CMPE320 - Prof. McLeod Design Goals Are taken from the existing non-functional requirements and from your observations and documentation of the application domain. These goals usually lie in the following categories: Performance Dependability Cost Maintenance End User Criteria Fall 2018 CISC/CMPE320 - Prof. McLeod

Design Goals – Performance Response Time How quickly must the system respond to a user request? Throughput How many tasks does the system need to complete in a fixed period of time? Memory How much memory is required when running? Fall 2018 CISC/CMPE320 - Prof. McLeod

Design Goals – Dependability Robustness Survive invalid user input. Reliability Does observed behaviour match specified behaviour? Availability Percentage of time the system is available to perform normal tasks. Fault Tolerance Ability to continue to operate under erroneous conditions. Fall 2018 CISC/CMPE320 - Prof. McLeod

Design Goals – Dependability, Cont. Security Ability to withstand malicious attacks. Safety Avoid human injury even in the presence of errors and failures. Fall 2018 CISC/CMPE320 - Prof. McLeod

CISC/CMPE320 - Prof. McLeod Design Goals – Cost Development Cost Initial system development. Deployment Cost Cost of installation and user training. Upgrade Cost Translating data from previous system. Backwards compatibility? Maintenance Cost Cost of bug fixes and enhancements. Administration Cost Cost to administer system. Fall 2018 CISC/CMPE320 - Prof. McLeod

Design Goals – Maintenance Extensibility How easy is it to add functionality or new classes to the system? Modifiability How easy is it to change functionality? Adaptability How easy is to port the system to different application domains? Portability How easy is it to port the system to different platforms? Fall 2018 CISC/CMPE320 - Prof. McLeod

Design Goals – Maintenance, Cont. Readability How easy is it to understand the system from reading the code? Traceability of Requirements How easy is it to map the code to specific requirements? Fall 2018 CISC/CMPE320 - Prof. McLeod

Design Goals – End User Criteria Utility How well does the system support the work of the user? Usability How easy is it for the user to use the system? Fall 2018 CISC/CMPE320 - Prof. McLeod

CISC/CMPE320 - Prof. McLeod Trade-Offs! Of course these goals can beat on each other. For example it might not be possible to have a system that is completely safe and secure but still cheap. For example, you might have to compromise between: Space and Speed Delivery Time and Functionality Delivery Time and Quality Delivery Time and Staffing Fall 2018 CISC/CMPE320 - Prof. McLeod

CISC/CMPE320 - Prof. McLeod Team Efforts Establish and formalize these design goals early on, and make sure everyone is aware of them. They form the constraints on what you are able to build! Fall 2018 CISC/CMPE320 - Prof. McLeod

CISC/CMPE320 - Prof. McLeod Boundary Conditions Might already have boundary use cases – but not always. Configuration Use Cases: First, identify each persistent object. Second, locate the use case that creates the object and then the use case that archives the object. If these cannot be found, create the necessary use cases invoked by a system administrator. Fall 2018 CISC/CMPE320 - Prof. McLeod

Boundary Conditions, Cont. Start-up and Shut-down Use Cases: Each hardware component (ex. WebServer) will need a start, shutdown and configure use case. A single use case might manage several tightly coupled components. Fall 2018 CISC/CMPE320 - Prof. McLeod

Boundary Conditions, Cont. Exception Handling Use Cases: Identify each possible component failure (ex. NetworkOutage), and decide how the system should react. Exceptions can be generated by hardware failures, changes in the operating environment, and software faults. How to handle these exceptions to prevent failure is a big topic! Fall 2018 CISC/CMPE320 - Prof. McLeod

Handling Boundary Conditions These new boundary use cases could have a profound impact on your design and you might have to go back and change your system decomposition to account for them. But it is still easier to look at boundary conditions after you have built your basic design. Fall 2018 CISC/CMPE320 - Prof. McLeod

CISC/CMPE320 - Prof. McLeod Back to C++ We were talking about using the heap: The new and new[] operators provide “dynamic memory allocation”. These operators return a pointer to memory allocated on the heap. Fall 2018 CISC/CMPE320 - Prof. McLeod

CISC/CMPE320 - Prof. McLeod Using the Heap Advantages: The size of the memory to be allocated does not have to be known until run-time. Once allocated the memory persists until either the program completes or you free up the memory by issuing a delete or delete[] on the pointer. You can return a pointer to this memory from a function and it will remain stable. The available memory is huge – determined really by the amount of RAM on your system (and whether or not you are using a 32 bit compiler). Much more memory than what is available on the stack. Fall 2018 CISC/CMPE320 - Prof. McLeod

CISC/CMPE320 - Prof. McLeod Using the Heap, Cont. Disadvantages: The responsibility for maintaining the heap is given to the coder (a human!!, very human sometimes!!) As we will see, forgetting to remove something from the heap can lead to the dreaded and very common “memory leak” problem. Crash, crash, crash! For example: Fall 2018 CISC/CMPE320 - Prof. McLeod

Notes on Using new[] and delete[], Cont. Suppose you do something like: string** arr = new string*[100]; for(int i=0; i < 100; i++) arr[i] = new string(); Will this be enough to delete this structure completely?: delete[] arr; Fall 2018 CISC/CMPE320 - Prof. McLeod

Notes on Using new[] and delete[], Cont. Similarly: vector<string*> *varr = new vector<string*>(); for (int i = 0; i < 100; i++) varr->push_back(new string()); Will this be enough to delete this structure completely?: delete varr; Fall 2018 CISC/CMPE320 - Prof. McLeod

Class Attributes on the Heap Following some standard rules for coding, when the heap is used by a class to store an attribute will help reduce the risk. For example, you can write the code that is responsible for cleaning up the heap in a special function called the Destructor: Fall 2018 CISC/CMPE320 - Prof. McLeod

Destructor Member Function Distinguished from a constructor using the ~ before the class name. Responsible for deleting all heap variables (using delete and delete[]). If you use the heap in your class you must have a destructor. You never invoke the destructor directly – the system will invoke it instead. Back to our collection of strings: Fall 2018 CISC/CMPE320 - Prof. McLeod

Example of Code in a Destructor To clean up the previous example: for (int i = 0; i < 100; i++) delete varr.at(i); delete varr; varr = nullptr; The destructor is a member of a group of functions called “The Big Three”: Fall 2018 CISC/CMPE320 - Prof. McLeod

“The Big Three” – Summary Destructor: Frees all heap memory used by the object. Copy constructor: Initializes the object as a copy of the same type object supplied as a parameter. If you are using heap memory you will need to allocate and initialize each value. Assignment operator: Check to make sure that you are not assigning yourself. If so, do nothing. Free up the heap memory that is no longer needed. Copy the value of the argument supplied. Return *this. Fall 2018 CISC/CMPE320 - Prof. McLeod

CISC/CMPE320 - Prof. McLeod Aside - “The Big Three” Any class that uses the heap must have these three functions. More on these guys later. We will build them in a demo program. For now, let’s summarize some common errors created by the improper use of memory in C++. Using the heap makes it much easier for the coder to create errors! Fall 2018 CISC/CMPE320 - Prof. McLeod

CISC/CMPE320 - Prof. McLeod Common Memory Errors Using a variable that has not been initialized. Using a pointer to reference a memory location that is no longer valid. Forgetting to delete something on the heap. Deleting a memory value that was never allocated. Deleting something on the heap more than once. Look at each of these, in turn: Fall 2018 CISC/CMPE320 - Prof. McLeod