Click here to Skip to main content
15,845,330 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
AnswerRe: Where to start? - Program which allows multiple users on a network to add different inputs Pin
Gerry Schmitz18-Dec-16 7:44
mveGerry Schmitz18-Dec-16 7:44 
AnswerRe: Where to start? - Program which allows multiple users on a network to add different inputs Pin
jschell26-Dec-16 7:28
jschell26-Dec-16 7:28 
QuestionVirtualization To Make a Sandbox Pin
Richard Andrew x6416-Dec-16 15:38
professionalRichard Andrew x6416-Dec-16 15:38 
AnswerRe: Virtualization To Make a Sandbox Pin
Munchies_Matt17-Dec-16 1:15
Munchies_Matt17-Dec-16 1:15 
AnswerRe: Virtualization To Make a Sandbox Pin
Gerry Schmitz18-Dec-16 8:07
mveGerry Schmitz18-Dec-16 8:07 
AnswerRe: Virtualization To Make a Sandbox Pin
Nathan Minier21-Dec-16 4:31
professionalNathan Minier21-Dec-16 4:31 
AnswerRe: Virtualization To Make a Sandbox Pin
jschell26-Dec-16 7:37
jschell26-Dec-16 7:37 
QuestionCalling class function vs function getting class variables Pin
hpjchobbes7-Dec-16 15:04
hpjchobbes7-Dec-16 15:04 
This is more of a general design concept, but if I had a class which I intend to have a list of those objects (around 5000) and I need to perform some function on each of these, should I be designing around a function that is part of the class or a separate function that takes a collection of these objects? I know that there's always situations where one may be better than another, but when first starting to think about the design, which way would be recommend

For example:
C#
class Person {
float HungerLevel;
public void AdjustHunger(float amount) { HungerLevel += amount; }
}

public void AdjustAllHunger(List<Person> PersonList, float amount) { foreach(Person in PersonList) { Person.AdjustHunger(amount); } }
or
C#
class Person {
float HungerLevel;
public void AdjustHunger(float amount) { HungerLevel += amount; }
}

public void AdjustAllHunger(List<Person> PersonList, float amount) { foreach(Person in PersonList) { Person.HungerLevel += amount; } }

I would imagine that the second option is more efficient if I need to change all objects in the collection by the same value, but not sure. I guess it could even depend on what language I'm using and how it would try to optimize the code? Does a call to a function have a higher cost than a call to an object's variable? Expanding on this example, what if the hunger change was based on another of the objects variables.
C#
class Person{
float HungerLevel;
float Metabolism;
public void AdjustHunger(float amount) { HungerLevel += (amount * Metabolism); }

public void AdjustAllHunger(List<Person> PersonList, float amount) { foreach(Person in PersonList) { Person.AdjustHunger(amount); } }
vs.
C#
class Person{
float HungerLevel;
public void AdjustHunger(float amount) { HungerLevel += amount; }
}

public void AdjustAllHunger(List<Person> PersonList, float amount) { foreach(Person in PersonList) { Person.HungerLevel += (amount * Person.Metabolism); } }


I don't have a project right now that deals with this, but the concept popped into my head and I was thinking about how I would start designing this. I could probably setup a test case and try it out with a sample, but is that what most programmers do at the designing stage, creating multiple test implementations? Is there some sort of 'design theory' that I would/should be using? I'm self taught, so I don't know if this would be something that is covered in a more structured training environment (so please excuse me if this is a dumb question).
AnswerRe: Calling class function vs function getting class variables Pin
Mycroft Holmes7-Dec-16 17:58
professionalMycroft Holmes7-Dec-16 17:58 
GeneralRe: Calling class function vs function getting class variables Pin
hpjchobbes7-Dec-16 18:15
hpjchobbes7-Dec-16 18:15 
GeneralRe: Calling class function vs function getting class variables Pin
Mycroft Holmes8-Dec-16 12:52
professionalMycroft Holmes8-Dec-16 12:52 
AnswerRe: Calling class function vs function getting class variables Pin
Gerry Schmitz7-Dec-16 18:27
mveGerry Schmitz7-Dec-16 18:27 
AnswerRe: Calling class function vs function getting class variables Pin
jschell26-Dec-16 7:49
jschell26-Dec-16 7:49 
QuestionDistribution of deliverables over the air. Pin
CodingLover28-Nov-16 23:51
CodingLover28-Nov-16 23:51 
AnswerRe: Distribution of deliverables over the air. Pin
Nathan Minier29-Nov-16 2:44
professionalNathan Minier29-Nov-16 2:44 
GeneralRe: Distribution of deliverables over the air. Pin
CodingLover29-Nov-16 16:32
CodingLover29-Nov-16 16:32 
AnswerRe: Distribution of deliverables over the air. Pin
Richard Deeming29-Nov-16 3:02
mveRichard Deeming29-Nov-16 3:02 
GeneralRe: Distribution of deliverables over the air. Pin
Mycroft Holmes29-Nov-16 14:18
professionalMycroft Holmes29-Nov-16 14:18 
GeneralRe: Distribution of deliverables over the air. Pin
CodingLover29-Nov-16 16:33
CodingLover29-Nov-16 16:33 
AnswerRe: Distribution of deliverables over the air. Pin
Daniel Pfeffer29-Nov-16 4:16
professionalDaniel Pfeffer29-Nov-16 4:16 
GeneralRe: Distribution of deliverables over the air. Pin
CodingLover29-Nov-16 16:40
CodingLover29-Nov-16 16:40 
GeneralRe: Distribution of deliverables over the air. Pin
Daniel Pfeffer29-Nov-16 21:57
professionalDaniel Pfeffer29-Nov-16 21:57 
NewsRe: Distribution of deliverables over the air. Pin
CodingLover2-Jan-17 16:27
CodingLover2-Jan-17 16:27 
AnswerRe: Distribution of deliverables over the air. Pin
Gerry Schmitz29-Nov-16 8:10
mveGerry Schmitz29-Nov-16 8:10 
GeneralRe: Distribution of deliverables over the air. Pin
CodingLover29-Nov-16 16:41
CodingLover29-Nov-16 16:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.