Click here to Skip to main content
15,888,521 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 6:44
mveGerry Schmitz18-Dec-16 6:44 
AnswerRe: Where to start? - Program which allows multiple users on a network to add different inputs Pin
jschell26-Dec-16 6:28
jschell26-Dec-16 6:28 
QuestionVirtualization To Make a Sandbox Pin
Richard Andrew x6416-Dec-16 14:38
professionalRichard Andrew x6416-Dec-16 14:38 
AnswerRe: Virtualization To Make a Sandbox Pin
Munchies_Matt17-Dec-16 0:15
Munchies_Matt17-Dec-16 0:15 
AnswerRe: Virtualization To Make a Sandbox Pin
Gerry Schmitz18-Dec-16 7:07
mveGerry Schmitz18-Dec-16 7:07 
AnswerRe: Virtualization To Make a Sandbox Pin
Nathan Minier21-Dec-16 3:31
professionalNathan Minier21-Dec-16 3:31 
AnswerRe: Virtualization To Make a Sandbox Pin
jschell26-Dec-16 6:37
jschell26-Dec-16 6:37 
QuestionCalling class function vs function getting class variables Pin
hpjchobbes7-Dec-16 14:04
hpjchobbes7-Dec-16 14: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 16:58
professionalMycroft Holmes7-Dec-16 16:58 
GeneralRe: Calling class function vs function getting class variables Pin
hpjchobbes7-Dec-16 17:15
hpjchobbes7-Dec-16 17:15 
GeneralRe: Calling class function vs function getting class variables Pin
Mycroft Holmes8-Dec-16 11:52
professionalMycroft Holmes8-Dec-16 11:52 
AnswerRe: Calling class function vs function getting class variables Pin
Gerry Schmitz7-Dec-16 17:27
mveGerry Schmitz7-Dec-16 17:27 
AnswerRe: Calling class function vs function getting class variables Pin
jschell26-Dec-16 6:49
jschell26-Dec-16 6:49 
QuestionDistribution of deliverables over the air. Pin
CodingLover28-Nov-16 22:51
CodingLover28-Nov-16 22:51 
AnswerRe: Distribution of deliverables over the air. Pin
Nathan Minier29-Nov-16 1:44
professionalNathan Minier29-Nov-16 1:44 
GeneralRe: Distribution of deliverables over the air. Pin
CodingLover29-Nov-16 15:32
CodingLover29-Nov-16 15:32 
AnswerRe: Distribution of deliverables over the air. Pin
Richard Deeming29-Nov-16 2:02
mveRichard Deeming29-Nov-16 2:02 
GeneralRe: Distribution of deliverables over the air. Pin
Mycroft Holmes29-Nov-16 13:18
professionalMycroft Holmes29-Nov-16 13:18 
GeneralRe: Distribution of deliverables over the air. Pin
CodingLover29-Nov-16 15:33
CodingLover29-Nov-16 15:33 
AnswerRe: Distribution of deliverables over the air. Pin
Daniel Pfeffer29-Nov-16 3:16
professionalDaniel Pfeffer29-Nov-16 3:16 
GeneralRe: Distribution of deliverables over the air. Pin
CodingLover29-Nov-16 15:40
CodingLover29-Nov-16 15:40 
GeneralRe: Distribution of deliverables over the air. Pin
Daniel Pfeffer29-Nov-16 20:57
professionalDaniel Pfeffer29-Nov-16 20:57 
NewsRe: Distribution of deliverables over the air. Pin
CodingLover2-Jan-17 15:27
CodingLover2-Jan-17 15:27 
AnswerRe: Distribution of deliverables over the air. Pin
Gerry Schmitz29-Nov-16 7:10
mveGerry Schmitz29-Nov-16 7:10 
GeneralRe: Distribution of deliverables over the air. Pin
CodingLover29-Nov-16 15:41
CodingLover29-Nov-16 15: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.