Questions tagged [c#]

C# is a multiparadigm, managed, garbage-collected object-oriented programming language created by Microsoft in parallel with the .NET platform

Filter by
Sorted by
Tagged with
-3 votes
0 answers
68 views

Why is Unity capable of rendering so many more 3d objects and animations than a web technologies game engine/framework (HTML5 & JavaScript) [closed]

Basically, I have been playing around with making 3D games in Unity, but I: Prefer JS to C# Want my UI to be HTML5, CSS and JS Would like the whole application to be as harmonious as possible (I know ...
user avatar
0 votes
1 answer
25 views

DDD - Modelling a system of groups and users

I'm looking for some advice on a system I'm designing, at its core it will allow users to create/join/manage groups of users. I thought it would be a good idea to try and apply some DDD principles, ...
user avatar
0 votes
0 answers
27 views

Is the combination of Image Classification and numerical data useful and possible with ML.Net?

Up front, this is my first ever question on StackExchange. So please be gentle with me. It is also my first time working with Machine Learning and ML.Net which means that I'm lacking fundamental ...
user avatar
0 votes
1 answer
70 views

Best Way to name derived classes when extending its functionality C# [closed]

I have just recently joined a new company and One of the classes used to log information has not been written properly. So i have been asked to add new functionality to the logger. So rather than ...
user avatar
1 vote
3 answers
73 views

Multi type HTML dropdown conversion to the corresponding C# object type

Note: This is a contrived example I came up with to illustrate what I'm after as simply as possible. I have an HTML report with a single dropdown box at the top that lets the user select (or filter) ...
user avatar
1 vote
2 answers
63 views

Domain Driven Design - Aggregate Root and Nested Aggregate Invariants

I've come to a bit of an impasse with the best way to implement a DDD problem, and am hoping for some advice from those with more experience, please. I have a RecipeCollection, which has a collection ...
user avatar
  • 119
0 votes
0 answers
16 views

Access ViewModel in ObservableCollection by Underlying Model

I have an ObservableDictionary that I bind to a ListView. The ObservableDictionary contains ClientViewModels which are ViewModel wrappers for my Client model that contain UI-only properties. The ...
user avatar
0 votes
1 answer
57 views

Is there a best practice for storing multiple pages of JSON responses from an API?

Scenario: An API that responds to a request with multiple JSON objects contained in an array. The responses are paginated such that each page returns an array of JSON objects. I deserialize the JSON ...
user avatar
0 votes
1 answer
56 views

MVVM - Wrapping Class For ViewModel

I am using a networking library I created which contains a Client class. I have a GUI which will display all these clients in a ListView with columns, such as one containing their online status. The ...
user avatar
  • 113
2 votes
2 answers
248 views

How to come up with an easy-to-use way of creating quantities with units in C#?

I want to come up with a way to make it easy to write classes that represent quantities with units, such as length, weight, etc. For example, var height = new Length(32.2, LengthUnit.M); var weight = ...
user avatar
  • 133
1 vote
2 answers
146 views

C# - Class creating instances of other classes requiring different services

Context I have a service class whose sole purpose is to interact with a specific API, let's say the Automotive API. The API mostly works with generic AutomativeRecord which basically represents a ...
user avatar
0 votes
0 answers
76 views

WPF - Custom MenuItem with buttons or new Window? (or other?) - Update : what is your opinion of my solution?

Context I'm currently doing a project with WPF, which I'm fairly new to. What I am trying to do is a custom and configurable taskbar-like application. What I currently have I managed to create a ...
user avatar
0 votes
2 answers
150 views

Struggle with catch 22 in initialization code

I have a command line application written in C#. Here's some facts about the program that are relevant to my question: The application has a "data directory" (e.g. ~/.config/myapp) where ...
user avatar
  • 4,825
0 votes
3 answers
145 views

Hardcoding endpoints in library alternative

I'm dealing with creating a few internal libraries for a project that can offload emails and logs to a queue (Service bus, storage queue). The issue I'm having is how to configure the the queueing ...
user avatar
0 votes
1 answer
169 views

Best way to accept a lot of user input from command line

I have a program that accepts computer names and then will perform CIM session tasks. The computer names are passed in from the user input and separated by "," (ex: program.exe -computers ...
user avatar
  • 11
0 votes
1 answer
62 views

Good approach to design Business interface for versioned API?

I am designing an API using .NET core 6 C# which has 2 versions. For v1 I have something like the following for the business logic interface (fictional names and simple fields just to facilitate ...
user avatar
  • 101
-1 votes
1 answer
103 views

How to handle third-party libraries that can potentially throw, without knowing what kind of exceptions they may have?

I'm starting to run into this sort of dilemma while many third-party APIs, but I will use MongoDB for my examples. Consider the following code: var settings = MongoClientSettings....
user avatar
  • 3,859
0 votes
0 answers
48 views

Best way to implement a custom session pool in c# (winscp)

I'm currently implementing a session pool for WinScp sessions, which intended purpose is to open multiple sftp sessions concurrently. While my current solution works, I'm not sure if the solution is ...
user avatar
-1 votes
2 answers
207 views

Would Injecting dependencies in C# as default parameters be a bad practice?

Given the (old) debate over whether Singletons are overused/abused/are worth it - would it be a bad idea to inject the dependencies as default parameters? In this way, we could get rid of defining ...
user avatar
  • 303
-3 votes
1 answer
86 views

Using two different languages where one would suffice for the task (microservices)

I previously asked this on StackOverflow, but doesn't fit there and I was suggested to move it here. I was thinking about using two seperate backend languages for seperating concerns in a project of ...
user avatar
  • 97
11 votes
4 answers
3k views

Should we abandon the "if not null" pattern?

I've seen that with the Dictionary API now has methods with bool TryGetValue<TKey, TValue>(TKey key, out TValue value) and I like this kind of methods because they're signaling to the other devs ...
user avatar
  • 350
2 votes
2 answers
77 views

Calculate operation time and setuptime or costprice based on a variable set of parameters - Design Pattern?

I work in a production company where my colleagues calculate costprices based on 3D models and their respective operations. Apart from workactivities where a user has to insert an operation time and ...
user avatar
0 votes
0 answers
43 views

Implementing the Repository/UnitOfWork pattern using Azure.Data.Tables "TableClient"

I currently have a generic Azure repository AzureRepository<TEntity> store internally a list of table transaction actions like so. private readonly IList<TableTransactionAction> ...
user avatar
  • 183
-1 votes
1 answer
93 views

State machine using SOLID principles. Connecting to real devices

I am trying to implement code for switching states of a couple laboratory devices. My considerations are: how should I link the state objects, state machine object and device manager object to follow ...
user avatar
  • 1
0 votes
1 answer
106 views

Blazor Application separation of concerns

I am building a cross-platform application and have planned to use Blazor. I have made similar applications in the past but using ASP.Net Core for the back-end and Angular for the front-end. I always ...
user avatar
0 votes
1 answer
212 views

How to implement automatic SemVer from code changes [closed]

Goal I'm working on libraries published as nuget packages and I would like the version of those packages to update automatically based on the changes I make. In other words, I would like something ...
user avatar
  • 204
0 votes
0 answers
72 views

Doubts designing an old system using DDD

We have the following system: References that identify a product and have a family which identifies a group in which the reference belongs. Families that are a way to group references, for example, if ...
user avatar
  • 33
0 votes
0 answers
67 views

Custom templated controls, user control and MVVM approach

I am developing a data visualisation tool, with some UI interactivity after initial trail with doing it mostly by using templates in XAML and code behind to handle interactive stuff I've realised that ...
user avatar
-2 votes
1 answer
140 views

How Should I Go About Refactoring My Code With Dependency Injection? [closed]

I work on WPF applications used in testing hardware. I need to make my code base more testable and re-usable. I believe DI would help, but I'm not quite sure where to start. I've done my best with the ...
user avatar
1 vote
0 answers
191 views

WPF Best way to create viewmodel from another viewmodel

Often I want to open a new window from within some view. I see opening a window as view logic. So I don't want code in my viewmodel that creates/opens/changes windows or anything else that interacts ...
user avatar
5 votes
6 answers
420 views

Unsupported concurrent calls, throw exception or log a warning?

Context Let's say I have a navigation service that allows me to navigate to a page. The Navigate method is async because an animation (about 250ms) is involved. public interface INavigator { ...
user avatar
  • 204
1 vote
1 answer
85 views

Contextual Implementation Overhead vs Redundancy

I have an application that has use cases relative to where it is used. A local client and server, where all the server data is in a single location and the client queries that server knowing it is ...
user avatar
0 votes
1 answer
380 views

How to handle duplicate validation logic with CQRS pattern

I am implementing a CQRS pattern in ASP.NET Core with MediatR, and I am wondering what the general consensus is for handling duplicate validation logic for queries/commands which operate on the same ...
user avatar
0 votes
2 answers
140 views

How to handle continual method addition to an existing class

I find myself often adding more and more methods to a specific class, is this class heading in an unmaintainable direction? Or is this class fine even if it has 50 or more methods? let's call the ...
user avatar
  • 111
0 votes
2 answers
215 views

Which strategy to use to create object instances

I have this use case (I've simplified it): Each student can apply for one or multiple activities. As of now we only have Swimming activity onboarded on the system, but we expect to have more. Base ...
user avatar
  • 109
3 votes
4 answers
692 views

How to get an ILogger instance from extension methods?

Let's say I have this service abstraction exposed from a library. public interface INavigator { ImmutableList<IPageViewModel> Entries { get; } void NavigateForward(IPageViewModel page); ...
user avatar
  • 204
0 votes
1 answer
119 views

Architecture solution for scalable crawling

I have the following requirements: a list of queries (rather long list ~ 100K - 1M items or even more) that I need to perform in a certain period of time and the execution time must be predictable. ...
user avatar
0 votes
2 answers
179 views

Where should helper classes/methods for transforming business data for the View be located

I have inherited a badly architected and organised ASP.NET MVC application, which is an online booking system for healthcare providers. It seems to have been designed with very few object oriented ...
user avatar
1 vote
3 answers
470 views

Why would you have a different namespace for each folder in a C# project?

I can't see how having a namespace for each folder makes sense. As near as I can tell, the point of having namespaces is to avoid name conflicts. But, Microsoft, in their namespace naming conventions, ...
user avatar
-1 votes
2 answers
375 views

Loop pattern for batch data processing

When processing data sets in batches I usually can think of the following three implementations. Which one do you consider better than the other and why? Notes: The implementation is in C# but the ...
user avatar
0 votes
1 answer
49 views

Better design for a REST import into web store

I have an import that needs to grab data from a REST service and import into an web store. It's basically an ETL type of service, but because the REST service can be slow and I don't want to call it ...
user avatar
0 votes
1 answer
76 views

Mapping destination object from multiple source objects vs constructing using multiple source objects (as in constructor)

Lets say we have DTO class with 15 properties. Usually DTOs like these are mapped from other objects. But sometimes some DTOs may use values from multiple objects. In these cases, should we “Map” or “...
user avatar
6 votes
4 answers
322 views

How to provide logging to consumers of a NuGet package/library

I've been building a library (NuGet package as I'm in the C# world here) & I want to add logging so the consumer of the library can optionally provide some logger to the library. However, there ...
user avatar
-2 votes
3 answers
310 views

Are interfaces made useless by the template pattern?

Refer to the highest upvoted answer here for why you should make an IPizza interface with a IPizza.Prepare() method. This is highly upvoted, But I think the answer is flawed. Sure a pizza can be ...
user avatar
  • 113
1 vote
0 answers
137 views

What design pattern does this implementation follow?

For a middleware solution I expose an API, which processes data and sends the necessary information to different parties. In the current design we create a new client, which acts sort of like an ...
user avatar
-3 votes
2 answers
117 views

Case Statements for string to string mapping [duplicate]

I have a class called SomethingProvider that contains: private static string convertMapA(string convertA) { switch (convertA?.ToUpper()) { case "NONE": ...
user avatar
  • 105
-3 votes
3 answers
322 views

Can be logic around `List<T>.Enumerator._version` considered control flow exploitation?

List<T>.Enumerator “snapshots” list version upon creation by _version = list._version;. This allows enumerator to halt enumeration when List<T> changed during it. This behavior likely ...
user avatar
  • 268
0 votes
3 answers
192 views

Should I send the current or previous state with my state changed event?

I have an event that is raised when my job objects change state (e.g. initializing, running, complete, etc). The event is to be invoked from my set method in the State property, but before I make it ...
user avatar
0 votes
3 answers
178 views

Should I perform simple validation (not null, max length, etc.) in a web api controller and duplicate in a command handler?

I have a question about DDD. I wonder if I should add validation in a web api controller and duplicate it in a command handler? Is it good approach to validate a DTO and a command even if the ...
user avatar
2 votes
3 answers
159 views

Use abstract factory (or an alternative way) to produce an instance of a subclass?

Context for this question I'm currently working with small data storage media (e.g. RFID tags) that contain some fixed number of bytes that can be manipulated. The drivers that allow reading bytes ...
user avatar

1
2 3 4 5
96