Skip to the main content
Photo from unsplash: marek-okon-WScpndZFrOM-unsplash_trqbmo

Back to Basics: Coding Fundamentals for Data Engineering, DevOps, and Cloud Engineering in Python & Scala

Written on October 26, 2023 by Rab Mattummal.

6 min read
––– views
Read in Dutch

Back to Basics: Coding Fundamentals for Data Engineering, DevOps, and Cloud Engineering

In the ever-evolving landscape of data engineering, DevOps, and cloud engineering, it's easy to get lost in the complexity of tools, platforms, and frameworks. However, amidst all the advanced technologies, it's crucial not to forget the fundamental coding principles that form the bedrock of these domains. In this journal, we'll explore these essential coding fundamentals and understand why they are vital for your Python and Scala projects.

The Role of Fundamentals

Fundamentals are like the foundation of a building. They provide stability, structure, and a basis for everything else that comes afterward. In data engineering, DevOps, and cloud engineering, coding fundamentals are just as essential. They ensure your projects are robust, maintainable, and scalable. Here are some of the key coding fundamentals to keep in mind:

1. Clean Code

Clean code is the hallmark of a proficient engineer. It involves writing code that is easy to read, understand, and maintain. Following coding conventions and keeping your codebase well-organized is the first step toward achieving clean code. In Python, this might mean adhering to PEP 8 guidelines, while Scala developers can focus on consistent naming conventions and style.

# Python Example
def calculate_average(numbers):
    total = sum(numbers)
    count = len(numbers)
    return total / count
// Scala Example
def calculateAverage(numbers: List[Double]): Double = {
  val total = numbers.sum
  val count = numbers.length
  total / count

2. Documentation

Clear and concise documentation is essential for onboarding new team members and maintaining existing projects. In data engineering, DevOps, and cloud engineering, this becomes even more critical as your codebase interacts with various systems and APIs. Proper documentation ensures that anyone who works on the project can understand its purpose, functionality, and usage.

<!-- Markdown Example -->
## Calculate Average
This function takes a list of numbers and returns their average.
- `numbers` (List): A list of numbers.
- `average` (float): The average of the input numbers.

3. Modularity

In large and complex projects, modularity is key. It involves breaking your code into smaller, self-contained modules or functions. This makes your code easier to test, maintain, and scale. In Python and Scala, leveraging the concept of modules and packages can help you achieve modularity.

# Python Example
def add(a, b):
    return a + b
def subtract(a, b):
    return a - b
from math_operations import add, subtract
result = add(5, 3)
// Scala Example
// MathOperations.scala
object MathOperations {
  def add(a: Int, b: Int): Int = a + b
  def subtract(a: Int, b: Int): Int = a - b
// Main.scala
object Main extends App {
  val result = MathOperations.add(5, 3)

4. Error Handling

In real-world projects, errors are inevitable. Effective error handling is crucial for data engineering and DevOps tasks, as a single failure can have cascading effects. Python and Scala provide mechanisms to handle errors gracefully, ensuring your systems remain robust and reliable.

# Python Example
    result = divide(10, 0)
except ZeroDivisionError:
    print("Error: Division by zero.")
    result = None
# Scala Example
val result = try {
  divide(10, 0)
} catch {
  case _: ArithmeticException =>
    println("Error: Division by zero.")

5. Efficiency

Efficiency isn't just about writing code that works; it's about writing code that performs well. In data engineering and cloud engineering, where massive data processing is common, inefficient code can lead to performance bottlenecks. Profiling your code, optimizing algorithms, and minimizing resource consumption are essential.

# Python Example
from datetime import datetime
start_time =
# Code to optimize
end_time =
execution_time = end_time - start_time
print(f"Execution Time: {execution_time}")
// Scala Example
val startTime = System.nanoTime
// Code to optimize
val endTime = System.nanoTime
val executionTime = (endTime - startTime) / 1e6 // Milliseconds
println(s"Execution Time: $executionTime ms")

6. Version Control

Version control systems like Git are indispensable for collaboration, tracking changes, and rolling back to previous versions if necessary. Whether you're working on data pipelines or infrastructure as code, understanding how to use version control effectively is a fundamental skill.

# Git Example
git init
git add .
git commit -m "Initial commit"
git branch development
git checkout development
git push origin development

7. Testing

Testing is the safety net of your codebase. In Python, you can use libraries like unittest and pytest, while Scala offers testing frameworks like ScalaTest. A solid testing strategy ensures that your code behaves as expected and allows for future changes without introducing new bugs.

# Python Example (unittest)
import unittest
class TestMathOperations(unittest.TestCase):
    def test_add(self):
        self.assertEqual(add(5, 3), 8)
    def test_subtract(self):
        self.assertEqual(subtract(5, 3), 2)
if __name__ == '__main__':
// Scala Example (ScalaTest)
import org.scalatest.flatspec.AnyFlatSpec
import MathOperations._
class MathOperationsSpec extends AnyFlatSpec {
  "The add method" should "return the sum of two numbers" in {
    assert(add(5, 3) == 8)
  "The subtract method" should "return the difference of two numbers" in {
    assert(subtract(5, 3) == 2)

8. Security

Security should be at the forefront of your coding practices, especially in DevOps and cloud engineering. It involves safeguarding your code, configurations, and sensitive data. Regular security audits and adhering to security best practices are fundamental.

9. Optimisation

Optimisation goes beyond efficiency; it's about making your code perform better. Whether you're writing data transformation scripts or configuring cloud resources, understanding how to optimize your code or configurations can lead to significant cost savings and improved performance.

Learning and Practicing Fundamentals

While it's exciting to explore advanced technologies and tools, dedicating time to reinforce coding fundamentals is equally important. As you work on

your Python and Scala projects in data engineering, DevOps, or cloud engineering, keep these fundamentals in mind. By doing so, you'll build a solid foundation that ensures your projects are efficient, maintainable, and successful.

Remember, in the world of data engineering and DevOps, getting the basics right can make all the difference. Embrace these coding fundamentals as your guiding principles, and watch your projects thrive.

Have you had any experiences where coding fundamentals made a significant impact on your projects? Share your thoughts and insights in the comments below.

Tweet this article

Liking it?

Don't overlook this opportunity. Receive an email notification each time I make a post, and rest assured, there won't be any spam.