Junior — Middle
What are the main principles of software development you apply in your work?
sobes.tech AI
Answer from AI
The main principles of software development that I apply:
- Clean code: I write code that is easy to read and maintain, using clear variable and function names.
- Single Responsibility Principle (SRP): each function or module is responsible for one task.
- DRY (Don't Repeat Yourself): I avoid code duplication by extracting repeating parts into functions or packages.
- Testability: I write unit tests for key components to ensure reliability.
- Idempotency and error handling: I handle errors and exceptions correctly so that the application does not crash.
- Use of interfaces: for abstraction and simplifying the replacement of implementations.
An example in Go demonstrating the single responsibility principle and interfaces:
package main
import "fmt"
type Notifier interface {
Notify(message string) error
}
type EmailNotifier struct {}
func (e EmailNotifier) Notify(message string) error {
fmt.Println("Sending email with message:", message)
return nil
}
func SendAlert(n Notifier, msg string) {
err := n.Notify(msg)
if err != nil {
fmt.Println("Error sending notification:", err)
}
}
func main() {
email := EmailNotifier{}
SendAlert(email, "Server is down!")
}
This approach facilitates maintenance and code extension.