Design Patterns: Creational Patterns
40 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

Which scripting technique focuses primarily on separating data from scripts for varied test runs?

  • Keyword driven testing
  • Linear scripting
  • Data driven scripting (correct)
  • Structured scripting
  • What is a characteristic of structured scripting?

  • It allows decision-making using control statements like 'if-else'. (correct)
  • It enables simple record and playback without control structures.
  • It depends on external files for its operations.
  • It defines shared behaviors across multiple scripts.
  • In the context of shared scripting, what does modularity imply?

  • Common functionalities can be reused across different scripts. (correct)
  • The script acts as a large, monolithic entity with no separation.
  • Scripts can only interact within a single application.
  • Scripts must be fully independent with no shared components.
  • Which technique utilizes external data files to define both test data and operation sequences?

    <p>Keyword driven testing</p> Signup and view all the answers

    What is a potential drawback of linear scripting?

    <p>It provides no structure for controlling script flow.</p> Signup and view all the answers

    What is the main focus of data driven scripting?

    <p>Storing test data separately to prevent script modification.</p> Signup and view all the answers

    Which scripting technique would be best suited for applications requiring frequent modifications to shared behaviors?

    <p>Shared scripting</p> Signup and view all the answers

    Which of the following describes the purpose of keyword driven testing?

    <p>It employs an additional library to interpret external data for testing.</p> Signup and view all the answers

    What is the primary function of a compiler in programming?

    <p>Translates code from one programming language to another.</p> Signup and view all the answers

    Which of the following is NOT a client-side scripting language?

    <p>Python</p> Signup and view all the answers

    What role does client-side scripting play in web development?

    <p>Reduces the amount of server processing required.</p> Signup and view all the answers

    What was the original name of JavaScript before its rebranding?

    <p>LiveScript</p> Signup and view all the answers

    How does an interpreter differ from a compiler?

    <p>An interpreter executes code directly without compilation.</p> Signup and view all the answers

    Which statement accurately reflects the use of JavaScript in web development?

    <p>JavaScript was originally created to enhance HTML and CSS.</p> Signup and view all the answers

    When a browser requests a webpage, what does the server provide?

    <p>HTML and CSS as plain text.</p> Signup and view all the answers

    What is the function of CSS in web development?

    <p>To style and design graphic elements on a web page.</p> Signup and view all the answers

    What is the primary purpose of creational design patterns?

    <p>To create objects based on specific criteria.</p> Signup and view all the answers

    What benefit do design patterns provide during software development?

    <p>They provide standardized solutions for common problems.</p> Signup and view all the answers

    Which classification of design patterns focuses on the organization of classes and objects?

    <p>Structural patterns</p> Signup and view all the answers

    What is a distinguishing feature of object-creation patterns?

    <p>They focus on delegation in the instantiation process.</p> Signup and view all the answers

    Which of the following statements about behavioral patterns is true?

    <p>They help to identify communication patterns between objects.</p> Signup and view all the answers

    How do structural class-creation patterns differ from structural object-patterns?

    <p>Structural class-creation patterns primarily use inheritance.</p> Signup and view all the answers

    What is the main reason for reusing design patterns in software design?

    <p>To enhance code readability and prevent subtle issues.</p> Signup and view all the answers

    Which design pattern category is least likely to be used for enhancing functionality through object composition?

    <p>Creational patterns</p> Signup and view all the answers

    What does the $this keyword refer to in PHP?

    <p>The current object inside methods</p> Signup and view all the answers

    How can the value of the $name property be changed outside the class?

    <p>By directly changing the property value</p> Signup and view all the answers

    What is the role of the extends keyword in PHP?

    <p>To inherit properties and methods from a parent class</p> Signup and view all the answers

    What is required to define a user-defined function in PHP?

    <p>The function name followed by parentheses</p> Signup and view all the answers

    What does passing an argument to a function in PHP resemble?

    <p>A variable used locally within the function</p> Signup and view all the answers

    Which statement is true regarding the Strawberry class in relation to the Fruit class?

    <p>It extends the Fruit class and inherits its properties</p> Signup and view all the answers

    Which of the following is an essential characteristic of functions in PHP?

    <p>They are blocks of code used repeatedly</p> Signup and view all the answers

    What must occur for a user-defined function to execute?

    <p>It must be called using its name with parentheses</p> Signup and view all the answers

    What is the purpose of the CREATE DATABASE statement in MySQL?

    <p>To create a new database</p> Signup and view all the answers

    Which attribute ensures a column can only hold positive numbers and zero in MySQL?

    <p>UNSIGNED</p> Signup and view all the answers

    What must be true about the SQL query when inserting data into a MySQL database using MySQLi?

    <p>It must be quoted in PHP</p> Signup and view all the answers

    What is the function of the WHERE clause in a MySQL SELECT statement?

    <p>To filter records based on specified conditions</p> Signup and view all the answers

    What does the ORDER BY clause do in a MySQL query?

    <p>Sorts the result set in ascending or descending order</p> Signup and view all the answers

    In which scenario would you use the AUTO INCREMENT attribute in a MySQL table?

    <p>For assigning unique identifiers to a field automatically</p> Signup and view all the answers

    Which of the following is NOT a rule for inserting data into a MySQL table?

    <p>Numeric values must be quoted</p> Signup and view all the answers

    Which column setting would you use to ensure that each row in a table has a unique identifier?

    <p>PRIMARY KEY</p> Signup and view all the answers

    Study Notes

    Design Patterns

    • Design patterns categorize into 3 sub-classifications: Creational, Structural, and Behavioral patterns
    • Creational patterns focus on object creation based on specific criteria and controlled instantiation.
    • Structural patterns are about organizing classes and objects into larger structures, offering new functionality.
    • Behavioral patterns identify and implement common communication patterns between objects.
    • Design patterns improve code readability for programmers familiar with them
    • Design patterns help prevent subtle issues leading to major software issues.

    Creational Patterns

    • Abstract Factory - provides an interface for creating families of related objects. Ensures consistency within a family.
    • Builder - separates the construction of a complex object from its representation
    • Factory Method defines an interface for creating objects. Allows subclasses to decide which class to instantiate.
    • Prototype: specifies the kinds of objects to create using a prototypical instance. Creates new objects by copying this prototype.
    • Singleton: ensures that a class has only one instance and provides a global point of access.

    Structural Patterns

    • Adapter: converts the interface of a class into another interface clients expect. Enables incompatible classes to work together.
    • Bridge: Decouples an abstraction from its implementation. Allows both to vary independently
    • Composite: composes objects into tree structures to represent part-whole hierarchies. Lets clients treat individual objects and compositions uniformly.
    • Decorator: dynamically adds responsibilities to an object. Provides a flexible alternative to subclassing for extending functionality.
    • Facade: provides a simplified interface to a complex subsystem
    • Flyweight: shares objects to support large numbers of fine-grained objects efficiently. Uses sharing to support large numbers of fine-grained objects efficiently
    • Proxy: provides a surrogate or placeholder for another object to control access to it.

    PHP - The '$this' Keyword

    • Refers to the current object
    • Only available inside methods
    • Allows access and manipulation of object properties and methods within the object's context

    PHP - Inheritance

    • A child class inherits properties and methods from a parent class using the extends keyword.
    • Inherited classes can have their own properties and methods in addition to those inherited.
    • Inheritance allows code reuse and creates a hierarchy of classes.

    PHP - User-Defined Functions

    • Functions are reusable blocks of code that perform specific tasks
    • Defined using the function keyword followed by the function name and parentheses.
    • Code within the function is executed only when the function is called.
    • Can accept arguments (inputs) and return values (outputs)

    Scripting Techniques for Test Automation

    • Linear scripting: simple record and playback of user actions. Can be redundant and inflexible.
    • Structured scripting: incorporates control structures like if-else, for and while loops for decision-making and iteration.
    • Shared scripting: Develops reusable scripts for common functionality across different tests. Enhances modularity and code reuse.
    • Data-driven scripting: Separates test data from the script, stored in external data files. Provides flexibility to adjust test data without modifying the script.
    • Keyword-driven testing: Uses keywords to represent test actions and stores them in external data files. Requires a library for interpretation.

    Client-Side Scripting

    • Client-side scripting executes code in the user's browser (client) without needing server interaction.
    • This speeds up website performance and reduces server load.
    • Examples include JavaScript, HTML, and CSS.
    • JavaScript is widely used for dynamic web page elements, user interaction, and validation.

    Javascript

    • Initially called LiveScript.
    • Released with Netscape 2.0 in 1995.
    • Server-side JavaScript frameworks are also available.

    MySQLi

    • MySQLi is a PHP extension for interacting with MySQL databases.

    Opening a Connection to MySQL

    • The mysqli_connect() function establishes a connection to a MySQL server.

    Creating a MySQL Database

    • The CREATE DATABASE statement creates a new database.

    Creating a MySQL Table

    • The CREATE TABLE statement creates a new table within a database.
    • It defines columns, their data types, and optional attributes like NOT NULL, DEFAULT, AUTO_INCREMENT, and PRIMARY KEY.

    Inserting Data Into MySQL

    • The INSERT INTO statement adds new records to a table.
    • String values are enclosed in single quotes.
    • Numeric values are not quoted.
    • The word NULL is not quoted.

    Selecting Data From MySQL

    • The SELECT statement retrieves data from a table.

    Filtering Data with WHERE Clause

    • The WHERE clause filters selected data based on specified conditions.

    Ordering Data with ORDER BY Clause

    • The ORDER BY clause sorts the retrieved data in ascending or descending order.
    • The default order is ascending.

    Studying That Suits You

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

    Quiz Team

    Related Documents

    Week 7.docx

    Description

    Test your knowledge on Creational Design Patterns, a part of the larger concept of design patterns in software development. This quiz covers essential patterns like Abstract Factory, Builder, Factory Method, and Prototype, focusing on object creation strategies. Improve your understanding of how these patterns enhance code readability and prevent software issues.

    More Like This

    Software Design Patterns Overview
    12 questions
    Creational Patterns in Design
    29 questions
    Creational Patterns Quiz
    17 questions
    Use Quizgecko on...
    Browser
    Browser