87
votes
When conversion from Integer to Single may lose precision
Single can store much more numbers than Integer
No, it can't. Both Single and Integer are 32 Bit, which means that both can store the exact same amount of numbers, namely 232 = 4294967296 distinct ...
43
votes
Accepted
Should we include the NuGet PACKAGE folder in version control?
A lot of time has passed, and NuGet has changed, so here's a new answer.
NuGet no longer creates a packages folder inside your source structure. Instead there is one in your user directory (%...
28
votes
When conversion from Integer to Single may lose precision
Floating point types (such as Single and Double) are represented in memory by a sign, a mantissa and an exponent. Think of it as scientific notation:
Sign*Mantissa*Base^Exponent
They - as you may ...
25
votes
When conversion from Integer to Single may lose precision
Here is an actual example of when converting from Integer to Single may lose precision:
The Single type can store all integers from -16777216 to 16777216 (inclusive), but it cannot store all integers ...
13
votes
When conversion from Integer to Single may lose precision
Floating point types are similar to "scientific notation" in physics. The number is split up into a sign bit, an exponent (multiplier) and a mantissa (significant digits). So as the magnitude of the ...
12
votes
Accepted
Convert a team from VB.Net to C#.Net
If you currently have VB.NET devs who know C#, I don't think all 20 applications need any rewriting all at once. It's just too much coding, testing, rolling out and for what? Because your next few ...
10
votes
Convert a team from VB.Net to C#.Net
Instead of trying to tell you what you should do, I'll share what we did.
Tests get written in C#, because, let's be honest, the VB codebase doesn't have any.
New classes are written in C# inside ...
8
votes
When conversion from Integer to Single may lose precision
Single precision floats have 24 bits of precision. Anything over that is rounded to the nearest 24-bit number. It might be easier to understand in decimal scientific notation, but keep in mind actual ...
6
votes
Accepted
Is a singleton with an update method and software state verification a valid pattern?
Your "singleton" isn't a singleton at all. It's a data cache, which can result in different parts of your app having different version of that cache. In C# code, as my VB.Net is weak:
var instance1 = ...
6
votes
Accepted
Working with a poorly written piece of software as an entry-level developer with no support or documentation
I was not provided with any tests, therefore I need to find out what output the datalogger gives, see what the original software produces, and then use that as tests for when I start making changes to ...
5
votes
Accepted
Newbie: OOP working with different class-datatypes and loop through them
Your named objects either need
Inherits abstractClass
or
Implements interfaceclass.name
Make whichever one you pick and give it a Name method with no implementation.
Then main needs either
Private ...
5
votes
Accepted
How should I protect the data sent over a tcp socket?
How about TLS (SSL)?
I'm not familiar with the details, but I do know it's a pretty transparent layer that will allow you to use whatever protocol you are already using.
Use the protocol over TLS ...
4
votes
What is difference between assigning to auto-Implemented properties VS their backing fields within the class
If you assign directly to a backing field, you can be certain it will work.
If you assign using the property that wraps the backing field, you can't be sure it will work. If the property is ...
4
votes
Convert a team from VB.Net to C#.Net
The question (for clarity, as it seems some couldn't read the question in its entirety): What is the best approach for migrating a team from VB.Net to C# with all of the considerations above?
...
4
votes
How can I keep accurate time in a Windows Forms (WinForms) application?
This sounds like you're in a pretty unenviable position, as you're expected to satisfy conflicting stupid requirements.
First off, messing with system time is a bad idea in general, especially when ...
3
votes
What is difference between assigning to auto-Implemented properties VS their backing fields within the class
Design answer:
You can think of assignment as an function call that has side effects. When you assign to backing fields it means that there are no preconditions and no postconditions. Responsibility ...
3
votes
How should I name output variables that are the same as the function?
Most frequently, I use the variable result.
Don't create ambiguity in the mind of the next Gentle Reader of your source-code. (Since, too bad for you, you just got smooshed by a bread truck, she can'...
2
votes
Convert a team from VB.Net to C#.Net
C# and VB.Net are pretty similar languages, but you still want to reduce the risk as much as possible.
There are tools which can perform the translation semi-automatically.
You should do it one ...
2
votes
What is difference between assigning to auto-Implemented properties VS their backing fields within the class
You should always use the getter/setter as that is the only way to guarantee consistent results.
It’s possibly a minor performance hit, that would depend upon the jitter — it is free to look into the ...
2
votes
Accepted
How can I keep accurate time in a Windows Forms (WinForms) application?
Instead of capturing the start time and using a timer, capture the start time and record the operating system tick count.
StartTime = DateTime.Now; 'Or however you are currently computing it
StartTick ...
1
vote
How can I keep accurate time in a Windows Forms (WinForms) application?
IMHO you are approaching this from the wrong angle. As mentioned, the OS already provides a local time zone as an offset to the system time / UTC. Under modern Windows systems, it requires less clicks ...
1
vote
Duplicated formula in front and back end
Always have one definition for your business rules.
That is a good rule, in practice though things get muddier. Particularly if you have multiple front-ends that do not agree on any form of shared ...
1
vote
Duplicated formula in front and back end
It would be better to only have this logic in the object.
You should protect your database with an API layer and have all queries/reports go through the API.
In the API layer you can use your object,...
1
vote
Accepted
How to handle events in extended classes?
Both options are fine and common. The big difference: with option 1, you can't necessarily tell what order the handlers are fired in, while with the second option, you can decide whether MyBase....
1
vote
Accepted
How should I load and change settings?
With help from RubberDuck's comments, I am able to use the Application Settings function built in to the .NET framework.
This is handling all the on-the-fly changes, as well as persistent changes ...
1
vote
Is a singleton with an update method and software state verification a valid pattern?
The essence of a Singleton is that There Can Be Only One. There is ONE instance of a class being created when it's needed the very first time, no other instance is ever created, and the one instance ...
1
vote
Is a singleton with an update method and software state verification a valid pattern?
On closer inspection, as @David Arno has identified,that isnt a singleton. The value returned by GetInstance potentially varies on each call.
Additionally (and this could simply be my lack of ...
1
vote
C#/VB struct – how to avoid case with zero default values, which is considered invalid for given structure?
How to implement some constrained .NET struct, where its state with default values (set by CLR to technical defaults, i.e. nulls, zeros, etc.) should be prohibited due to some design constraint?
You ...
1
vote
Is it OK to have a property of type COM object
Considering that this is a program that is inextricably linked to Excel, I think its relatively reasonable to treat an Excel.ListObject the same way you would normally treat a .Net object in this case....
1
vote
Should we include the NuGet PACKAGE folder in version control?
My stable datum is: "does it compile or not?"
So I created a VS2022 WinForm app on pc 1
I added a NuGet package NPGSQL v7.0
I compile ok and the app runs ok
I push to GIT without package ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
vb.net × 131c# × 42
.net × 35
asp.net × 6
visual-studio × 6
design × 5
multithreading × 5
design-patterns × 4
object-oriented × 4
object-oriented-design × 4
sql × 4
wpf × 4
architecture × 3
database × 3
c × 3
refactoring × 3
code-quality × 3
inheritance × 3
sql-server × 3
winforms × 3
visual-basic × 3
c++ × 2
algorithms × 2
python × 2
unit-testing × 2