Questions tagged [class]
A template for declaring a type of object.
306 questions
1
vote
3
answers
224
views
Calendar modeling in class diagram
I am creating a cinema website focused on client services, where clients can reserve tickets for movies and browse the cinema's schedule (both daily and weekly). The schedules will be managed by an ...
2
votes
3
answers
2k
views
Is refactoring scattered functions into a class always a good idea?
Straight to the point, here's the original code:
integer = input(...)
size = len(integer)
# Created three dicts for matching numbers as keys to corresponding words
dic_ones = {...}
dic_tens = {...}
...
-2
votes
1
answer
330
views
What is a component in C#?
Introduction
Components are an important building block of software. In terms of software architecture, there are a lot of principles regarding components that should be adhered to (high cohesion, low ...
0
votes
4
answers
500
views
Resolving Dependency Cycles
Class and component dependency cycles
Assume, we have component A with class CA, and component B with class CB, with a cyclic two-way dependency between classes CAand CB. Hence, we have a cyclic ...
-2
votes
1
answer
533
views
Defining functions inside vs outside a class
Say I have a class with a function do_thing that is comprised of multiple steps, which themselves segregate into functions (first_process and second_process). At what point would this be considered ...
1
vote
1
answer
150
views
Can a standalone class be seen as violating the Liskov Substitution Principle
Say we have the interface
interface IColoredSquare
{
int GetSideLength();
void SetSideLength(int length);
string GetColor();
}
and I implement it like this
class ColoredSquare : ...
2
votes
1
answer
2k
views
In Python when is absolutely preferable to use a class instead of a module?
Python is the language I use most in this period.
My background in Java
Before start learning Python I have programmed in Java language. In Java all code is written inside the methods of a class and ...
2
votes
3
answers
225
views
Which association should be in the class diagram
there are a vehicle class and customer class . In short, in the customer class there is a function that shows 'can this person or company rent that car'.The function uses a object of vehicle and ...
0
votes
5
answers
2k
views
Comparing Java objects with different member variables
I have a base class "People" which two other classes inherit from: Employee and Student. The Student class includes a GPA (type double) and the Employee class does not. I have an ArrayList ...
1
vote
2
answers
797
views
How to design an entity that has different fields depending on a type?
I have a specific domain entity that has a given type and some attributes. Based on the type, it can have another set of type-depending attributes. Normally, I would create a class for each type and ...
2
votes
2
answers
157
views
What is the threshold of "usage" of a parent class member that should move to child class?
For example, for base and child classes, if all child class need a class member, eg: baseHp, which represents the base hp to calculate the actual hp of monsters in a game:
public class Monster{
...
0
votes
1
answer
194
views
Assigning to fields in function or by function?
While writing the constructor for class A in Python, I calculate some of the class's fields using function fun(). This function is never used outside the constructor of instances of this class.
In ...
2
votes
3
answers
1k
views
Why do we need factories in the first place?
I went through various blogs but nowhere I can find the reason of having virtual constructors in C++.
Why is virtual constructor needed and lets say if we go through the wrong way of creating virtual ...
1
vote
0
answers
100
views
Mimic public/private data members in C with hidden static arrays
Context
I'm designing the software architecture of a safety critical software written in C, under DO-178C (DAL A) and with a Code Standard based on MISRA-C 2012, but no fully compliant.
It is the ...
9
votes
4
answers
4k
views
How to analyze and understand the use/application of a "class" in a colossal million-line legacy code base?
I am working on a huge code base (more than a million lines of code with a sophisticated architecture) written in C++ over the span of a couple of decades. The task on which I'm working at this point ...