CP317 | Week 6 | Implementation

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 of the following is NOT a suggested practice for becoming a proficient programmer?

  • Reviewing your own code, applying SOLID principles.
  • Clarifying requirements before starting the coding process.
  • Being a meticulous developer, paying close attention to detail.
  • Focusing primarily on theoretical knowledge rather than practical problem-solving. (correct)

What is the potential consequence of incorrect coding during the implementation phase?

  • Increased hardware costs.
  • A slight delay in project timelines.
  • Minor inconveniences for end-users.
  • Severe accidents and system vulnerabilities. (correct)

What does 'Fail-safe default' refer to in software security considerations?

  • Automatically backing up data in case of system failure.
  • Granting access to all subjects unless explicitly denied.
  • Denying access to a subject unless explicit access is given. (correct)
  • Defaulting to the most secure settings upon installation.

Which of the following is NOT a typical benefit of adhering to a coding standard?

<p>Increased ambiguity in code interpretation. (A)</p> Signup and view all the answers

Why is software version control important in collaborative software development?

<p>It provides automatic backup and facilitates sharing on multiple computers. (B)</p> Signup and view all the answers

Which factor is most crucial when understanding and utilizing APIs in software development?

<p>Knowledge of functionalities, inputs, and outputs, combined with computer language and operating system skills. (D)</p> Signup and view all the answers

In software engineering, which characteristic is NOT necessarily a recommendation for writing good code?

<p>Complete focus on speed of delivery above all else. (B)</p> Signup and view all the answers

What is a 'side effect' in software engineering?

<p>A function modifying global variables or having an observable interaction outside of its scope. (A)</p> Signup and view all the answers

What is the primary difference between offensive and defensive programming?

<p>Defensive programming ensures continued function under attack with expected erroneous input, while offensive programming prioritizes not tolerating errors. (B)</p> Signup and view all the answers

In the context of exception handling, what is an exception?

<p>An event that occurs during program execution that disrupts the normal flow. (C)</p> Signup and view all the answers

What is a 'buffer' in the context of memory consumption?

<p>A region of physical memory storage used to store data. (B)</p> Signup and view all the answers

What is the key characteristic of a buffer overflow?

<p>Writing more data into a buffer than it can hold. (C)</p> Signup and view all the answers

Which of the following situations is most likely to cause a memory leak?

<p>Allocating memory without releasing it when no longer needed. (A)</p> Signup and view all the answers

Why is minimizing the number of local variables in a function beneficial?

<p>It allows the compiler to fit variables into registers, avoiding frame pointer operations. (D)</p> Signup and view all the answers

What is a potential drawback of function calls with a large number of parameters?

<p>It can be expensive due to parameter pushes on the stack. (B)</p> Signup and view all the answers

What defines a safety-critical system?

<p>A system whose failure may result in serious injury or death. (D)</p> Signup and view all the answers

In the context of safety considerations, what is 'redundancy'?

<p>A design method where a component is duplicated so there is a backup if one fails. (C)</p> Signup and view all the answers

What benefit is gained by using initialization in object construction rather than assignment?

<p>It can be faster and more efficient. (A)</p> Signup and view all the answers

Which principle should developers adhere to when writing constructors in object-oriented programming?

<p>Constructors should be as lightweight and simple as possible. (C)</p> Signup and view all the answers

What is the general rule regarding exceptions within destructors?

<p>Never allow exceptions to leave destructors. (C)</p> Signup and view all the answers

Which of the following best describes the Single Responsibility Principle?

<p>A class should have one and only one reason to change. (A)</p> Signup and view all the answers

Which of the following adheres to the Open/Closed Principle?

<p>Designing modules that are open for extension but closed for modification. (A)</p> Signup and view all the answers

Which principle focuses on ensuring that derived classes can be substituted for their base classes without altering the correctness of the program?

<p>Liskov Substitution Principle (A)</p> Signup and view all the answers

What best describes the Interface Segregation Principle?

<p>Clients should not be forced to depend on methods that they do not use. (B)</p> Signup and view all the answers

Which of the following describes the Dependency Inversion Principle?

<p>High-level modules should not depend on low-level modules; both should depend on abstractions. (D)</p> Signup and view all the answers

Flashcards

Coding standard

A set of guidelines, rules, programming styles and conventions that software developers adhere to when writing source code for a project.

Software version control

Managing and tracking changes to documents, computer programs, and configurations over time.

Side effect (in programming)

A function modifies global variables or has an observable interaction outside of its scope.

Defensive programming

Designing software to continue functioning even when under attack, or encountering errors.

Signup and view all the flashcards

Offensive programming

Expects a program to not tolerate errors, particularly in the face of software bugs.

Signup and view all the flashcards

Exception (in programming)

An event that occurs during program execution that disrupts the normal flow of instructions.

Signup and view all the flashcards

Buffer (in memory)

A dedicated memory area, it holds data being transferred between devices or processes.

Signup and view all the flashcards

Buffer overflow

When a process writes data beyond the allocated size of a buffer, overwriting adjacent memory locations.

Signup and view all the flashcards

Stack overflow

An undesirable condition in which a program exceeds stack memory limits.

Signup and view all the flashcards

Memory leak

A type of memory consumption where a program fails to release memory when it is no longer needed.

Signup and view all the flashcards

Safety-critical system

A system whose failure could result in injury or death.

Signup and view all the flashcards

Redundancy (in software engineering)

A design method in which a component is duplicated so if it fails there will be a backup

Signup and view all the flashcards

Light Constructors

Constructors should be as direct and simple as possible

Signup and view all the flashcards

Destructors and exceptions

Never let destructors throw exceptions

Signup and view all the flashcards

Requirement Clarification

The process of clarifying requirements before starting.

Signup and view all the flashcards

Software Security

Software security is an important consideration that can lead to system vulnerabilities if implemented poorly.

Signup and view all the flashcards

Fail-safe Default

Unless there is an explicit access to an object, it should be forbidden

Signup and view all the flashcards

Integrated Development Environment (IDE)

Using tools such as Visual Studio and Eclipse

Signup and view all the flashcards

Study Notes

Review of Week 5 Topics

  • Object-oriented design includes association, aggregation, and composition.
  • SOLID principles are: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.
  • The Single Responsibility Principle states that a class should have one reason to change.
  • The Open/Closed Principle states that software components should be open for extension but closed for modification.
  • Liskov’s Substitution Principle states that derived types must be completely substitutable for their base types.
  • The Interface Segregation Principle states that clients should not be forced to implement unnecessary methods.
  • The Dependency Inversion Principle states to depend on abstractions, not concretions.

Introduction to Implementation

  • Implementation is equal to coding.
  • Becoming a great programmer involves clarifying requirements, being meticulous, problem-solving, debugging, reviewing code with SOLID principles, continuous learning, and proficient Googling.

Software Security Considerations

  • Software security should be a consideration during implementation.
  • Incorrect coding leads to vulnerabilities and system accidents.
  • A buffer overflow is an example of a security vulnerability.
  • Fail-safe default means that access to an object should be denied unless explicitly granted.

Coding Standard

  • A coding standard is a set of guidelines and conventions for software developers.
  • Benefits of using coding standards include improved software quality, quicker debugging, easier code review, conflict avoidance, and better collaboration.

Programming Tools

  • Programming tools include compilers, linkers IDEs (Integrated Development Environments).
  • Examples of IDEs includes Visual Studio, Visual Studio Code and Eclipse.

Software Code/Version Control

  • Software code/version control involves managing changes to documents and computer programs.
  • Benefits of version control includes automatic backup, multiple computer sharing, version control and version maintenance.
  • Github and ClearCase are version control systems (VCS).

Understanding APIs

  • Understand application programming interfaces (APIs) which requires knowledge of functionalities, inputs, and outputs, as well as computer language and operating system skills.
  • Object-oriented programming APIs include C++, .NET C#, and Java.
  • Knowledge of API theory and mechanism is essential.

Recommendations

  • Writing good code can be difficult; strive for high cohesion, low coupling, and adherence to SOLID principles.
  • Coding is a level of design.
  • A good code designer should be a programmer.

Unexpected Situations

  • Unexpected situations need to be handled.
  • Questions you should about API failures is “should the process continue or stop?”.
  • Creative thinking and attention to detail are crucial.

Comments

  • Write sufficient comments.
  • Comment outlines should adhere to coding standards, improving code understanding and maintenance.

Side Effects

  • The goal is to avoid side effects.
  • Side effects occur when a function modifies global variables or has interactions outside its scope.

Offensive and Defensive Programming

  • Defensive programming involves designing software to continue functioning under attack by expecting erroneous input.
  • Offensive programming departs from defensive principles by prioritizing the avoidance of errors stemming from software bugs.

Exception Handling

  • An exception is an event that occurs during program execution and they can be inside or outside.
  • Exception handling helps create reliable systems and separates error handling logic.

Memory Consumption

  • A buffer is a physical memory region used for data.
  • Buffer overflow happens, when a process writes more data into a buffer than it can hold.
  • Stack based buffer overflow is equal to a stack overflow.
  • Heap based buffer overflow is equal to a heap overflow.
  • Stack overflow condition, may occur when computer program tries to use more memory space than the stack size.
  • Memory leaks happen, when software fails to release required memory.
  • Memory leaks cause impaired performance
  • Avoiding repeating memory allocations without releases is suggested

Function Calls

  • Minimizing local variables and function parameters can improve performance in C/C++, avoiding expensive frame pointer operations or excessive pushing onto the stack.
  • It is best to avoid cascaded function calls, which can be hard for debugging in non-scripting languages

Safety Considerations

  • Critical systems include medical devices, airplanes and automatic control train systems because failure in these systems may result in serious injury or even death.
  • Real Time Operating Systems (RTOS) handle data in strict time frames.
  • Redundancy: in software engineering, it is a design method in which a component is duplicated so if it fails there will be a backup.
  • Employing system redundancy improves the reliability of computerized systems, as seen in online banking, control systems, and Hadoop applications.

Constructors/Destructors

  • It is best to keep constructors lightweight (simple), and perform the necessary initialization including resource allocation within it.
  • Destructors should prioritize releasing resources allocated in the heap.
  • For initialization, the use of Color c(black) is faster than Color c; c = black;.
  • It is best to keep destructors simple.
  • Never allow exceptions to leave destructors.

Announcement

  • The group project is to start.
  • There is no class next week as it is reading week.

Studying That Suits You

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

Quiz Team

Related Documents

More Like This

SOLID Principles Quiz
5 questions

SOLID Principles Quiz

BeneficentCanyon avatar
BeneficentCanyon
Introduction to SOLID Principles
19 questions
Introduction to SOLID Principles
10 questions

Introduction to SOLID Principles

BuoyantBaritoneSaxophone9882 avatar
BuoyantBaritoneSaxophone9882
Object-Oriented Design and SOLID Principles
25 questions
Use Quizgecko on...
Browser
Browser