CP317 Software Engineering - Low-level Design 2
21 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the primary focus of procedural-oriented design?

  • Data structures
  • Functions (correct)
  • Objects
  • Inheritance
  • Which of the following is NOT a disadvantage of procedural-oriented design?

  • Efficient use of memory (correct)
  • Difficult to understand and maintain
  • Difficult to modify and extend
  • Data is not protected
  • What is the purpose of a constructor in object-oriented design?

  • To inherit properties from another class
  • To define the attributes of a class
  • To initialize an object (correct)
  • To destroy an object
  • What is the relationship between a class and an object in object-oriented design?

    <p>A class is a blueprint for creating objects (A)</p> Signup and view all the answers

    Which of the following object-oriented design principles allows for code reusability?

    <p>Inheritance (A)</p> Signup and view all the answers

    What does the term 'abstraction' refer to in object-oriented design?

    <p>Hiding implementation details from users (B)</p> Signup and view all the answers

    Which of the following is NOT a key task in detailed design?

    <p>Implementing the software (B)</p> Signup and view all the answers

    What is the purpose of internal component design in detailed design?

    <p>Specifying the structure and behavior of internal modules (D)</p> Signup and view all the answers

    What is the primary purpose of using virtual functions in C++?

    <p>To allow derived classes to redefine functionality from the base class. (A)</p> Signup and view all the answers

    Which of the following features of object-oriented design is closely related to the concept of hiding data within a class?

    <p>Encapsulation (A)</p> Signup and view all the answers

    In the context of object-oriented design, how does abstraction differ from encapsulation?

    <p>Abstraction concerns itself with defining the interface of an object, while encapsulation hides its internal implementation details. (C)</p> Signup and view all the answers

    What is the primary benefit of using encapsulation in object-oriented programming?

    <p>Encapsulation promotes code reusability by separating functionality from implementation details. (D)</p> Signup and view all the answers

    Which of the following is a key difference between procedural-oriented design (POD) and object-oriented design (OOD)?

    <p>POD emphasizes modularity, while OOD prioritizes data encapsulation. (A)</p> Signup and view all the answers

    Which benefit of object-oriented design (OOD) allows for the creation of new objects based on existing ones, promoting code reuse?

    <p>Code Reusability (A)</p> Signup and view all the answers

    What is the key principle of object-oriented design (OOD) that hides unnecessary complexity and presents only essential features of an object?

    <p>Abstraction (C)</p> Signup and view all the answers

    Which of the following features of object-oriented design (OOD) refers to the ability of a programming language to treat objects differently based on their class or data type?

    <p>Polymorphism (B)</p> Signup and view all the answers

    Which type of polymorphism occurs during the compilation process, binding function calls with specific implementations at compile time?

    <p>Compile-time polymorphism (B)</p> Signup and view all the answers

    What is the main advantage of using abstract classes in object-oriented design?

    <p>They force derived classes to define their own implementations of abstract methods. (A)</p> Signup and view all the answers

    What does the term 'polymorphism' mean in the context of object-oriented programming?

    <p>Many forms (D)</p> Signup and view all the answers

    Which of the following is NOT a benefit of using object-oriented design (OOD) principles?

    <p>Increased complexity (B)</p> Signup and view all the answers

    How does overloading contribute to object-oriented design principles?

    <p>It enhances code modularity by allowing different functions with the same name to perform different tasks. (B)</p> Signup and view all the answers

    Study Notes

    CP317 Software Engineering - Low-level Design (Part 2)

    • Course information: CP317 Software Engineering, low-level design, part 2, week 4-2. Instructor: Shaun Gao, Ph.D., P.Eng.

    Agenda

    • Review of week 4-1 topics
    • Introduction to procedural-oriented design
    • Introduction to object-oriented design
      • Abstraction
      • Inheritance
      • Polymorphism
      • Encapsulation
    • Comparison of procedural-oriented design vs. object-oriented design
    • Summary

    Review of Week 4-1 Topics

    • Low-level (detailed) design concepts
    • Key tasks in detailed design: understanding requirements, architecture, and systems
    • Detailed design creation: interface design (internal/external), shared memory, inter-process communication (IPC)
    • Graphical User Interface (GUI) design
    • ASCII table use
    • Internal component design: structural & behavioral aspects
    • Data design and data structure design for detailed design
    • Documentation and evaluation of detailed design

    Introduction to Procedural-Oriented Design

    • Primary focus: functions
    • Step-by-step approach that guides applications through instruction sequences
    • Instructions executed in a specific order
    • Data structure: global and local data
    • Diagram shows the flow of control within a procedural-oriented program

    Procedural-Oriented Design Disadvantages

    • Data protection: data is not protected from unwanted access
    • Modification issues: adding new data requires modifying all functions accessing it
    • Modeling real world problems: less effective at representing real-world issues
    • Complexity & Scalability: becomes problematic when size/complexity increase; difficulties with modification/extension → lacks scalability
    • Vulnerability: easier to break (vulnerable) due to lack of proper structure

    Introduction to Object-Oriented Design

    • Classes: units defining objects (with properties/methods)
    • Constructor: special method initializing objects (a class usually has default constructor)
    • Destructor: special method automatically called when objects are destroyed (a class usually has default destructor)
    • Attributes: properties of a class (things that can be measured or observed)

    Object-Oriented Design (cont.)

    • Objects: created from classes via constructors (matched parameter types)
    • Relationship: between classes and objects

    Object-Oriented Design (cont.)

    • History of Object-oriented design: data -> methods
    • Object orientation combines data & methods into classes (cohesive wholes)
    • Object-Oriented Design (OOD): A process of designing interacting objects for software problem-solving
    • Comparison: Procedural-oriented design vs. Object-oriented design

    Object-Oriented Design (cont.)

    • Features: Abstraction, Inheritance, Polymorphism, Encapsulation
    • Benefits: code reusability (new objects from old), code modularity (object-based), easier maintenance, design stability

    Abstraction

    • Hiding unnecessary details and showing essential object features
    • No implementation details, just the concept
    • Benefits: reduced complexity and improved maintainability
    • Examples: abstract classes (declaring pure virtual member function in C++)

    Inheritance

    • Mechanism for derived classes to acquire properties from a base class
    • Benefits: increased productivity through code reuse and easier maintenance

    Polymorphism

    • Method naming consistency across various object data types (or class)
    • Polymorphism enables different behaviours depending on specific data types
    • Benefits: Code reuse and improved flexibility
    • Support different types of function calls

    Compile Time Polymorphism (Static Binding)

    • Binding is done during compile time
    • In C++, non-virtual functions are bound during compile time

    Run Time Polymorphism (Dynamic Binding)

    • Binding occurs during runtime
    • C++ uses virtual functions for run-time polymorphism

    Overloading

    • Technique allowing functions with the same name but different parameters for different behaviours within a class
    • Why Overloading is needed: allows greater flexibility in handling various data types or input sequences
    • Examples of Function Overloading

    Overriding

    • Function definition in a subclass that matches a method defined in a superclass
    • Method overrides offer custom implementation
    • Examples of Function Overriding

    Encapsulation

    • Hiding internal object characteristics and functionality (prevent outside modifications; users only see appropriate interfaces through public methods)
    • Benefits: improved software reliability, easier maintenance, reusability
    • Examples: setter(...) and getter() methods for accessing data elements inside an object

    Abstraction vs. Encapsulation

    • Abstraction: implementation hiding via abstract classes/interfaces
    • Encapsulation: data hiding via access modifiers (public, private, protected)

    POD vs. OOD

    • Procedural vs. Object-Oriented Programming
    • Procedural Programming
      • Global data
      • General function
      • Local data (variables)
    • Object-Oriented Programming
      • Objects
      • Properties
      • Methods
      • Objects

    POD vs. OOD (Advantages/Disadvantages)

    • Procedural Programming (Advantages): code reusability, program flow tracking, module construction
    • Procedural Programming (Disadvantages): global data vulnerability, complex data verification, difficult real-world modelling
    • Object-Oriented Programming (Advantages): task partitioning (in projects), secure programs (using data hiding), object categorizing/mapping, flexible code upgrade/enhancement through inheritance, eliminate redundant code, greater modularity, data abstraction enhances reliability, flexible dynamic binding
    • Object-Oriented Programming (Disadvantages): more resources required, complex behaviour & debugging, tight coupling in inheritance, message passing affects reusability

    Think-Pair-Share

    • Group projects: which OOP features can be utilized

    Summary

    • Procedural-oriented design
    • Object-oriented design
    • Abstraction (concept)
    • Inheritance (concept)
    • Polymorphism (concept)
    • Encapsulation (concept)
    • Differences between POD and OOD

    Announcement

    • Group formation deadline
    • Test 1 details (60 min, cover week 1-4 material), upcoming date, location (LH3094). Students need their laptops.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Description

    This quiz covers key concepts related to low-level design as part of the CP317 Software Engineering course. It focuses on procedural-oriented design, object-oriented design principles such as abstraction, inheritance, polymorphism, and encapsulation. Additionally, it compares these design paradigms and summarizes essential topics from previous weeks.

    More Like This

    Use Quizgecko on...
    Browser
    Browser