General Flashcards
What is Test-Driven Development (TDD)?
TDD is a software development process where tests are written before the actual code. Developers write failing tests first, then write the minimum amount of code necessary to pass the tests, and finally refactor the code to improve its design without changing its behavior.
Explain the SOLID principles in software engineering.
Single Responsibility Principle (SRP)
Open/Closed Principle (OCP)
Liskov Substitution Principle (LSP)
Interface Segregation Principle (ISP)
Dependency Inversion Principle (DIP)
What is the Single Responsibility Principle (SRP)?
SRP states that a class should have only one reason to change, meaning it should only have one responsibility or encapsulate one aspect of the software’s functionality.
Can you explain the Open/Closed Principle (OCP)?
OCP states that software entities (classes, modules, functions, etc.) should be open for extension but closed for modification. This means that the behavior of a module can be extended without modifying its source code.
Describe the Liskov Substitution Principle (LSP).
LSP states that objects of a superclass should be replaceable with objects of its subclass without affecting the correctness of the program. In other words, derived classes must be substitutable for their base classes.
What does the Interface Segregation Principle (ISP) advocate for?
ISP suggests that clients should not be forced to depend on interfaces they don’t use. It promotes the idea of segregating interfaces into smaller and more specific ones.
Explain the Dependency Inversion Principle (DIP).
DIP states that high-level modules should not depend on low-level modules, but both should depend on abstractions. It promotes loose coupling between software modules by ensuring that high-level modules are not directly dependent on the implementations of low-level modules.
What are some advantages of using Python over other programming languages for scripting tasks?
Python offers simplicity, readability, extensive standard libraries, cross-platform compatibility, and a vast ecosystem of third-party packages.
what is virtualenv in Python, and why would you use it?
virtualenv is a tool used to create isolated Python environments. It allows you to install Python packages into an environment without affecting the system-wide Python installation, making it useful for managing dependencies in projects.
How do you check the syntax of a Bash script without executing it?
You can check the syntax of a Bash script using the bash -n command followed by the script’s filename, like this: bash -n script.sh.
What is the purpose of the shebang (#!) line in a Bash script?
The shebang line specifies the interpreter that should be used to execute the script. For example, #!/bin/bash indicates that the script should be run using the Bash interpreter.
Question: How can you pass arguments to a Bash script?
You can pass arguments to a Bash script by specifying them after the script’s filename when executing it, like this: ./script.sh arg1 arg2.
What is the purpose of the chmod command in Bash?
The chmod command is used to change the permissions of files and directories in Unix-like operating systems. It allows you to specify who can read, write, and execute a file or directory.
Explain the difference between grep, sed, and awk in Bash.
grep is used to search for patterns in text files, sed is used to perform text transformations on files, and awk is a versatile text-processing tool for extracting and manipulating data.
how can you redirect the output of a command to a file in Bash?
You can redirect the output of a command to a file using the > operator, like this: command > output.txt.