Skip to main content

Posts

Showing posts from July, 2020

Solve the Downcasting-Problem of Django Models

In Django, I cannot downcast (attributes are missing). Any trivial solution breaks the Open-Closed Principle. This Solution not: from django.db import models class ParentModel ( models . Model ): type = models.CharField( max_length = 255 , default = 'item' ) class Meta : abstract = True def save (self, *args, **kwargs): self .type = self .type_str super ().save(*args, **kwargs) @ staticmethod def register_subtype (clazz): the_type = clazz.type_str if not hasattr (ParentModel, 'subclasses' ): ParentModel.subclasses = {} ParentModel.subclasses[the_type] = clazz def downcast (self): if self .type not in ParentModel.subclasses: return self return ParentModel.subclasses[ self .type].objects.get( pk = self .pk) With the example Item: class Item ( ParentModel ): """Stuff you can purchase""" type_str = 'item' ...

Traveling with the speed of light

Traveling with the speed of light is only possible if we can sperate our mind from our body. Downloading and uploading. Before using clones or other bodies we have to be able to upload it to a robot. The singularity comes before the speed of light traveling. Separating our minds from our bodies is the key to human survival.

Futureproof Software

From here:  https://dzone.com/articles/the-secrets-of-futureproof-software Self-healing Self-patching, or more broadly, self-updating Backward compatibility Dynamic adaptation/ability to evolve over time Intent-based Made up of reusable futureproof components