A problem of great decision
-
This issue I have it for a while, almost 1 year or more. I tried diverse permutations but always got stuck at some point, when the whole idea will not work anymore. And I give up all the time on it. I have a class with properties, fields and methods in it. I am thinking to add events to it, but im not that great at them yet. When i call this class into form1 I basically change some values inside class, and the "object" that represents it, will add value or change color or change position ,etc. If i have a game let's say, when the character stays and I want him to look like it's breathing, this property should be inside the class? or outside, letting me choose when to breathe, how much, how long, how fast,etc. It's just an example. I had a lot of similar (and more complex) encounters with this subject and I simply freeze in the middle of it, not knowing how to manage it anymore. Both ways are good! From outside or from inside class. But... sometime i need maneuverability, sometime is just in the way and i want it 'there' behind some close door(inside class I mean). What your rules say about this thing? Should I change its values from inside the class? Or from outside? Thank you. ------ thanks to OriginalGriff i relocated here the question.
q12
-
This issue I have it for a while, almost 1 year or more. I tried diverse permutations but always got stuck at some point, when the whole idea will not work anymore. And I give up all the time on it. I have a class with properties, fields and methods in it. I am thinking to add events to it, but im not that great at them yet. When i call this class into form1 I basically change some values inside class, and the "object" that represents it, will add value or change color or change position ,etc. If i have a game let's say, when the character stays and I want him to look like it's breathing, this property should be inside the class? or outside, letting me choose when to breathe, how much, how long, how fast,etc. It's just an example. I had a lot of similar (and more complex) encounters with this subject and I simply freeze in the middle of it, not knowing how to manage it anymore. Both ways are good! From outside or from inside class. But... sometime i need maneuverability, sometime is just in the way and i want it 'there' behind some close door(inside class I mean). What your rules say about this thing? Should I change its values from inside the class? Or from outside? Thank you. ------ thanks to OriginalGriff i relocated here the question.
q12
Don't sweat it, it's something you will learn to decide better as time goes. As a rule, if your property has public setter it implied people will set it from outside! ;) Property usually have very simple set/get behaviour. But you could imagine the class having an Update() method that does some property updating. As well as an external agent modifying them wen needed.
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
This issue I have it for a while, almost 1 year or more. I tried diverse permutations but always got stuck at some point, when the whole idea will not work anymore. And I give up all the time on it. I have a class with properties, fields and methods in it. I am thinking to add events to it, but im not that great at them yet. When i call this class into form1 I basically change some values inside class, and the "object" that represents it, will add value or change color or change position ,etc. If i have a game let's say, when the character stays and I want him to look like it's breathing, this property should be inside the class? or outside, letting me choose when to breathe, how much, how long, how fast,etc. It's just an example. I had a lot of similar (and more complex) encounters with this subject and I simply freeze in the middle of it, not knowing how to manage it anymore. Both ways are good! From outside or from inside class. But... sometime i need maneuverability, sometime is just in the way and i want it 'there' behind some close door(inside class I mean). What your rules say about this thing? Should I change its values from inside the class? Or from outside? Thank you. ------ thanks to OriginalGriff i relocated here the question.
q12
_Q12_ wrote:
If i have a game let's say, when the character stays and I want him to look like it's breathing, this property should be inside the class? or outside, letting me choose when to breathe, how much, how long, how fast,etc. It's just an example.
Inside, since it is part of.
_Q12_ wrote:
Both ways are good!
Nope. Breathing would be done by a "AirSupplier", a base class that both Lungs and Gills inherit from. That way you can instantiate a fish with gills, and a rat with lungs. Add an IBreathable interface for quick filtering of breathing things.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
This issue I have it for a while, almost 1 year or more. I tried diverse permutations but always got stuck at some point, when the whole idea will not work anymore. And I give up all the time on it. I have a class with properties, fields and methods in it. I am thinking to add events to it, but im not that great at them yet. When i call this class into form1 I basically change some values inside class, and the "object" that represents it, will add value or change color or change position ,etc. If i have a game let's say, when the character stays and I want him to look like it's breathing, this property should be inside the class? or outside, letting me choose when to breathe, how much, how long, how fast,etc. It's just an example. I had a lot of similar (and more complex) encounters with this subject and I simply freeze in the middle of it, not knowing how to manage it anymore. Both ways are good! From outside or from inside class. But... sometime i need maneuverability, sometime is just in the way and i want it 'there' behind some close door(inside class I mean). What your rules say about this thing? Should I change its values from inside the class? Or from outside? Thank you. ------ thanks to OriginalGriff i relocated here the question.
q12
Your character (class) could have a "Timer" that regulates breathing (and maybe another "ticker" for a heart). Then you can "attach" (using "component composition") an air supply to your character. Inside the air supply, you can have another timer so that eventually the air "runs out". You can attach a "progress bar" (another component) to your character that goes to blue as air runs out. Think "components"; and how to build more complicated components and scenarios from them.
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal