Skip to main content
18 events
when toggle format what by license comment
Aug 14, 2023 at 8:33 comment added JonasH I think the statement should be mutable global state is bad. If the application is only writing to the logger, it can be considered stateless from its point of view. The implementation will not be stateless, but in most cases we do not need to care.
Aug 14, 2023 at 5:04 comment added Flater @Opifex: The hairs you're splitting about what is and isn't a variable are not relevant to the posted question nor the comment to which you're replying as you're using a wholly different definition of "variable". You're also playing very fast and loose with your definition of why a globally available object is therefore a variable because this is not as much of a given as you make it seem.
Jul 16, 2023 at 23:37 comment added Simon Crase I wouldn't write my own logger, though, unless there were a very good reason. I find that any home-grown logger tends to expand, as it is intended to deal with weird stuff.
Jul 16, 2023 at 20:24 comment added preferred_anon @Opifex I don't understand your comment. My original comment is clear that I consider "variable" to refer to data that can be modified. Even if you don't, the objections to read-only global data are very different to read-write global data. In many languages, functions are objects. Variables are usually references to objects, either mutable or immutable. I don't think any of that clarifies my comment or the question, though.
Jul 16, 2023 at 19:38 comment added Opifex @preferred_anon OP is talking about a logger. Not a logging function. An object is a variable, so a global logger-object would be a global variable.
Jul 16, 2023 at 17:37 answer added Matthieu M. timeline score: 10
Jul 16, 2023 at 13:34 comment added Jeremy Friesner Note that it's not an either/or decision; you could support both a global logger object (or a static API), for ease-of-use in the general case, and passing custom logger object, for when non-default behavior is desired strongly enough to justify the complication of having to pass an object around.
Jul 14, 2023 at 19:58 answer added Warbo timeline score: 1
Jul 14, 2023 at 15:57 comment added nvoigt So I guess you don't have unit tests?
Jul 14, 2023 at 14:58 comment added FluidCode Who told you that globals are bad? Do they know that every running program has a Context? This seems like the usual story of the rule of caution that becomes a rule applied in an obtuse manner.
Jul 14, 2023 at 13:35 comment added preferred_anon I don't think this question can actually be answered unless you say what your "good reasons" are. Most objections I see regarding globals relate to global variables, i.e. global data that can be modified, usually with no designed API. Among other things, all classes and all defined functions in a program are "global" in your sense. So I think the premise needs more justification.
Jul 14, 2023 at 13:15 answer added Doc Brown timeline score: 16
Jul 14, 2023 at 12:32 history became hot network question
Jul 14, 2023 at 10:54 answer added Martin Ba timeline score: 15
Jul 14, 2023 at 7:21 answer added sfiss timeline score: 9
Jul 14, 2023 at 7:05 review Close votes
Jul 19, 2023 at 3:03
S Jul 14, 2023 at 4:25 review First questions
Jul 14, 2023 at 6:33
S Jul 14, 2023 at 4:25 history asked StaticMethod CC BY-SA 4.0