Questions tagged [generalization]
131 questions
2
votes
3 answers
How can I make a function that loops over a list and takes which data member to access as input parameter
I have a datatype PlayerStats which contains a lot of different data members. I want to calculate a score which is different for each data member (the case below looks at statistics.nrOfGoals).
private double getScore()
{
double strength = 0;
…

Simon Andersson
- 23
- 2
2
votes
5 answers
How can I generalize these repetitive blocks of code?
Code with near-identical blocks like this makes me cringe. Plus it adds up to where you have a thousand lines of code where half that would suffice. Surely there is a way to make a loop to make it all happen and not have code that looks so…

DSlomer64
- 4,234
- 4
- 53
- 88
2
votes
4 answers
Can Java Generics replace multiple similar classes?
Problem
I'm trying to use Java generics to replace classes with similar methods. All of the examples that I've found cover simple examples, but I'm not sure if Java Generics are intended to be used this way.
I have 2 parent classes, and 2 child…

Taylor Lopez
- 813
- 1
- 8
- 28
1
vote
1 answer
Is it possible to do something similar to "typeclass" behaviour in Fortran?
I am aware one can use an interface to create a single name for multiple functions. In fact, I've done so in a small code for something like that:
interface assert_equal
procedure assert_equal_int
procedure assert_equal_real
procedure…

lsoranco
- 125
- 9
1
vote
0 answers
Python Generalisation/Polymorphism - invoking superclass method having subclass object in print()
It is academic problem that I present here. The case is to invoke __str__() method of superclass having object of subclass. The case is presented in last two lines (marked with comment hashes. In line commented as #1 you will see what I was…

piom
- 11
- 3
1
vote
1 answer
Generalization of actors in use case diagrams
I have two main actors in the use case diagram where I am modeling the use cases for the visitors of my project: an admin and a user. A user has to signup and then login in order for him/her to open his/her page while an admin has only to login…

yami S
- 21
- 4
1
vote
2 answers
How do I generalize this?
I have a class ExampleProperty that extends the superclass Property and in a separate class, GameObject, I have an ArrayList properties as well as the following method where Engine.createEngineObject(new ExampleProperty()) simply adds the…

Jam
- 476
- 3
- 9
1
vote
1 answer
Cloning Classes i C# (Unity), is there a short hand for these two code snippets?
So I'm working on an equipment system where I have some Item template classes, than i want to clone each time a new item is instantiated for this i have this bit:
public Item(Item clone)
{
this.name = clone.name;
this.description =…

Mikael Wendt
- 104
- 6
1
vote
2 answers
Pairwise combination of arbitrary set of lists
I am looking for a generalized approach that solves the following problem:
Given an arbitrary number of one- or multidimensional lists (NumPy arrays or the like) return their pairwise combinations.
The following tries to give an example for three…

Felix
- 1,837
- 9
- 26
1
vote
1 answer
UML class diagram when templated forms are involved
I'm learning UML diagramming and I am bit confused how to draw the class diagram for my problem
A Firm has many users
A User can belong to many firms
A Firm has many templated forms
A User can't create their own forms but can clone and use a Firm's…

Ramona
- 11
- 4
1
vote
2 answers
Is my Use Case diagram correct? About Use Case generalization
Edit:
Final outcome based on suggestion given by @qwerty_so
This is my use case diagram for View Repository in Source Code Management System.
This system is part of Project Management System.
The system is similar to GitHub, user can select…

wei
- 937
- 2
- 14
- 34
1
vote
0 answers
G-Study with nested and crossed effects
I am having some trouble setting up a G-study for the following data":
rater<- rep(1:4,each=12)
stu <- rep(1:8,each=6)
item<-rep(1:6,8)
score<- sample(2:4,48,replace=T)
dat<-as.data.frame(cbind(rater,stu,item,score))
Students are crossed with items…

asokol
- 119
- 1
- 16
1
vote
3 answers
Is there a way to generalise multiple generators and randoms in haskell
I'm learning Haskell.
Average of large number of Dice Rolls in Haskell
How shall I make the below code work with multiple dices say 8 dices) instead of repeatedly creating let rolls..3,4,5...etc...
module Dice where
import System.Random
import…

Curious
- 921
- 1
- 9
- 25
1
vote
0 answers
Best Practises on Archiving/Storing/Sharing Code
Note: I tagged this under R because I am an R user, but the topic of this question is general, so I appreciate any input regardless of programing language.
Hello Everyone,
My company is expanding into a data-science/developer field and will be…

Alokin
- 461
- 1
- 4
- 22
1
vote
1 answer
What is the opposite of an AoE expiry?
I'm speccing an application that displays time periods to the user. The goal is to present periods in a simple view (no time, no timezones) and detailed view (date and time, with timezone data). The simple view should be unambiguous, in other words…

lofidevops
- 15,528
- 14
- 79
- 119