Dynamic data delivery using JSDelivr Architecture / Design Questions

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

Website design – Language of language names in the language selector?

Anyway, although what others have answered is good, it does not reach the big picture. I will give you what I think is the IDEAL answer.

Basically this answer provides Multiple tracks (instead of a single track) for language selection.

First It is the name of the language (according to the previous answers), as it provides a basic interface for anyone literate in English.

Second is the name of the language in your own native script, for a person literate in the basic native language. e.g.
enter the image description here

Third It is a flag for the country. For languages ​​spoken in dialects and common countries, the country of origin or the country of speech can be used. E.g. ENGLISH (must have the flag of the United Kingdom), ENGLISH OF THE UNITED KINGDOM, ENGLISH OF THE USA USA (Must have the flag of their respective countries). A visual clue that overlooks the thinking part of the brain.

Below is a poor screenshot from this example, from the website http://blog.myheritage.com/2009/06/small-changes-big-differences-new-header-and-footer/
enter the image description here

Many apps I've seen have implemented this correctly, and I urge the rest to follow this.

Some other required features are fast filtering of keyboard-displayed languages, such as listing for lists, to narrow down results. I like it if you are specifically looking for English (Singapore).

Also, the location of the language selector is very important. Must be ideally located above the fold (that is, on the first page) somewhere. General practice is the upper right corner, below any profile information you may have. IT IS A MUST for first-time visitors, can be hidden from regular visitors (i.e. the site is already in your preferred language) and can be accessed through the second location.
The second common location is at the bottom of the page, centered or left aligned. Although I think it should always be available at first glance. The same is true for applications.

Ahhh, this is one of my hobbies!
For example, see Chrome! (I know it is an app, but please be patient with me) It has the most horrible user experience to change the language to English from a language unknown to the user. It requires an excessive amount of clicks and absolute confusion!

  1. Menu icon
  2. Configuration menu item (no icon! For clear / easy identification when using an unknown language)
  3. Click Show advanced settings text.
  4. Click Language (absolutely no way to find it in an unknown language)
  5. Click Add
  6. Choose your language
  7. Move it to the top of the screen.
  8. Click the button on the right to make it Chrome's default language. (Some languages ​​can't be done this way either, and can only be used for spelling! You should separate these dialogs and not combine spelling and language selection dialog! As the most common case is probably selecting language, and a very distant one is the spell checker selection).
  9. Restart Chrome!

Some interesting links I found with contrary opinions and other useful resources.

Best practice for presenting languages


Beginner: Would anyone be willing to comment on the structure, design, and effectiveness of my Python program?

The essence of my program is to simulate the growth of some viruses. I used to (tried) using OOP concepts to break the problem into chunks and make the chunks talk to each other. I'm not sure if my implementation is effective but it seems to work quite well. Currently, the bottleneck appears to be in the plot. I am still learning about matplotlib, so it doesn't surprise me.

The program has five classes. The first class just keeps track of the simulation details, nothing too fancy.

class Details():
    def __init__(self,num_people_1d,fig_size):
        self.num_people_1d = num_people_1d
        self.total_people = self.num_people_1d**2

        self.fig_size = fig_size

        self.x_length = self.fig_size(0)/num_people_1d
        self.y_length = self.fig_size(0)/num_people_1d

The second class is the screen. In each iteration, the 2D grid is updated with details about the people who are infected or have perished. The display class is updated with the information.

import matplotlib.pyplot as plt
import matplotlib.patches as patches

class Display():
    def __init__(self,details_instance):
        self.size_x,self.size_y = details_instance.fig_size
        self.length_1d = details_instance.num_people_1d

        self.x_length = details_instance.x_length
        self.y_length = details_instance.y_length

    def create_plot(self,plot_size = (5,5)):
        self.fig = plt.figure(figsize = plot_size)
        self.ax = self.fig.subplots()

        canvas = patches.Rectangle((0,0),1,1,fill=True,

    def update_plot(self,infected_table=None,kill_table = None): 
        #Transposing tables
        infected_table = list(map(list, zip(*infected_table)))
        kill_table = list(map(list, zip(*kill_table)))

        for i,row in enumerate(infected_table):
            for j,col in enumerate(row):
                infected_person = col
                dead_person = kill_table(i)(j)
                if dead_person:
                    coord = i*self.x_length,j*self.y_length
                    square = patches.Rectangle(coord,
                                       edgecolor = 'none',
                                       facecolor = 'r')
                if infected_person and not dead_person:
                    coord = i*self.x_length,j*self.y_length
                    square = patches.Rectangle(coord,
                                       edgecolor = 'none',
                                       facecolor = 'y')

The next class is the virus class. Not much happens, just the infection and mortality rate.

class Virus():

    def __init__(self,infectionRate = 0.1,mortalityRate = 0.01):
        self.IR = infectionRate
        self.MR = mortalityRate

So he's the kind of person. This class only stores basic information. Whether the person is infected or dead, and some simple methods.

import random

class Person():

    def __init__(self,id = None,discrete_location = None,infected = False):
        self.id = id
        if discrete_location:
            self.dl_x,self.dl_y = discrete_location
            raise Exception()
        self.infected = infected
        self.neighbors = ()
        self.dead = False

    def become_infected(self,virus):
        if not self.dead:
            self.infected = True
            self.virus = virus

    def do_i_live(self):
        return random.random()>self.virus.MR

    def kill(self):
        self.dead = True
        self.infected = False

The last class is the population class. This class contains most of the code that actually does things because it is what updates all individuals.

from person import Person
import random

class Population():
    def __init__(self,persons=(),details_instance =None,virus_strain=None):
        if len(persons)<1:
            print('There is no population! Adding a member')
            self.persons = persons
            self.count = 0

            self.persons = persons
        self.details_instance = details_instance
        self.virus_strain = virus_strain
        self.dead_persons = (())

    def add_person(self):
        if len(self.persons)<1:
                                  discrete_location = (0,0),
                                  infected = False)
            self.count +=1
            loc_x = self.details_instance.x_length*(self.count%self.details_instance.num_people_1d)
            loc_y = self.details_instance.y_length*((self.count - self.count%self.details_instance.num_people_1d)/self.details_instance.num_people_1d)
            person = Person(id = self.count,
                             discrete_location = (loc_x,loc_y),
                             infected = False)
            self.count +=1

    def get_infected_table(self):
        truth_table = ()
        current_list = ()
        i = 0
        while i < self.count:
            if (i)%(self.details_instance.num_people_1d) ==0:
                current_list = ()
        if self.count%(self.details_instance.num_people_1d) !=0:
        return truth_table

    def get_dead_table(self):
        truth_table = ()
        current_list = ()
        i = 0
        while i < self.count:
            if (i)%(self.details_instance.num_people_1d) ==0:
                current_list = ()
        if self.count%(self.details_instance.num_people_1d) !=0:

        return truth_table

    def kill_infected(self,infected_table):
        linear_indices = self.get_infected_indices(infected_table)
        for index in linear_indices:
            still_living = self.persons(index).do_i_live()
            if not still_living:

    def add_neighbors(self):
        #Currently returns the linear index! Compatible with persons!!
        if len(self.persons)<=1:

        #One method:
            #Use self.count and modulos to identify neighbors
        #Possibly a better method that I do not follow:
            #Using discrete location to identify neighbors

        #Using first method
        for i in range(self.count):
            #at left boundary
            if i%self.details_instance.num_people_1d==0:
                left = -1
                left = i-1
            #at right boundary
            if (i+1)%self.details_instance.num_people_1d==0:
                right = -1
                right = i+1

            up = i+self.details_instance.num_people_1d
            down = i - self.details_instance.num_people_1d

            #First build potential neighbors
            potential_neighbors = (left,right,up,down)

            #Second identify if any potential neighbors don't exist
            neighbor_list = ()
            for j in potential_neighbors:
                if (j >= 0) and (j

To run all this code, I wrote the following script:

from person import Person
from virus import Virus
from display import Display
from details import Details
from population import Population

import random
num_people_1d = 10

simul_details = Details(num_people_1d = num_people_1d,fig_size = (1,1))
virus_strain1 = Virus()
pop = Population(details_instance = simul_details,virus_strain=virus_strain1)

number_people = num_people_1d**2-1
for i in range(number_people):
starting_person = random.randint(0,number_people-1)
print('The starting person is %d' % starting_person)

current_infected = pop.get_infected_table()
current_dead = pop.get_dead_table()

simul_display = Display(details_instance=simul_details)

total = 100
for iter in range(total):
    infected_people = pop.get_infected_count()
    dead_people = pop.get_dead_count()
    print('The iteration we are on is %d with %d infected' %(iter,infected_people))

    current_dead = pop.get_dead_table()

    if infected_people+dead_people > number_people:
        print('All individuals are infected or dead!')

This is all the code. Any comments will be appreciated. Thank you!

website design: how many input fields in a row of a form?

If you really want columns in your forms

Here is a quick rule to follow when designing forms with multiple columns:

double the size of the font and enter the largest realistic value the input would need to accept, if it fits then your input is big enough.

The reason for this is that a lot of people will increase the font size in their browser and WCAG 1.4.4, although not entirely clear, suggests that this should allow a size increase of up to 200%.

I say it is not clear as it says as long as the page can be expanded and this has always been a point of discussion on what the rule really means.

Even if this point is not clear, it is good practice.

Assuming you're using rem or em units in 1rem / 1em, just set font-size: 200% in your HTML and enter the longest realistic information you can think of (i.e. for the email address enter & # 39; thisisalongemailaddress@alongdomainname.com&#39;), if set, it is gold.

Since the font size is complex with rems, ems, etc., you can set the font size to 32px manually on each input, as that would be the equivalent. Don't forget your labels too to check that they work.

If you find you have a lot of space left, add another entry to the row if it makes sense.

A couple of additional considerations.

Also, since it's marked as & # 39; accessibility & # 39 ;, make sure the edge of your posts has at least a 3: 1 contrast ratio to the environment, it looks good at a glance, but it's on the edge .

One last thing to consider is if the items go together. Name and surname, but is the identification number related? I would be tempted to have an ID number on a different line.

Should I design forms with more than one column?

Having said all of the above … put one entry on one line.

By the time you start adding error messages, all of the above will fall apart (since error messages tend to be longer).

Error messages should still work in larger font sizes and tend to be unclear when they have 2 or 3 columns.

Also, don't worry about vertical scrolling, it's a convention today and since a form will end with a submit button, people will know when they have reached the end of your form (so you don't have to worry about missing people fields.)

c # – Design pattern: how to inject dependencies into a command pattern

I'm fairly new to programming languages ​​and have only limited knowledge of design patterns, so I hope you can help me with the following problem:

I have an application that operates on a group of different services. One functionality of the application is to provide an interface to the user to call all available service methods. Therefore, I want to use the Command pattern because it allows me to add new commands simply by adding new classes and not changing the existing code. The parameters for each service command are passed to the constructor.


public interface ICommand {
    void Execute();

public abstract class Command : ICommand {
    public T Service { get; set; }

    public abstract void Execute() { /* use service */ }

public class Command1 : Command {
    T1 param1;

   public Command1(T1 param1, ...) { /* set parameters */ }

   public override void Execute() { /* call first service1 method */ }


public class Command2 : Command {
    T2 param1;


   public override void Execute() { /* call first service2 method */ }


The advantage is that the user can create instances of a group of commands without knowing the interface of the application and execute them later when the service was configured. The problem is that I don't know how I can inject the services with elegance.
The application is primarily responsible for starting and stopping the services and keeping an instance of each service in one central place.


public class Application {
    S1 Service1;
    S2 Service2,

    public void StartService(/* params */) { /* ... */ }
    public void StopService(/* params */) { /* ... */ }


So my question is how do I get the correct service within a command?
I thought about using some kind of dependency injection, service locator, or generator pattern, but I never used these patterns and I'm not sure what is the best solution in this case and how to implement it correctly.

desktop app: another alternative to tabs (I need to design more than 10 categories on the same screen)

I am working on a system with a lot of content on the same screen.
There is a 2/3 table on the left and 1/3 on the right curtain details.
When the user clicks on an item in the table, the right curtain displays and minimizes the width of the table.

The use case is that I have more than 10 categories in the table and I need to divide each of the categories into a different table in the same view …

The alternatives are:
1. tabs
2. accordion
3. Labels

Does anyone have another solution?

Start web architecture design question. Two different roles (client = event creator) than the other (animator = event responder)

  • Thinking of having a database where the client can write an event
    to him on his authenticated page.

  • Then artists can see all events on their
    authenticated pages and add their name to "available artists"
    column in the database. From here, the customer can choose one that
    they want to come to your event and then the chef can see this on
    your side of the website.

Is this reliance on reading and writing to a database and using conditionals the best way to do it?

All opinions greatly appreciated.

architecture – Junction table with DAO design

I have a question about the DAO design pattern.

I have 3 tables called user, role Y user_role. In my application I have two DAOs, UserDao Y RoleDao. I also have two services that use DAOs, UserService Y RoleService.

How can I do if when I get all the users I also want to get the roles associated to each user? Should I have my user domain model filled in with all the information in the UserDao making all necessary queries to all related tables? Or should I have the UserService service call both Dao to get the user first and then their roles to fill the user (entity) domain model? Which way of doing this is the most correct in relation to good practices? Is a new DAO related to the join table needed?

Thank you!