« first day (2287 days earlier)      last day (2710 days later) » 

1:20 AM
I'm voting to close this question as off-topic because it is about mathematical induction / recurrence relation / Mathematics instead of programming or software development. — Pang just now
 
 
7 hours later…
8:43 AM
This would be better suited to Software Engineering, rather than Code Review as it's more about pattern than code. — toadflakz 41 secs ago
 
 
1 hour later…
9:56 AM
@RobertHarvey If I remember correctly, the original image was animated and had the cloud standing alone with its arm extended (take a moment to look at the image above and imagine the cloud, alone). A few seconds later the monitor would fade in and, it would appear, uh, grab the cloud. The static version is far less confusing.
 
 
3 hours later…
jrh
12:35 PM
@RobertHarvey part of the problem is that I may not have ran into a case where a property has really helped over a field, but I've ran into plenty of cases like this where properties leaked implementation details like this. Though again for non-final classes I definitely agree that the ability to override a property is great, for final classes properties feel like they violate YAGNI at best.
Another thing that comes to mind is a certain class representing a connection implemented an IsConnected property that seemed to imply that the socket was still there but in reality it was only set on an initial connection and was never reset when the socket was disposed.
While these are probably unambiguously bad designs if the guidance for properties wasn't so overwhelming, this bad code would have been easier to find, I have a hard time just trusting the semantic contract an object after this.
also for final classes properties feel like they violate YAGNI at best. I meant for properties that are just plain get/set.
 
 
1 hour later…
2:06 PM
@jrh That post says, "Don't call private methods or fields using Reflection; expose a public method or property instead." Yes, reflection can expose implementation details if you use it, but that's not the fault of properties.
@jrh That's just a badly-designed class.
@jrh Think of it this way: you routinely lock the doors and windows to your house, for security reasons. Someone who is really determined could still break into your house. But that doesn't mean you simply give up and leave your doors and windows unlocked.
 
jrh
@RobertHarvey I was more referring to the Encapsulation section in the bottom half of my answer
i.e., The PlayerSocket getter allows other classes to run functions to modify the socket.... Note that PlayerSocket is a public property.
I agree that any calling code that depends on reflection as an "interface" isn't good.
 
2:22 PM
It sounds like you believe that properties should not call other methods, even private ones.
 
jrh
I'm generally OK with properties calling static methods just for the sake of formatting strings, etc.
But in general, I feel like properties that modify or return the state of an object gets into murky territory, and is vulnerable to feature creep.
 
Isn't that kinda the whole purpose of properties?
 
@jrh That isn't the fault of properties, that's just a lack of encapsulation. In particular, this is what the Law of Demeter is about: by returning a Socket, the complete Socket interface has become part of the PlayerConnection interface.
 
jrh
Well... as I mentioned getting state gets murky for more complex objects (is it a copy, or THE thing), I rarely set state in objects, it's usually more configuration settings, not really "state".
 
2:29 PM
Configuration settings are state.
Instead of returning the entire socket, that guy could have just exposed some useful property on the socket object, using a get-only property in his own class.
That's how you use a Property properly.
 
jrh
right, as I mentioned in my answer, but it gets tricky when the object itself is desirable, like Image in ImageList or PictureBox
 
Here's a better example: a class that contains a collection, like a dictionary. You can expose the collection as a public property, but you can also write an indexer instead. That indexer could do things like, for example, see if a key is already present in a dictionary before adding it. In an ordinary dictionary, that would be two steps, so now you have a dictionary that's a little bit smarter.
But at the end of the day, if you need to expose an ImageList or PictureBox as a property, then that's what you do.
 
jrh
Indexers are great, I think the IEnumerable interface definitely has its uses; though regarding ImageList and PictureBox, I'm not exposing the Controls, I'm talking about situations similar to the Image property ON those controls when I design classes with similar resource requirements.
 
@jrh If the object you're exposing has “unsafe” methods that you don't want to expose, the usual solution is to create an interface for the safe methods, then use the object adapter pattern to connect the interface to the actual object.
 
jrh
There's several cases where an Image property's ambiguity (copy or return the actual image?) on a class could have made the code very hard to read, I'd almost need both a GetCopy and GetImage method.
 
2:38 PM
C# returns object references by value. It's almost always the actual object, not a copy. If you want copy semantics, you have to specify that explicitly.
What is "GetImage?" If you're coming from the Java world, that's not how it works in C#. It's simply Image.
 
jrh
hmm. The convention of C# returning object references instead of copies is important, I didn't think of it that way.
 
I agree, for reference types the assumption is never that I own that instance and are responsible for cleanup, unless I've created the instance or asked for a new copy.
 
jrh
In that case I suppose making my own Clone on a hypothetical (custom) Image class would have solved the problem
I was confused that ImageList violated the return a reference convention but if that's indeed an outlier than this might be a non-issue
 
jrh
2:54 PM
Kind of a tangent, but since the image is returned by reference, how would you know as a caller when it's safe to Dispose PictureBox.Image? Would it even be possible to determine if other PictureBoxes were using it? (it's easy if the image is a local resource but if it's set in code it gets a little less obvious)
 
3:07 PM
we probably need a new meta faq / canonical, "Why was my blatantly off-topic question quickly deleted by a moderator?"
@amon you are right, but if this site has a «be nice policy», I think that by imediatly delete other peoples questions doesn't fit in those «be nice policies». If I'm in a Math forum and someone ask me: «Why 2+2=4?» I'll try to approach the level of thinking of that person. There are no such thing of "stupid question" and all question deserves an answer. — user256083 5 mins ago
 
jrh
IIRC there was a post that specifically forbid "what tech should I learn next" questions. I'd link it but I forgot where it was.
Found it, I think the comments already covered it, never mind.
 
3:22 PM
@jrh Why was my question closed or down voted? - this is it. But apparently some askers wonder why their questions are not only closed and voted down but deleted. They would of course prefer it to hang at the site for a while and gain answers (in comments if it is closed). See above ^^^ "all question deserves an answer"
 
@gnat Too many misconceptions there to list them all.
 
3:46 PM
@RobertHarvey you probably haven't read the question text yet, top hit is this: "Can you please explain me how can I get an answer for my question, let me HAVE TIME to read the answer and then delete my question if you want?" Lovely... how lovely!
 
4:02 PM
Anyone have the link to Shog's suggest to delete fast?
 
@ThomasOwens it's right there in your answer to duplicate question. Scroll to the words "deleted on the advice of Shog9, one of the Stack Exchange CMs..." - there's a link and quote
 
@gnat I know. I found it.
 
...just in case if you feel proud of being personally targeted by garbage droppers, don't. One post at MSE (deleted) suggests that Yannis is most evil mod over here, not you
 
DAMMIT!
YANNIS! Stop being so evil.
 
4:27 PM
I guess he has stopped already. Now that all moderators do quick deletions there is just not enough garbage posts left for the regular deletion raids like he did in the past (long before Shog recommended this). Though maybe it's too late, he did too much harm to poor askers already and this will keep him top-evil forever
 
 
1 hour later…
jrh
5:50 PM
@amon I guess in that case the class with the method that called the constructor of the unmanaged resource would be the only one responsible for freeing it? The other ones would just be taking the resource "by reference". I prefer to keep unamanged resources as local variables within a single function (so I can use using) but it just doesn't work all the time, e.g., if I have to display an image.
Looking back that was what I did in the code, I didn't really follow that deliberately but that's just sort of where the resources fell into place.
If there's no chance of misunderstanding (i.e., it's generally accepted that an image would be returned by reference) then that makes my life easier, I can give access to the Image to display it but I don't have to worry about client code disposing the image being displayed because they would understand that it might be used in other places.
 
6:12 PM
@jrh Yes. Some languages are a bit more helpful and have an explicit concept of “owning” and “borrowing” a reference.
However, a method that creates a resource needing cleanup may also transfer that responsibility, for example a factory won't also do cleanup. Ideally that's obvious from context and clearly documented, but then again there is this thing called the real world…
It would be extremely confusing if accessing an object through a property would transfer ownership, but if it's a method called CreateFoo(), transferring ownership seems sensible.
 
You're not changing the human. He can still go on vacation. Like I said, give supervisors the ability to unlock files and assign them to someone else. If you look at the answers posted so far, I am now the third person who has recommended this. — Robert Harvey 5 mins ago
[sigh] -- The only thing worse than asking misguided questions is not taking the advice of the people you're asking. It suggests that all you want is to have your preconceived answer validated by others.
 
jrh
@amon makes sense, thanks. The idea of owning and borrowing a reference having language support is very interesting, what languages support this? (Also: for some reason in the back of my mind I assumed the idea of "Ownership" was not as important in C# as it was in C or C++, due to the GC I guess)
That wasn't a correct assumption, obviously. It only made things more confusing.
 
@jrh C++ pioneered this to a degree. If you have an object by value, you own it (duh). A reference is always borrowed. A pointer has no inherent ownership semantics. But there are various smart pointers like unique_ptr (single owner), shared_ptr (refcounted, multiple owners). Rust elaborated on that system and made ownership/lifetimes part of the type system. References can be qualified with lifetimes; the type checker prevents you from holding a reference longer than it exists.
Escape analysis is also used by some garbage-collected language implementations to avoid GC overhead for local variables – if only I use that object, I can allocate it on the stack.
Because C++ has RAII (deterministic destruction allows us to couple resource management with object lifetime) resource management is straightforward. GC only automated management of memory resources. Java's Autoclosable+try-with-resource, C#'s IDisposable+using statement, Python's context managers+with statement all add resource management back to the language, but it's not as safe as RAII: now the using programmer has to write extra code to ensure correctness, and the compiler can't help.
 
6:29 PM
RAII is safer than garbage collection? Surely not.
 
jrh
@amon interesting analysis, I think I got a little confused about ownership when I no longer had to differentiate between pointers to things and the things themselves for reference types in C#.
 
IDisposable ought to be just as safe as RAII. It even takes exceptions into account, IIRC.
 
jrh
using does take exceptions into account.
 
using is just syntactic sugar around a try catch block.
(get my keywords mixed up sometimes)
 
jrh
(I get stuck in VB land sometimes, I go back and forth between C#, C and VB.NET and you can tell which one I'm Using When I Capitalize Every Single Thing)
 
6:33 PM
@RobertHarvey for general resource management? RAII is safer. If I write a class that needs to do stuff in the destructor, I can be sure the destructor will be invoked at a specific time (for local variables: when the current scope is left, for instance variables: after the enclosing instances destructor has run). GC may only happen much later. The only way to mess that up is to create an object with the new operator, which in C++ screams “I know what I'm doing!”.
In C# or Java, it's easy to mess up an IDisposable/AutoClosable object: I just create it and forget to put it into an using/try-with-resource statement.
 
Good afternoon! I'm making a hex editor tailored to reverse-engineer a binary file, would this be an appropriate stack to posts questions?
 
@HireThisMarine That depends on the question – what would you ask?
 
@amon I've picked out the header space but the rest of it seems to be purposefully garbled (even a small change to the file in it's special IDE means almost every byte is modified), in what order should I test cyphers?
I'm first implementing a Caeser cipher decoder/encoder but I can tell from a quick glimpse that this isn't the case.
@amon Does that pass muster or am I better off with r/programming?
 
@HireThisMarine It seems you're asking for debugging help. Software Engineering is more about software development concepts, design questions, development methodologies, …. So no, this is not the place for your questions.
 
@amon Thank you.
 
6:49 PM
Thanks for asking here before asking on the main site, much appreciated! I hope you'll be successful with your reverse engineering quest.
 
@amon Sure. When I questions on Reddit that don't really fit they're usually just ignored, as opposed to being tarred and feathered on stack. Good day.
 
7:19 PM
This might be better suited for softwarerecs.stackexchange.com. — Dave Jarvis 45 secs ago
 
7:45 PM
I had a somewhat related question on programmers: softwareengineering.stackexchange.com/questions/312216/…Kritner 28 secs ago
 
8:01 PM
Oh, I didn't realize that this was a self-answered question. Sorry. Then, may I ask, how is this related to programming? If anything, this is software engineering/design and would perhaps be more appropriate on Software Engineering. — Cody Gray 48 secs ago
 
jrh
8:38 PM
@RobertHarvey Not related to what we were talking about earlier, but adding to the other two articles I linked before you might be interested in this. I only read the first couple articles in the list, but they seem to bring up some new things that I haven't read elsewhere.
 
9:12 PM
@jrh Yeah, you don't have to go far to find OOP criticism. This is my favorite: Execution in the Kingdom of Nouns.
I guess the other two people making the same suggestion are wrong too, then. If you aren't open to advice, then why did you ask the question? — Robert Harvey 2 mins ago
 
 
1 hour later…
10:26 PM
@glennjackman Actually, SO is not an IT help desk. Fixing found code for non-programmers is too broad and therefore off-topic for this site. — TigerhawkT3 11 secs ago
does this question belong on softwareengineering.stackexchange.com instead? — Eric 58 secs ago
 
10:53 PM
You may want to post to SoftwareRecs@StackExchange.com or search there. — Thomas Matthews 11 secs ago
 

« first day (2287 days earlier)      last day (2710 days later) »