database design – Integrity of polymorphic association data at two different tables

Let's say that I have a very large list of students to filter if each of these students meets certain specific limits of the school and the class. So in my data model, I have School and Classroom entities. The limitations (let's call them filters) are like

  • Age is greater than 9
  • The score is equal to 2
  • Wants to use the school bus

Classrooms and school have the same filters, but class filter values ​​take precedence over school filters. If there is no specific filter defined for the class, the one for schools will be used.
For example, the school filter definition is as follows:

  • Age is more than 7 years old
  • Must want to use the school bus

But the definition of the class is:

In this example, if a student is over 10 years and wants to use the school bus, I can assign it to the class.

Here is my database design:

school
----------
id
name
...

classroom
----------
id
name
school_id
...

filter
----------
id: primary_key
name: string

filter_data
----------
id: primary_key
filter_id - FK to filter.id
owner_id - Polymorphic association to `School` and `Classroom` (the main point of my question)
filter_type - ENUM('CLASSROOM', 'SCHOOL')
operator - should be a from a defined list of comparison operators such as: >, <, =, !=, etc...
filter_value - The value to filter against.

Some examples of data:

school
------
ID   |  name
-----+------
1    |  School #1
2    |  School #2

classroom
------
ID   |  name          | school_id
-----+----------------|----------
1    |  Classroom #1  | 1
2    |  Classroom #2  | 1

filter
------
ID   |  name
-----+------
1    |  Age
2    |  Grade
3    |  School bus

filter_data
------------
ID   | filter_id  | owner_id       | filter_type | operator | filter_value
-----+------------+----------------+-------------+----------+-------------
1    | 1          | 1              | SCHOOL      | >        | 7
2    | 1          | 1              | CLASSROOM   | >        | 10
3    | 3          | 1              | SCHOOL      | =        | 1

With this structure, I can easily query and understand that, to assign a student to Classroom #1, the age of the student must be above 10 years and must want to use the school bus.

And now the question: as you can see, there is a polymorphic association for the filter_data.owner.id, it can refer to School or Classroom and I lose important functionality from the use of foreign keys, like data integrity. A search for ideas to have a better extensible design that guarantees data integrity.

Plan to use PostgreSQL if it helps.

python – Design of a turn-based dice game

I'm trying to build an irc-bot that serves as the manager of a multiplayer, turn-based, dice-rolling game. The bot listens to all messages on the channel. When the connections, it creates a Game example with all the players, except him, present in the chain.

There are two types of players in the game, regular players and lords. Being a lord is a cumulative property, you can be a lord with one count, with two, and so on.

The purpose of the first round is to assign lords. Each player must roll the dice at least once. If you throw pairs, you have to repeat. The three of you are assigned a lord.

Then you have two more rounds. Each player must roll the dice at least once more. If you launch pairs, you have to repeat, if you launch certain types of reels, you lose all your waiting reels. If you launch other types of reels, you can send a fight to another player. The fight is resolved until one of the two participants fails. It is important the number of rounds that the fight lasts.

I'm trying to build a loop style, along the lines of:

first_round: Round = next(self.game)

for turn in first_round:
    current_player = turn.player
    for dices in turn:
        dices.roll()

for the first round. The other tours must be managed via irc-bot, responding to chat messages. irc-bot has access to the Game example.

But I'm stuck with the code, I don't know how to continue.

class Dices:
    def __init__(self, left, right):
        # Canonical members of dices are ordered being the first the min and the second the max.
        self.left: int = left if left < right else right
        self.right: int = right if left >= right else left

    def roll(self):
        first_roll = random.randint(1, 6)
        second_roll = random.randint(1, 6)

        return Dices(first_roll, second_roll)

    def count_threes(self):
        return (1 if self.left == 3 else 0) + (1 if self.right == 3 else 0)

    def is_pair(self):
        return self.left == self.right

    def __eq__(self, other):
        if isinstance(other, Dices):
            return other.left == self.left and other.right == self.right
        else:
            return False

    def __str__(self):
        return f"({self.left},{self.right})"


class NotRollingDices(Dices):
    def roll(self):
        return NotImplementedError


class Pair(NotRollingDices):
    def __init__(self, num: int):
        super().__init__(num, num)


class Player:
    def __init__(self, name):
        self.name: str = name
        self.dices = Dices(0, 0)
        self.lords: int = 0

    def add_lord(self) -> None:
        self.lords = self.lords + 1

    def is_lord(self) -> bool:
        return self.lords_count() > 0

    def lords_count(self) -> int:
        return self.lords

    def roll(self) -> Dices:
        return self.dices.roll()

    def __str__(self):
        return f""

    def __eq__(self, other):
        if isinstance(other, Player):
            return self.name == other.name
        return False

    def __hash__(self):
        return self.name.__hash__()


class Turn(Iterator(Dices)):
    def __init__(self, player: Player, is_first: bool):
        self.player: Player = player
        self.is_first: bool = is_first
        self.pending_rolls: int = 3
        self.current_roll: Optional(Dices) = None

    def __next__(self) -> Dices:
        if self.pending_rolls == 0:
            raise StopIteration

        self.pending_rolls -= 1
        current_roll = self.player.roll()
        return current_roll

    def __str__(self):
        return f""


class Round(Iterator(Turn)):
    def __init__(self, players: Iterable(Player), is_first: bool):
        self.players = players
        self.is_first: bool = is_first
        self.current_turn = Optional(Turn)

    def __next__(self) -> Turn:
        for player in self.players:
            return Turn(player, self.is_first)
        raise StopIteration


class Game(Iterator(Round)):
    def __init__(self, pending_rounds: int = 3):
        self.players: set = set()
        self.pending_rounds: int = pending_rounds
        self.current_round: Optional(Round) = None

    def add_player(self, player: Player) -> None:
        self.players.add(player)

    def player_by_name(self, name: str) -> Optional(Player):
        for player in self.players:
            if player.name == name:
                return player
        return None

    def lords(self) -> List(Player):
        return (player for player in self.players if player.is_lord())

    def current_round(self) -> Round:
        return self.current_round

    def is_first_round(self):
        return self.pending_rounds == 3

    def __next__(self) -> Round:
        if self.pending_rounds <= 0:
            raise StopIteration

        self.pending_rounds -= 1
        self.current_round = Round(self.players, self.is_first_round())
        return self.current_round

interaction design – Name for a flexible view-based layout like Photoshop, Eclipse, Blender?

Is there an established name for visualization and interaction based on mobile views like in Photoshop, Eclipse, Blender, etc.?

I refer to:

  • a screen with some global controls
  • on which a set of views can be distributed (mainly, tiled, without overlapping)
  • views are connected, for example, selection in one determines content in another
  • views show different aspects of a (complex) model (such as a development project)
  • where the user determines which views are displayed
  • views can be resized and moved to their new location
  • which allows you to save a certain layout (as a "perspective" – ​​Eclipse terminology)
  • Sometimes views can be combined in a tab bar, so only one of a few is visible at any time
  • sometimes views can be torn in their own window (possibly on another screen)

So this is not a term for a single control, but rather a "floor plan" of an entire application.

web design – Which micro interaction to use when hovering over a button?

👋

We try to learn / understand UX from the first principles and create the most intuitive user interface.
We are creating buttons in an application and want to know what is the ideal micro-interaction when you hover over the button.

We have seen some tutorials decrease the opacity of the buttons when the cursor is over the button, but we think it can be counter intuitive for the user because it is "graying"the button which could mean that the action is unavailable.

Here are the app buttons we are currently building:

buttons-opacity-reduced-hover

Does it make sense to reduce the opacity of the hover button?
What would be a more appropriate UX / mic interaction for a button?

Thank you!

Any suggestions for the design of my blog

I have implemented a new theme and made some changes. Please review it and let me know your suggestions for improvement. here my link – steamyiron.com

java – Builder design template password object

What I have seen the most with regards to generator models is that the object (in your case Animal) will be built in the build constructor method. So in your case, it would look like this:

public class Animal {

    private String animalName;
    private int animalAge;

    public static class AnimalBuilder {
        private String animalName;
        private int animalAge;

        public AnimalBuilder() {
        }

        public Builder withName(String animalName) {
            this.animalName = animalName;
            return this;
        }

        public Builder withAge(int animalAge) {
            this.animalAge = animalAge;
            return this;
        }

        public Animal build(){
            Animal animal = new Animal();
            animal.animalName = this.animalName;
            animal.animalAge = this.animalAge;
            return animal;
        }
    }

    public Animal(){ }

    public String getAnimalName() {
        return animalName;
    }

    public int getAnimalAge() {
        return animalAge;
    } 
}

You can then use it

Animal animal = new AnimalBuilder()
    .withName("Terry")
    .withAge(5)
    .build();

You can also add a static method builder() to the Animal class that returns a new generator:

public class Animal {
    ...

    public static AnimalBuilder builder() {
        return new AnimalBuilder();
    }
}

Animal animal = Animal.builder()
    .withName("Terry")
    .withAge(5)
    .build();

Does that mean a lot of duplicates? Unfortunately, yes, generator models need a lot of duplicate code. You can also check out the Lombok Builder annotation which will generate all of the constructor's passcode for you. In this case, it will be fair

@Builder
public class Animal {

    private String animalName;
    private int animalAge;

    public Animal(){ }

    public String getAnimalName() {
        return animalName;
    }

    public int getAnimalAge() {
        return animalAge;
    } 
}
```

Design a business card within 4 hours for $ 5

Design of a business card within 4 hours

Designing a business card within 4 hours What is the BUSINESS CARD?

It is the most useful tool for connecting personally with prospects, customers, clients, fellow business owners – and promoting your brand.

Are you starting a new business and looking for a business card?

We therefore welcome you! You are in the right place!

Why hire us?

We are a team of experienced and creative minds who create innovative, simple and double-sided, minimalist, remarkable, exceptional and professional business cards.

YOU WILL HAVE:

  1. Simple or double sided design.
  2. Modern / classic or luxury designs
  3. Files ready to print in JPEG and PDF format.
  4. Editable PSD or Ai source file (Extras)
  5. Unlimited revisions
  6. 100% customer satisfaction
  7. Money back guarantee
  8. 24 hour express delivery

Requirements:

1. If you have a logo, send it.

2. Send the name of your business and mention the nature of your business.

3. Text to use on your business card. Be confident and place the order!

Cheers:
Victor

. (tagsToTranslate) Business (t) Card (t) Businesscard (t) Cards

domain-driven design – Difficulty understanding event search Microservice Receiving / communicating events

I have known about event sourcing, CQRS, DDD and micro-services for a while and I am now at the point where I want to try to start implementing things and trying something.

I have studied the technical side of CQRS and I understand DDD concepts and how the write side handles commands from the user interface and publishes events from them, and how the read side handles events and creates projections on them.

The difficulty I have is the communication and management of service to service events (both from writing to reading and between micro services).

So I want to focus on eventstore (this one: https://eventstore.com/ to be less ambiguous). This is what I want to use because I understand that it is perfect for searching for events and the simple nature of event storage means that I can also use it for a bus. messages.

My problem therefore comes down to two questions:

Question 1:
Between writing and reading, for the reading side to receive / retrieve events created from the writing side, am I right in thinking that something like a catch-up subscription can be used to subscribe to a stream to receive all the events written to or should I use something like the poll to retrieve events from a given point?

Question 2:
Between micro services, I have even more trouble …
So when we look at the CQRS tutorials / discussions etc … they always seem to be talking with an example of an isolated service that receives commands from the user interface / API. It’s good. I understand that the write side will be associated with an API so that the user can interact with it to execute commands. For example. create a client.
However … say if I have two microservices, e.g. ordering micro-service and shipping micro-service, how does the shipping micro-service get published events from the order micro-service? Specifically, how do these customer events translate into orders for the shipping service.

So let's take a simple example of:
– Order created from the order API to place an order.
– An OrderPlacedEvent is published in the event store.
How does the shipping department listen and react? It must then DispatchOrder and in turn create an OrderDispatchedEvent.

Should the writing side of the shipping microservice then interrogate or also have a catch-up subscription to the order flow?
If so, how is an event translated into a command using the DDD approach?

Any help on this subject would be overwhelmingly approved.

Thank you

Dynamic data delivery using JSDelivr Architecture / Design Questions

I have a JavaScript application that retrieves and renders the data on a map. Due to CORS restrictions, I decided to put the data in a .js file on GitHub and retrieve it from JSDelivr using