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
0
votes
0answers
11 views

C# - Generic Configurable Condition checker at Runtime - Achievement System

I'm writing a "generic" achievement system for my MMORPG project, it needs to be friendly & efficient for my game designers (without having to write code to add new achievements). If anyone got ...
-3
votes
0answers
26 views

Integration test practice vs c# [closed]

Can I build a beginner app such as a registration form which stores user info to a db and then write integration tests for this app? Wondering if there are any formal structure I should follow while ...
-6
votes
0answers
34 views

C# new rules for naming method, variables, classes and properties

I am going through Unity API and notice that the nomenclature rules for naming variables, method, properties, fields etc are quite different and confusing. For example, some time they are using ...
0
votes
1answer
41 views

Unit testing async tcp server

I built an async multi-client TCP server for RPC usage. It's working well but I've found it difficult to unit test certain functionality: Connect 2x clients, is client count 2 Connect 1x ...
2
votes
0answers
150 views

Should developers do things that defeat strong-typing, kill intellisense and make it difficult for other developers to follow? [closed]

Just to clarify: This is not a rant. I'm genuinely curious and it's a genuine question our of straight curiosity. I want to become a better developer and even little details like this count. So, don'...
1
vote
2answers
223 views

Is there an advantage of using (“hello {0}”, variable) over (“hello ” + variable)

I am relatively new to programming but have noticed a lot of people when creating strings using variables do something like the below to put a variable into a string. I am curious at the difference/...
0
votes
0answers
58 views

Design pattern for Developing a customize form? [closed]

We have a module that allows the user to create a custom report template that will be filled latter by another user. The module looks like this: In the right side we see the controls we can use to ...
0
votes
1answer
102 views

Architectural pattern for testable C code [closed]

I wrote a lot of software in C# and Python. I tried to make the overall architecture testable by using the "Clean Architecture" and Dependency Injection. This works well for C# (and python). Now I ...
11
votes
3answers
2k views

Looking for an effective pattern to cope with switch statements in C#

I sometimes end up with services encapsulating the responsibility of doing some sort of business process for which there are several possible outputs. Typically one of those output is success and the ...
-2
votes
1answer
63 views

Are These Both The Same Or Different If Statements [duplicate]

This is for unity I tried another way of stopping player after he dies and it worked fine but now it does not work with sounds That was my way the only thing that I changed is the state Ben's was ...
-3
votes
0answers
124 views

Development Time, am i slow? [closed]

I'm developing a small ERP software for a company, they have an access version and im porting it to c#, make it pretty, more robust etc. Im getting doubts about my time management. What i often have ...
-2
votes
2answers
148 views

Best Practices for Managing SQL Code

I have a issue that keeps coming up as a developer using any .NET (C# mostly) and SQL. I personally feel it is bad practice to build SQL statements in code. There are too many case scenarios that may ...
0
votes
1answer
89 views

Create or Update method returning created entity

Clarification question on saving entities best practice. What is the purpose of returning an entity that you might have just saved in a repository? I see the benefit of returning it's Id once it's ...
0
votes
1answer
46 views

GraphQL results in a very large Query and Mutator file for Enterprise Monolith

I am investigating a good maintainable architecture for GraphQL. In particular we want to migrate a REST app to GraphQL. Specifically I am using .NET. I am following the tutorial here: https://...
61
votes
10answers
14k views

When to use / not use syntactic sugar

Currently I am working on a school project written in C#. Some teammates just started in C# and some are already familiar with C#. Today I had a discussion on whether to use syntactic sugar like this ...
1
vote
0answers
56 views

Application Service Layer referring to two Layers, and Database Entity Copy Layer with DTO Layer?

I am trying to review our current architecture. These are the current layers, trying to analyze them, and see if the following three ideas are good practice. DatabaseSQLStorage ---> Entity Framework ...
-3
votes
1answer
144 views

A True RESTful API | Help needed

I know that a RESTful would have unified API and it treats everything as a resource (a noun, example a book, a product,...) and it can be applied with CRUD operations using HTTP Verbs (GET, PUT, POST, ...
-1
votes
0answers
70 views

Help me understand OS dependent and independent languages c# as an example [duplicate]

A NOTE : All of the below is considering that the CPU architecture is the same For every operating system ** Another NOTE : Please If you can make it simple so that a stupid like me can get it ...
1
vote
2answers
64 views

Custom services container for ASP .NET core business layer

My model classes (business layer/library of ASP .NET core solution) uses a number of services (IOrmService, IEmailService, IFileService, IHtmlToPdfConverter etc.). Different models requires different ...
2
votes
2answers
123 views

Copy Database Entities into Another Layer in Software Architecture?

We are using Entity Framework with SqlServer Database. Business program needs to create many columns which are not in the Database, due to storage, high querying cost etc. Currently, the team is ...
0
votes
0answers
61 views

Instantiating adapters in onion architecture

GitHub and NuGet Do you use connection strings to instantiate your adapter services or just always configure it through IoC? I think that connection strings could provide a way more flexibility, ...
2
votes
4answers
203 views

Is having different implementations for ToString and the implicit operator bad design?

I am currently developing a wrapper API for a translation service that should provide multiple methods for translating strings, Task<string> ITranslator.TranslateAsync(string phrase, Language ...
0
votes
2answers
127 views

Is it ok to use .Replace(“ ”, “+”) when reading hashes in a querystring?

I am letting users change their password after a reset, by following a link containing hashes of the password and user name (e-mail address). The link can look like this: www.example.domain/login?...
-4
votes
3answers
105 views

C# Why should i limit myself to List or Stack ? ( instead of having both)

List is implemented in C# exactly as Stack, see: https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.stack-1.push?view=netframework-4.8#remarks https://docs.microsoft.com/en-us/...
-4
votes
0answers
30 views

Multiple background workers causes lag to whole computer

I have a 'Text Recognition' Form that has a button "Select Area" it can select a specific area (like snipping tool) it will draw a red outline, but that selected area will stay in that spot to detect ...
0
votes
2answers
82 views

How to inherit a static function in a class?

Probably the answer is you can't. However, I would like to have a work-around to solve my problem. Objective I am trying to create a program in which I try to avoid nulls as much as possible. ...
1
vote
2answers
103 views

Why can't I use a generic method to implement multiple typed interfaces in C#?

public class B { } public class C { } public class D { } public class E { } public class A : IRetrievable<B, C>, IRetrievable<D, E> { public TValue Retrieve<TKey, TValue>...
0
votes
2answers
123 views

How to avoid deadlock

I have queue of MoveableItems in a class BackgroundTaskQueue (based on example from Microsoft here). Clients call BackgroundTaskQueue.QueueBackgroundWorkItem to add a MoveableItem to the queue. An ...
2
votes
3answers
91 views

Is it ok to have a DTO for each process/app/service in a system?

I have a Foo service that, among other things, retrieves data from a table called Widget. This table has about 50 columns. This service is called by a request from a browser. Now, I have another ...
1
vote
2answers
212 views

How to avoid magic strings when doing Translations

I have worked in companies that to achieve translations based on the user's localization they use a file to store those translations. However, when they try to access a translation on that file they ...
2
votes
1answer
62 views

What are some authorization based design patterns to limit functionality from the perspective of size or amount of data?

I am well aware of role based / activity based authorization in the context of limiting user functionality in a simple on/off manner; however, the problem gets difficult when it's not so black and ...
-3
votes
0answers
40 views

Building a desktop application in windows 10 that interacts with MS Office

We have built an application in an Microsoft Excel userform. It basically connects to a access database to record where documents are and dates and such. Then the program also interacts with word ...
1
vote
4answers
311 views

forEach over branching over null check?

I was watching Zoran Horvat's "Making Your C# Code More Object-oriented" on pluralsightpaywalled. And he says that instead of : if(obj != null) { obj.DoSomething(); } We should have a list that has ...
1
vote
1answer
101 views

Include Get Password function in User Domain without violating separation of concerns

Problem: I am using a Domain Driven Design architecture and I have a domain model called User as follows: public class User{ public User(string username){ this.Username = username; } ...
1
vote
2answers
111 views

How to concat lists with logical ANDs and ORs

Having multiple lists of integers, like e.g.: var p1 = new[] { 3, 9, 5, 8, 9 }; var p2 = new[] { 12, 1, 18, 27, 103, 99, 4 }; var p3 = new[] { 23, 930, 15 }; // ... I want to concatenate them with ...
0
votes
0answers
43 views

Effective data/rows queuing out of database

A component in a system (called Notifier) inserts hundreds of messages ~300 (SMSs) per second in a table in MSSQL database with PENDING status by flagging a column called status with int value 0. ...
-2
votes
1answer
38 views

Creating one or multiple objects based on the input

I am designing the software to calculate employees' hours among others. To simplify my problem let's say that I have Activity class, which has a property Type. This type could be for example "Standard ...
0
votes
1answer
83 views

Simple Poker Simulation - How to design it well

I trying to create a little poker Texas Holdem simulator .. In my solution have some class : Premise : I know about Fisher Yates algorithm. I will implement it later Keep in mind that the next ...
-3
votes
3answers
186 views

Better way than singleton pattern to ensure single instance of class

When this question has been asked before on StackOverflow in 2011 and 2015, all answers as of now suggest to use a Singleton. But that’s not right. Singletons are defined by the Gang of Four to ...
8
votes
3answers
609 views

How can we avoid showing the literal path in the exception's stack trace?

When our in-house developed application (C#, ASP.NET) is throwing an exception, it displays a stack trace that contains path information like C:\users\DEVELOPER_FULL_NAME\path\some-module.cs. So it ...
-1
votes
1answer
75 views

How can I securely store and process user data?

I am creating a Discord Bot in Discord.Net. So first, of course this bot is not a professional project, but I still want it to look as professional as possible. And a huge part is the storage and ...
0
votes
2answers
56 views

where to put presentation data formatting method

I am trying to display a specially formatted dropdown list as part of a view. I have a controller action which fetches the data for the dropdown, then needs to format it by fetching certain other ...
2
votes
3answers
174 views

Should a library throw exceptions that reveal its internal call stack?

While researching this question, I've found a lot of sources like this: Basically, it should be deemed a criminal offense to use "throw ex". The experts I'm seeing this from seem to be working ...
2
votes
3answers
144 views

Why does imprecision fail for these 3 numbers specifically?

Hi i asked this question on SO but no one seems to be bothered to answer the question with actual information. Firstly just to say, i fully know computers are imprecise for floating numbers and ...
1
vote
2answers
115 views

Payment system migration

GitHub There need to be a software design supporting gradual migration from one payment system (E-xact) to another (Stripe). Credit cards data are stored outside, so I would like to use both systems ...
1
vote
1answer
122 views

Create a common interface to use N libraries and define specific behaviours

I am creating a browser automation library that is capable of using Puppeteer(automates chromium) and Selenium(automates all major browsers), but the goal is to also be able to add more libraries in ...
0
votes
0answers
41 views

Layered Model-View-ViewModel design

I am designing an application using C# and Windows Presentation Foundation (WPF). I would like to follow (at least) the very basic rules of software architecture, like dependicies only going in one ...
1
vote
2answers
177 views

What's more expensive on my server-side processing?

So I want to be processing my security protocols server-side, mainly token checks and then role authorisations for certain actions. I'm using c# .net core connecting to an MS SQL database and ...
1
vote
4answers
233 views

Throw an exception in default case of a switch?

In my class I have a processor manager that contains a switch case. I just renamed the real name by Ant, Parrot and Snake. switch (name) { case "ant": ...
2
votes
1answer
76 views

Application Security Trimming vs Database Security Trimming

We have a fairly complex Meetings Management solution which would have one meeting to contain different agendas which would contain some tasks and also documents, etc. There are also different roles ...