All Questions
175 questions
83
votes
12
answers
31k
views
What is the utility and advantage of getters & setters especially when they are merely used to read and assign values to properties of an object? [closed]
I’m still really new to learning to program. Just learning the syntax for a few programming languages at the moment.
The courses I viewed for C# and Java touched only very briefly on getters & ...
3
votes
5
answers
993
views
How are strings simultaneously objects and primitive data types in C#?
In C#, strings can be used like objects with methods, properties, and other features of objects. At the same time, strings are treated the same as primitive data types like int or float in numerous ...
0
votes
3
answers
434
views
Would you test this piece of configuration code? How do I determine which code is worth testing?
We have a piece of code that decorates an interface to transparently add retry logic.
Inversion of Control configuration
service.AddOurRestApiClient()
.AddResilienceHandler("Retry", ...
92
votes
16
answers
21k
views
Do the young minds need to learn the pointer concepts?
Why did the C master Dennis Ritchie introduce pointers in C? And why did the other programming languages like VB.NET or Java or C# eliminate them? I have found some points in Google, and I want to ...
43
votes
3
answers
17k
views
Why is the logical NOT operator in C-style languages "!" and not "~~"?
For binary operators we have both bitwise and logical operators:
& bitwise AND
| bitwise OR
&& logical AND
|| logical OR
NOT (a unary operator) behaves differently though. There is ~ for ...
89
votes
11
answers
13k
views
Did the developers of Java consciously abandon RAII?
As a long-time C# programmer, I have recently come to learn more about the advantages of Resource Acquisition Is Initialization (RAII). In particular, I have discovered that the C# idiom:
using (var ...
63
votes
6
answers
28k
views
Why was C# made with "new" and "virtual+override" keywords unlike Java?
In Java there are no virtual, new, override keywords for method definition. So the working of a method is easy to understand. Cause if DerivedClass extends BaseClass and has a method with same name ...
67
votes
16
answers
9k
views
How much freedom should a programmer have in choosing a language and framework?
I started working at a company that is primarily C# oriented. We have a few people who like Java and JRuby, but a majority of programmers here like C#. I was hired because I have a lot of experience ...
32
votes
7
answers
9k
views
What does this statement about C# and Java being half of a language mean? [closed]
In the article: Why POCO, there is this sentence:
Maciej Sobczak puts it well: “I just don’t like when somebody gives me half of the language and tells me that it’s for my own protection”.
I don't ...
74
votes
5
answers
83k
views
Why do C# developers newline opening brackets?
I've spent most of the last several years working mainly with C# and SQL. Every programmer I've worked with over that time was in the habit of placing the opening brace of a function or control flow ...
71
votes
8
answers
23k
views
How do you encode Algebraic Data Types in a C#- or Java-like language?
There are some problems which are easily solved by Algebraic Data Types, for example a List type can be very succinctly expressed as:
data ConsList a = Empty | ConsCell a (ConsList a)
consmap f ...
0
votes
2
answers
417
views
How to restrict the construction of a domain object to an external service?
I have this object
RelativeFoo{int relativeCode, Origin relativeTo}
And I want to map it to this other object
AbsoluteFoo{int absoluteCode}
In order to do this, I need to use a service whose ...
31
votes
9
answers
11k
views
Designing a Class to take whole classes as parameters rather than individual properties
Let's say, for example, you have an application with a widely shared class called User. This class exposes all information about the user, their Id, name, levels of access to each module, timezone etc....
22
votes
7
answers
15k
views
Should "Set" have a Get method?
Let's have this C# class (it would be almost the same in Java)
public class MyClass {
public string A {get; set;}
public string B {get; set;}
public override bool Equals(object obj) {
...
41
votes
8
answers
4k
views
Can modern OO languages compete with C++'s array store performance?
I just noticed that every modern OO programming language that I am at least somewhat familiar with (which is basically just Java, C# and D) allows covariant arrays. That is, a string array is an ...