Architecture, Paradigmas, Design Patterns, Principles, Clean Code

  • Architecture: description of system (structure, relationships, collaboration)
  • Programming Paradigmas: imperative, functional, object-oriented
  • Design Pattern: usually parts of the systems; generic solution design for a problem; an architecture uses many design patterns
  • Programming Principles: SOLID, Law of Demeter, etc.; generic best practices
  • Clean Code: lowest level, actual source code; e.g. code formatting, lines per functions;

Windows 10 & Docker: volumes not working

Make sure you have your firewall settings correct and issues with File/Print-Sharing fixed. Follow the article https://blog.olandese.nl/2017/05/03/solve-docker-for-windows-error-a-firewall-is-blocking-file-sharing-between-windows-and-the-containers/ .

For me following commands is necessary (since some parts are managed by corporate sys-admins and AD). (So that the Docker is moved into the private network category, where the firewall rules can be applied.)

Set-NetConnectionProfile -interfacealias "vEthernet (DockerNAT)" -NetworkCategory Private

Django (SQL/”Model”) Performance Optimization

Django makes it easy to write code, which performs bad, since it is automatically executing SQL statements when you are handling models. If you don’t know about the details behind that, you can easily end up executing thousands of queries.

def get_books_by_author():
    books = Book.objects.all()
    result = defaultdict(list)    
    for book in books:
        author = book.author
        title_and_author = '{} by {}'.format(
            book.title,
            author.name
        )
        result[book.library_id].append(title_and_author)    return result

This will execute for each book an author query! Which means 1 query for books and n queries for n books!

books = Book.objects.all().select_related('author')

This will add “author” into the Book.objects.all() query and you just execute one query!

However, select_related only works for one-to-many and one-to-one. Many to one relations can be optimized with prefetch_related().

Continue reading “Django (SQL/”Model”) Performance Optimization”

Async: how it is handled internally in JS (Tasks, Microtasks/Jobs, Queues, Schedule)

I have found this wonderful step-by-step-diagramms in an article from I want to share with you: https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/ It also contains an example with event bubbling 🙂

In summary:

  • Tasks execute in order, and the browser may render between them
  • Microtasks execute in order, and are executed:
    • after every callback, as long as no other JavaScript is mid-execution
    • at the end of each task

What programming language should I learn?

Well, you might have noticed, I am an excessive medium reader. This time I stumbled across an article about, what programming languages should I learn (as a beginner). Whereas most suggestions are either Python or JavaScript, Eric Girouard suggests the one and only fundamental thing in computer science: Logic! If you are able to solve problems logically fitting to a computer’s “mind”, it doesn’t matter which programming language you are using to express it.