General Flashcards

1
Q

What is Test-Driven Development (TDD)?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Explain the SOLID principles in software engineering.

A

Single Responsibility Principle (SRP)
Open/Closed Principle (OCP)
Liskov Substitution Principle (LSP)
Interface Segregation Principle (ISP)
Dependency Inversion Principle (DIP)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the Single Responsibility Principle (SRP)?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can you explain the Open/Closed Principle (OCP)?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe the Liskov Substitution Principle (LSP).

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the Interface Segregation Principle (ISP) advocate for?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Explain the Dependency Inversion Principle (DIP).

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are some advantages of using Python over other programming languages for scripting tasks?

A

Python offers simplicity, readability, extensive standard libraries, cross-platform compatibility, and a vast ecosystem of third-party packages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is virtualenv in Python, and why would you use it?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you check the syntax of a Bash script without executing it?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the purpose of the shebang (#!) line in a Bash script?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Question: How can you pass arguments to a Bash script?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the purpose of the chmod command in Bash?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Explain the difference between grep, sed, and awk in Bash.

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

how can you redirect the output of a command to a file in Bash?

A

You can redirect the output of a command to a file using the > operator, like this: command > output.txt.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you debug a Bash script?

A

You can debug a Bash script by using the set -x command to enable debugging mode, which prints each command before executing it. Additionally, you can use echo statements to print variable values and intermediate results for troubleshooting purposes.

17
Q

What is Object-Oriented Programming (OOP), and what are its core principles?

A

OOP is a programming paradigm based on the concept of “objects,” which can contain data and code. Its core principles include encapsulation, inheritance, and polymorphism.

18
Q

Explain the concept of encapsulation in OOP.

A

Encapsulation is the bundling of data and methods that operate on the data into a single unit, known as a class. It hides the internal state of an object from the outside world and only exposes the necessary functionality through methods.

19
Q

What is inheritance in OOP, and how does it facilitate code reuse?

A

Inheritance is a mechanism where a new class inherits properties and behaviors from an existing class. It allows for the creation of a hierarchy of classes, with derived classes inheriting attributes and methods from their base classes, facilitating code reuse and promoting the DRY (Don’t Repeat Yourself) principle.

20
Q

Describe the difference between composition and inheritance.

A

Composition involves creating objects that contain other objects as attributes, while inheritance involves creating a hierarchy of classes where subclasses inherit properties and behaviors from superclasses. Composition typically favors “has-a” relationships, whereas inheritance favors “is-a” relationships.

21
Q

What is polymorphism in OOP, and how does it enhance code flexibility?

A

Polymorphism allows objects of different classes to be treated as objects of a common superclass. It enables code to work with objects of various types through a uniform interface, promoting flexibility and extensibility.

22
Q

What are abstract classes and interfaces, and how do they differ?

A

Abstract classes are classes that cannot be instantiated and may contain one or more abstract methods, while interfaces are collections of method signatures without implementations. Abstract classes can have both abstract and concrete methods, whereas interfaces only define method signatures.

23
Q

What is method overriding, and how does it relate to inheritance?

A

Method overriding occurs when a subclass provides a specific implementation for a method that is already defined in its superclass. It allows subclasses to customize the behavior of inherited methods to suit their specific needs.

23
Q

What is the DRY (Don’t Repeat Yourself) principle, and why is it important?

A

The DRY principle advocates for avoiding duplication of code by ensuring that each piece of knowledge in a system is represented in a single, unambiguous way. It promotes code reuse, reduces maintenance overhead, and improves code readability and consistency.

24
Q

What are some common code smells, and how can they be addressed?

A

Common code smells include duplicated code, long methods or classes, inappropriate coupling, and inappropriate naming conventions. They can be addressed by refactoring code to eliminate duplication, break down large methods or classes, reduce coupling, and improve naming clarity.

25
Q

What is the difference between imperative and declarative programming paradigms?

A

Imperative programming focuses on describing a sequence of steps to achieve a desired outcome, while declarative programming emphasizes describing what should be done rather than how it should be done. Declarative programming often leads to more concise, expressive code that is easier to understand and maintain.

26
Q

How does exception handling improve the robustness of a program?

A

Exception handling allows developers to gracefully handle unexpected or exceptional conditions that may arise during program execution. By catching and handling exceptions, developers can prevent program crashes, recover from errors, and maintain the stability and reliability of the software.

27
Q

Describe the difference between static and dynamic typing in programming languages.

A

Static typing requires variable types to be explicitly declared at compile time and enforces type checking at compile time, whereas dynamic typing allows variables to hold values of any type and performs type checking at runtime. Static typing can help catch type-related errors early in the development process, while dynamic typing offers more flexibility and expressiveness.

28
Q

How can you optimize the performance of a software application?

A

Performance optimization involves identifying and eliminating bottlenecks, reducing resource consumption, and improving the efficiency of critical algorithms and data structures. Techniques for optimizing performance include profiling, code refactoring, caching, parallelization, and algorithmic improvements.

29
Q

What role does continuous integration (CI) and continuous deployment (CD) play in developer productivity, and how would you implement these practices?

A

CI/CD practices automate the process of building, testing, and deploying software, enabling rapid iteration and feedback cycles. To implement CI/CD, I would set up automated build and test pipelines using tools like Jenkins or GitLab CI, integrate automated testing into the pipeline, and automate deployment to staging and production environments.

30
Q

How would you handle resistance to adopting new tools or processes from development teams?

A

I would address resistance by communicating the benefits of the proposed changes, soliciting feedback from team members, and involving them in the decision-making process. I would also provide training and support to help team members adapt to the new tools or processes and gradually introduce changes in a phased approach.

31
Q
A