All Questions
38 questions
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
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 ...
1
vote
2
answers
385
views
Are experienced developers and software architects able to describe an entire software application in terms of design patterns?
Do experienced developers and software architects see entire application in terms of design patterns?
In other words experienced developers and software architects able to describe an entire software ...
-2
votes
1
answer
300
views
Why aren't constructors atomic? [closed]
If thrown exceptions in constructors can lead to memory leaks or partially-constructed objects, then why we don't make them atomic? so neither an object nor it's local variables will get created/...
4
votes
7
answers
2k
views
When to use a class with a constructor vs using a method returning an object
I've been working in a rather large codebase filled to the brim with small classes such as
class Person
{
public string name;
public int age;
public int height;
}
As a mainly front-end ...
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 & ...
-4
votes
1
answer
2k
views
Use Case Diagram for Vending machine
I want to create a use case diagram for a vending machine which has the following states:
Accepts coins of 1,5,10,25 Cents
Allow user to select products Coke(25), Pepsi(35), Soda(45)
Allow user to ...
0
votes
1
answer
58
views
Objectreference vs Equality [closed]
While coding I stumbled upon something like this (extremely simplified example):
public bool Func()
{
Object[] array = new Object[] {false, false};
return array[0] != array[1];
}
I was fooled ...
1
vote
0
answers
83
views
Hierarchy of models while designing a client for a RESTful service
I am trying to write a client for a restful service. I am confused in designing the models. Below are the details:
I have a Model named UnicastMessageRequest, it's definition is like this:
...
2
votes
4
answers
872
views
What do OOP languages gain from having constructors that always return an object?
In what seems like a deliberate design decision, C++ does not have a null value for objects and references. This makes using objects and references very elegant since we don't have to perform null ...
10
votes
3
answers
3k
views
Is it good practice to wrap a related set of properties into its own struct/class?
Writing a User object in Swift, though my question relates to any strongly typed language. A User can have a bunch of links (FacebookProfile, InstagramProfile, etc). A few questions around this.
Is ...
16
votes
7
answers
3k
views
Primitive vs Class to represent simple domain object?
What are general guidelines or rules of thumb for when to use a domain-speciifc object vs a plain String or number?
Examples:
Age class vs Integer?
FirstName class vs String?
UniqueID vs String
...
1
vote
7
answers
4k
views
Repeated Instantiation of the Same Class in a Method
This is sort of a follow up question on Multiple Same Object Instantiation.
And I think, is not really language specific, so this is applicable to Java and C#?
Version A
public MyClass {
public ...
1
vote
3
answers
7k
views
Why not make everything private or public? [closed]
In code there are private and public declarations. Why shouldn't I make everything private or make everything public?
4
votes
1
answer
5k
views
Which is better of these two class diagrams for calculator project and why?
I'm a novice programmer i draw two class diagrams for calculator Project, i want you to check each one of them and tell me which one is better and also, i would appreciate it if you point out the ...