Programming

Recursion

Recursion

Definition of Recursion:

Recursion is a programming technique where a function calls itself in order to solve smaller instances of the same problem until it reaches a base case that does not require further recursion.

Example in Python:

def factorial(n):
    """Calculate the factorial of a number using recursion."""
    if n == 0:
        return 1
    else:
        return n * factorial(n - 1)

# Example usage:
result = factorial(5)
print(f"The factorial of 5 is: {result}")

In this example, the factorial function calculates the factorial of a number n recursively. It calls itself with n - 1 until n reaches 0 (base case).

Becoming a Professional Software Developer

Becoming a Professional Software Developer

“Everybody wants to be a bodybuilder, but nobody wants to lift heavy ass weight”

Ronnie Coleman, 8x Mr. Olympia winner

Being a programmer is a lot like being a bodybuilder. Regular training, incremental progress, over and over again.

Over time this transforms the person from a beginner to a profesional.

Adopt this mindset in being a programmer. Plan to consistently train and improve your software engineering skills.

YAGNI

YAGNI

YAGNI is an acronym for “You Aren’t Gonna Need It”.

It’s an important principle in software development. Often it’s tempting to add code that could have useful utility down the road. In the end, it never ends up being used and creates overhead and code bloat.

So to follow YAGNI, don’t implement code until it actually needs to be utilized.

It’s a principle that comes from XP - Extreme Programming.

A "Simple" Change to a Web App

A "Simple" Change to a Web App

Imagine a basic web app (SPA, REST API, Sql database) with a new-user registration form. The form collects a first and last name of a new user. It is decided that the middle name needs to be collected on the form as well.

What changes need to be made to accomodate this?

  • The SQL table needs to have “middle_name” column added. Requires a DDL script.
  • The Java layer needs to update a USER entity to include middleName field. Java Change.
  • The REST API - if using a DTO, needs the DTO updated. Java Change.
  • The repository code, if implemented manually, needs to be updated. (Entity mapping can alleviate some changes). Java Change.
  • The UI needs to add a field in the form to collect the middle name, and likely modify the model stored in the UI. JavaScript/Typescript change.

Also unit tests need to be updated, flyway or liquidbase scripts, redeployments have to be scheduled (if the deployment pipeline is working). Checkstyles and test coverage re-ran.

Rules of Thumb for Software Developers

Rules of Thumb for Software Developers

Fetching Data

  • Remember Performance issues go unnoticed during development because the data set is too small - Vlad Mihalcea
  • A transaction should fetch only as much data as required by the current executing business logic - Vlad Mihalcea

Optimization

  • Premature optimization is the root of all evil - Donald E. Knuth
  • Measure performance before and after each attempted optimization. J Bloch
  • Programs spend 90 percent of their time in 10 percent of the code.

Design

  • The components of design that are most difficult to change after the fact are those specifying interactions between components and with the outside world. Cheif among these design components are APIs, wire-level protocols, and persistent data formats. Bloch
  • Strive to write good programs rather than fast ones. J Block