Advertisement
Guest User

Untitled

a guest
May 26th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. (I'm trying to get into the mindset of OOP still, so I apologize if this is a very very stupid and confusing question)
  2.  
  3. Alright so I'm having a little confusion about something. I have an object, the ChannelManager, which is responsible for scanning the server for channels which are inactive every x amount of days (the criteria for deciding if a channel is inactive is if their channel owner has not logged in for y amount of days), where x and y are read from a config. I call these values the ChannelScanInterval, and the ChannelUltimatum...
  4.  
  5. It was when typing this message that at this point, I realized that the original issue I was thinking would occur if these values are set would not happen because of the way I programmed it, lol, but I still am confused at what I should do in this situation:
  6.  
  7. Basically, I was giving the ChannelUltimatum value to the ChannelManager object to use to compare the last owner login time against, and I was wondering if I should put the check to make sure the value is satisfactory in the ChannelManager object (before deciding it was unneeded and would not cause a problem, I was wanting to make sure it was greater than 0), OR if I should put the check in the module which reads the configuration file values and sets them.
  8.  
  9. I'm thinking ChannelManager should decide for itself if a value passed to it to use as an attribute is satisfactory or not, and the configuration file reader should not give a flying fuck about validating the values coming from the config, as it's only responsibility is to ensure it gets SOMETHING for the keys requested from the configuration file and that the file exists.
  10.  
  11. So I guess my question is: Is it proper OOP design or whatever for a configuration file reader to only care about if the keys requested from the ini exists along with a value for the key, but otherwise not care about the values that it reads, and for the actual objects that will use those values the config reads do the actual validation for those values?
  12.  
  13. Like for instance, if an object needs to use an integer for something, and it gets that integer from a value set in the configuration file, should the configuration reader verify it's an int before passing it to the object, or should the object itself verify it's an int?
  14.  
  15. The reason why I am curious about this is, if I do this validation in the objects, then it might seem odd that I am checking if it's a string or not before setting it (but isn't that what properties are for? Verifying the value is satisfactory?), and if I do it in the config code, then it'll be kind of weird detecting if it's an int or not there, as why should the config reader care? But, if the key in the ini the config reader is searching for is called "NumberOfChannels" or something, then number implies it should be an int, so wouldn't make sense to verify it's an int there when reading it- dahahrhrhaeiuaeriuatihiu!!!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement