interaction design – How do I let users know the field can be edited without putting it in text?

I am designing something like a wallet where users can withdraw from it. I’d like to give users the option to withdraw any amount, however, I do not know how to let my users know in a really obvious way that the amount can be edited. Currently, I’m deciding to put a text saying ‘click here for desired amount’ and connecting it via an arrow to the bottom $300.70 for users to know.

Please share with me your thoughts and opinions. Greatly appreciated!
If you do not understand where I am coming from, do leave a comment as well! Thank you :]

enter image description here

c# – Asp.Net overall design pattern integrating REST, dependency injection, and Hosted Services (See full project at Github)

I’m new to C#, and want to conform as much as possible to good design patterns. This code is the beginning of a Microservice, running as Asp.Net. It is based on a Microsoft tutorial doing similar work.

It has three functional components currently:

  1. Converts a CSV file to JSON, for return via REST
  2. A REST controller to test the conversion of the CSV to JSON return
  3. A background service which monitors a directory looking for changed files. The file attributes (Path, Date, Checksum) are stored in a MongoDB database via a Repository.

Opinions/Recommendations regarding the design patterns welcomed.

The full code can be found at: https://github.com/BioComSoftware/unite-radimaging-source-n2m2.git

BONUS: Notice in FileSearchHostedService.cs, I instantiate the Repository objects explicitly. I think it would be more appropriate to have them as Dependency Injection – but I couldn’t get it to work. Notice the commented-out lines that would have done this. My understanding is; I would need to do this with IScopedProcessingService – but I have no idea how to do this with this specific code.

Structure

(Startup.cs)

using unite.radimaging.source.n2m2.Data;
using unite.radimaging.source.n2m2.Repositories;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
//using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace unite.radimaging.source.n2m2 {
    public class Startup {
        public Startup(IConfiguration configuration) {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime.
        // Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services) {

            services.AddControllers();

            services.AddScoped<IFoundFileContext, FoundFileContext>();
            services.AddScoped<IFoundFileRepository, FoundFileRepository>();
        }

        // This method gets called by the runtime.
        // Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
            if (env.IsDevelopment()) {
                app.UseDeveloperExceptionPage();
            }
            app.UseExceptionHandler("/error");
            app.UseRouting();
            app.UseAuthorization();
            app.UseEndpoints(endpoints => { 
                endpoints.MapControllers(); 
            });
        }
    }
}

(FoundFileRepository.cs)

using unite.radimaging.source.n2m2.Data;
using unite.radimaging.source.n2m2.Entities;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace unite.radimaging.source.n2m2.Repositories {
   public class FoundFileRepository : IFoundFileRepository {
       private readonly IFoundFileContext _context;
       public FoundFileRepository(IFoundFileContext context) {
           _context = context ?? throw new ArgumentNullException(nameof(context));
       }

       public async Task<IEnumerable<FoundFile>> GetFiles() {
       return await _context
           .FoundFiles
           .Find(p => true)
           .ToListAsync();
       }

       public async Task<FoundFile> GetFile(string id) {
           return await _context
                          .FoundFiles
                          .Find(p => p.Id == id)
                          .FirstOrDefaultAsync();
       }

       public async Task<FoundFile> GetFileByPath(string path) {
           return await _context
                          .FoundFiles
                          .Find(p => p.Path == path)
                          .FirstOrDefaultAsync();
       }

       public async Task<FoundFile> GetFileByChecksum(string checksum) {
           return await _context
                          .FoundFiles
                          .Find(p => p.Checksum == checksum)
                          .FirstOrDefaultAsync();
       }

       //public async Task<IEnumerable<FoundFile>> GetFileByMtime(string mtime) {
       //    FilterDefinition<FoundFile> filter = Builders<FoundFile>.Filter.ElemMatch<DateTime>(p => p.Mtime, mtime);

       //    return await _context
       //                    .FoundFiles
       //                    .Find(filter)
       //                    .ToListAsync();
       //}

       //public async Task<IEnumerable<FoundFile>> GetFileBySize(long size) {
       //    FilterDefinition<FoundFile> filter = Builders<FoundFile>.Filter.ElemMatch<long>(p => p.Size, size);

       //    return await _context
       //                    .FoundFiles
       //                    .Find(filter)
       //                    .ToListAsync();
       //}

       public async Task CreateFile(FoundFile foundFile) {
           await _context.FoundFiles.InsertOneAsync(foundFile);
       }

       public async Task<bool> UpdateFile(FoundFile foundFile) {
           var updateResult = await _context.FoundFiles.ReplaceOneAsync(
               filter: g => g.Path == foundFile.Path, replacement: foundFile);
           return updateResult.IsAcknowledged && updateResult.ModifiedCount > 0;
       }

       public async Task<bool> DeleteFile(string path) {
           FilterDefinition<FoundFile> filter = Builders<FoundFile>.Filter.Eq(p => p.Path, path);

           DeleteResult deleteResult = await _context
                                               .FoundFiles
                                               .DeleteOneAsync(filter);

           return deleteResult.IsAcknowledged
               && deleteResult.DeletedCount > 0;
       }
   }
}

(FileSearchHostedService.cs)

using unite.radimaging.source.n2m2.Repositories;
using unite.radimaging.source.n2m2.Entities;
using unite.radimaging.source.n2m2.Data;
using Serilog;
using Microsoft.Extensions.Configuration;
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace unite.radimaging.source.n2m2.HostedServices {
    public class FileSearchHostedService : BackgroundService {
        private readonly IConfiguration _configuration;
        //private IFoundFileRepository _repository;

        public FileSearchHostedService(
            //IFoundFileRepository repository,
            IConfiguration configuration
            ) {
            //_repository = repository ?? throw new ArgumentNullException(nameof(repository));
            _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
        }

        protected override async Task ExecuteAsync(CancellationToken cancellationToken) {
            Log.Information("FileSearchHostedService: File searching started.");

            cancellationToken.Register(() => Log.Information("Processing service stopped"));

            //string checksum;
            string _current_path;
            FileInfo _current_file;
            FoundFile _foundFile;
            FoundFile _existingFile;
            FoundFile _addFoundFile;
            FoundFileContext FoundfileContext = new FoundFileContext(_configuration); // Normal instantiation, in leiu of injection
            FoundFileRepository _repository = new FoundFileRepository(FoundfileContext);  // Normal instantiation, in leiu of injection

            while (!cancellationToken.IsCancellationRequested) {
                Log.Information("Searching files...");
                string dir = _configuration.GetValue<string>("FileSearchSettings:SearchDir");
                string() files = Directory.GetFiles(dir);
                foreach (string filename in files) {
                    Log.Debug($"Parsing '{filename}'");

                    _current_file     = new FileInfo(filename);
                    _current_path = Path.GetFullPath(Path.Combine(_current_file.Directory.ToString(), _current_file.Name));

                    _foundFile = new FoundFile() {
                        Path = _current_path,
                        Size = _current_file.Length,
                        Mtime = _current_file.LastWriteTime,
                        Checksum = FileChecksum.getChecksum(filename)
                    };
                    Console.WriteLine("==========================");
                    _existingFile = await _repository.GetFileByPath (_current_path);
                    Console.WriteLine("past _repository.GetFileByPath");

                    try {
                        Console.WriteLine($"{_existingFile.Path} exists!!!");
                        Console.WriteLine($"     _existingFile.Checksum: {_existingFile.Checksum}");
                        Console.WriteLine($"     _existingFile.Length = {_existingFile.Size}");
                        Console.WriteLine($"     _existingFile.LastWriteTime = ({_existingFile.Mtime}");
                    }
                    catch {
                        Console.WriteLine($"Creating MongoDB for file {_foundFile.Path} ");
                        _addFoundFile = new FoundFile() {
                            Path = _foundFile.Path,
                            Size = _foundFile.Size,
                            Mtime = _foundFile.Mtime,
                            Checksum = _foundFile.Checksum
                        };
                        await _repository.CreateFile(_addFoundFile);
                    }
                }

                await Task.Delay(
                    _configuration.GetValue<int>("FileSearchSettings:Delay"),
                    cancellationToken
                    );
            }
        }
    }
}

design – Loose coupling vs transparency in vistor pattern that visits composite

I have a composite object (I will call it A) that has fixed number of sons (I will call them A1 and A2)

All of them have an Accept(Visitor) method.

I have a GUI, A is the main window that consists of many sub-windows (a.k.a A1 and A2).
The visitors will be visitors for when a user clicks a button to start a new operation such as starts a new game, guesses a word incorrectly and other events. (Command design pattern is used, but this is out of the scope) and when such events happends the visitor will update the GUI appropriately.

When considering how to implement Accept(Visitor) at A, I consider weather I should cascade the Accept(Visitor) request to A1 and A2 as well or not.

Here is my argument for cascading:

More transparency – in all of my visitors until now, I do want to go over the sons of A. but in order to do that without cascading, I will need getters for the sons of A, but the sons of A can change (even at run time, if I change implementation from fixed amount of sons to a collection) and I do not wish to change the interface all the time to support such get operations. You might suggest iterators for that, but the thing is that the Visitor might want to visit A1 and A2, but if another A3 son will be added, he might not want to visit it. So as it iterates through A‘s sons, it will must resort to ugly type checking, which is what the Visitor design pattern has come to eradicate. Instead, it might be much easier to simply cascade all the requests to the children, and if a visitor isn’t interested in visiting some type, it cant just leave the visit method for it empty. Moreover, in the symbolic level, A1 and A2 are part of A, so the cascade makes sense.

Here is my argument against cascading:

Looser coupling – cascading means you force the visitor to visit children it might didn’t want to visit, which can lead to unexpected results. Moreover, it might not support accepting the types of the children. If getter or iterators are used, then the visitor can choose weather it wants to go over the children.

What approach should I take?

design patterns – how to read go interfaces

I been learning to program by reading tutorials and playing around by myself but when it comes to more “conceptual” questions it is hard to find answers. For example a few months ago I wanted to integrate a markdown parser in my project. I chose https://github.com/yuin/goldmark because in the README it says it is easy-to-extend and well-structured and that is important for me. After spending a lot of time trying to understand the API I ask for help https://github.com/yuin/goldmark/issues/163 and got the following answer:

I’m afraid, there are no detailed documentation.
Many users already created extensions by reading source codes. You did not possible it due to your code reading skills…
Built-in elements like emphasis, links …etc are implemented by as same interface as extensions. So you just read goldmark source codes to create extensions.
See if you can do it, and if it doesn’t work, there are some extensions on github, you can search it and read them.

So I took the code I needed from an existing extension and this is the gist of that:

package main
import (
  "bytes"
  "fmt"
  "github.com/yuin/goldmark"
  "github.com/yuin/goldmark/ast"
  "github.com/yuin/goldmark/renderer"
  "github.com/yuin/goldmark/util"
)

type html struct {}

func (r *html) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) {
  reg.Register(ast.KindFencedCodeBlock, r.renderFencedCodeBlock)
}

func (r *html) renderFencedCodeBlock(w util.BufWriter, source ()byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
  n := node.(*ast.FencedCodeBlock)
  if !entering {
    return ast.WalkContinue, nil
  }
  
  language := n.Language(source)
 
    if string(language) == "x" {
      l := n.Lines().Len()
    for i := 0; i < l; i++ {
      line := n.Lines().At(i)
      fmt.Println(string(line.Value(source)))
    }
    }
  return ast.WalkContinue, nil
}

func main() {
    markdown := goldmark.New()
    markdown.Renderer().AddOptions(
    renderer.WithNodeRenderers(
      util.Prioritized(&html{}, 200),
    ))

    var buffer bytes.Buffer
 
    if err := markdown.Convert(()byte(`
# text before
`+"```x"+`
hello from codeblock x
`+"```"+`
`+"```z"+`
hello from codeblock z
`+"```"+`
# text afer
`), &buffer); err != nil {
    fmt.Println("error")
  }
}

The code does what it is suposed to do but I still don’t really understand how to read the code. Is it just a question of “code reading skills” mentioned by the Goldmark creator? If so, how do you for example know where to find the RegisterFuncs function? How do you know what the options renderer.WithNodeRenderers and util.Prioritized do if you can’t find any documentation? Or maybe I just don’t know how to read the documentation ?

Is it really a good idea to use interfaces like this ? Does it not make the code harder to reason about?

design patterns – Implementation strategies for dynamically scheduled tasks

I have a varying number of tasks. New tasks can be added, some tasks can be removed. But those operations happen rather infrequently (once or twice per week, and adding is more common than removing). The overall number of tasks will be somewhere between 10 and 100, roughly, but can also be 1 in specialized deployments.

When a task gets scheduled it runs its operations, calculates a waiting time and is put back to sleep. Calculating the waiting time is a dynamic process which yields a datetime value. In pseudocode a task could look like this:

void task_worker(TaskData data) {
    while (keep_running) {
        subtask = get_next_subtask(data);
        execute_subtask(subtask);
        sleep_until(schedule_next_subtask());
    }
}

Calculating the sleep_until datetime can be considered a solved problem for this question. It should be noted though that the result is also highly variable and can be a point in time between seconds and days from now.

While this specific question has some additional constraints like the recalculation of the waiting time after each scheduled execution, I’d love to learn more about approaches to the general problem of scheduling more or less periodic tasks.

In my scenario, solving the scheduling outside of the process (e.g. with a cronjob) seems infeasible. Also, if the requirements also include some form of monitoring, a solution internal to the program seems the better choice.

From the top of my head I could come up with two implementation strategies:

  1. Having a thread for each task, similar to the pseudocode above.
  2. Having a threadpool and a queue, where the tasks can be retrived from by an executor.

Are there any other approaches, design pattern? Under what circumstances would it be preferrable to start an entirely new process for my task once it gets scheduled opposed to doing that only in a thread?

database design – Best practices when designing SQL DB with “redundant” tables

I have a design dilemma for a DB I’m creating for an e-commerce platform I want to develop.

I have 3 different actors interacting with the website:

  • Customer
  • Manager
  • Supplier

Those 3 actors have the same table structure: email, username, address…

My initial design for the DB was to create a single table (StoreUser), with an additional field to distinguish between the 3 different types of actors.

The issue I see with this design is that when referencing a Customer in the “Order” table for instance, to assign an Order to a Customer, it would be technically possible to assign a “Manager” or a “Supplier” to the order, even though it isn’t wanted. Same thing for the “Product” table, to which a Supplier’s foreign key should be provided, the “StoreUser” FK would not distinguish between the 3 actors.

On the other hand, creating 3 tables, containing the exact same datafields, seems really redundant, especially from the code perspective (I’m using Django for the website, and I really don’t like the idea of having 3 different classes with the same structure.

Which one seems the most logical to you? What’s the good practice here?

Contest – $30 Design Contest

Hi,
SEMrush

I am looking for someone to design a logo for my company Collectiball

Collectiball is a Premier League Football (soccer) trading card collection, people can purchase limited edition trading cards to keep or trade on our marketplace.

Here is what I need for the logo:
– Simple FLAT logo. No gradients. Good typography.
– Needs to be both an icon and text logo
– It needs to be professional, memorable.
– The logo needs to look good in black and white, as well as in colour.

The design has to be original work only.

I will provide feedback for submissions. The winner will be paid via Paypal and delivery is expected in PSD and transparent PNG (black, white and colour)

Thank You

 

I will design professional and responsive wordpress website for $45

I will design professional and responsive wordpress website

If you are looking to create a WordPress Website or e-commerce for your business then look no further, you’re at the right place. I have extensive experience in wordpress!!! don’t worry i am here!!!

A professional, eye-catching, highly interactive and appealing website is guaranteed. I promise to provide my best service and life time w free support to Kickstart Your company!!!

Here’s what you would get:

  • Trusted solution provider
  • WordPress Setup & Installation
  • E-Commerce ready(Standard & Golden package)
  • WordPress Blog/Forum Setup
  • SEO Optimisation(Golden package)
  • Speed Optimised – Pingdom Tools*
  • Setting up Google Analytics to track your site metrics
  • Integration with Social media platforms
  • Integration with Marketing platforms & CRM
  • Facebook Customer Chat
  • Online Contact Form
  • Signup/Newsletter Forms
  • Popups(Premium)
  • Helpful Video Guides for website maintenance
  • LifeTime WEEKS FREE SUPPORT
  • Coustom website via html.css,javaScript
  • Highily obtimized!

Looking forward to working with you!

Please contact me before placing the order

.(tagsToTranslate)wordpress(t)wordpress(t)websit(t)website(t)design(t)Crypto(t)websitemake(t)javascript

database design – Getting sums of multiple leveled relations efficiently

I’m currently building an API and a web app for an internal warehouse system using NET Core.
I have the core entity structure, that goes like this:

“Material” has many “MaterialSubtypes” has many “MaterialClasses” has many “Packs”.

Now, I need to create a list, representing a single sale. It can include lots of packs of different materials. The user should be able to add or remove packs to a sale as it is being prepared.
The problem is that I also need to show the user the list of all materials hierarchy that the sale contains, as well as the sum of “Quantity” field of all packs on each sublevel. This quantity is supposed to be updated dynamically in a client app.

What is the most efficient way to do this? Should I just add all packs to a sale, and then, on every GET request, Include everything and recalculate all sums via foreach loops? Or should I create separate entities for Material->MaterialSubtype->MaterialClass within the Sale and update them each time a Pack is added?
None of that seems optimal, but I can’t think of anything else.