Skip to main content
Theraot's user avatar
Theraot's user avatar
Theraot's user avatar
Theraot
  • Member for 12 years, 11 months
  • Last seen more than a month ago
comment
Error handling. Is it always necessary?
FileSystemObject.FolderExists should not fail. I don't know if it can. It doesn't fail with invalid paths, or even paths to which it does not have permission to access (it simply returns false). However, I cannot discard that it is possible that it can fail. For example there could be an stack overflow, or it might run out of memory. Yet, those aren't the kind of things you want to have error handling for. I don't think the example function should include error handling. Yet, that does not mean there not other cases where it is useful, even necessary.
comment
Is there a reliable way to get get the fingerprint of a file hosted online, without fully downloading it?
@Akiva If the Etag returned by an url changed, the contents changed. There is no guarantee of two different urls that have the same contents having the same Etag. And yes, some servers will use some Hash or HMAC for Etag, either of the contents or simply of the timestamp of the modification. No idea how common those are.
comment
Is there a reliable way to get get the fingerprint of a file hosted online, without fully downloading it?
@Akiva I don't think you are going to have a neat solution to your problem. At least not without the server collaborating. At least you need to create or extend a protocol to talk with the collaborating server. Without server collaboration, you may, for example, have a server download the content and hash it, and then the client can talk to that other server... That way you prevent the client having to download the contents if it is duplicate. Then that server you set up has all the cache problems. We can also imagine a torrent-like solution that distributes this task in a decentralized way.
comment
Is there a reliable way to get get the fingerprint of a file hosted online, without fully downloading it?
There is no standard for this. Quaternary to the question, learn about the Armstrong Condenser (I'm taking the liberty to coin that term, after all, it likely is a necessary step before we can make a Matrioshka brain). Oh, wait, this is not worldbuilding.stackexchange.com. See also Content-addressable memory.
comment
Do any programming languages use types as values? Would there be any point?
Given you accepted the answer by Lie Ryan, I believe I misunderstood you. Does using classes as values in Python (as described in the aforementioned answer) give you the strong type checks you want?
Loading…
revised
Loading…
Loading…
comment
Do any programming languages use types as values? Would there be any point?
And we are not talking reflection, right? Edit: I mean, you have .NET Type type, for example, which will allow to do most if not all that is described here via reflection. We are not talking strings as types either, right? For example Visual Basic CreateObject or PHP new and get_class and similar which use strings.
comment
Snake Game design
When I have done this game, I have gone with the Game 'has-a' Snake. I consider the board a different level of abstraction. I consider the board what we use to communicate to the engine what to draw. So I put an architectural line there. The board should not depend on something more abstract than itself (such as the snake). By the way, there is another way: The Snake 'has-a' Board. And it is responsible of updating it.
comment
How can I defend reducing the strength of code reviews?
The reason to move methods to another class should not be the number. A rule about ordering logically related methods together should not have come up if non-logically related methods don't share file. So, at first glace, split the class in multiple files. Then there is the question of single responsibility principle. A class with methods that are not logically related needs a SRP review. This also suggests that the design process (which happens to be TDD) is not taking care of that (which is not what I'd expect of "religious fundamentalism" TDD). Is nobody responsible for the design?
Loading…
comment
Should functions depend on other functions?
Suppose I have the main function, and some other doSomething function. Now I want main to do the same something that doSomething does. Should main call doSomething or should implement the same functionality again? If the answer always was to implement the same functionality again, we would never make functions. And thus functions have not stuck as a language feature. Since functions are an acceptable language feature, it is acceptable for a function to depend on another. QED. Addendum: the question should be when is it ok.
answered
Loading…
comment
What is the technical terminology for the practice of checking for null and edge cases in programming?
For a context shift, consider Total functions (as understood in math and functional programming), which (along with restriction on recursion) must be defined for all possible inputs.
comment
What is the technical terminology for the practice of checking for null and edge cases in programming?
I agree that defensive programming is the right topic. I also agree that input validation covers what you mention. See also fail-fast, and contrast offensive programming and exception handling. You might also find Circuit breaker design pattern interesting.
comment
Do compilers optimise in concurrency?
Most language don't lend themselves well to this, because the compiler does not have information on whether or not the functions can interfere with each other if run in parallel. Functional languages that mark pure and impure functions would be best suited to this. However, I can't tell which compilers do this, if any.
awarded
comment
How to model and unit test code with multiple side effects?
I approve this message. I would have wrote basically the same thing, but with more words. I'd probably gone about asynchronous code, functional purity, architectural lines, and when to use one approach instead of the other.
comment
How to model and unit test code with multiple side effects?
Dependency Injection, Interface Segregation, Mocks… That is the usual approach. This not far from what is usually covered by Software Architecture courses, et. al. Have a class whose single responsibility is to coordinates other classes with more specific responsibilities. Then inject those. Then define a interface for them, so you can replace them. Then create test mocks against those interfaces. Edit: This might pass as answering in a comment, sorry about that. Yet, I believe this is expected knowledge for many here. did not down vote. Advice: Break down the problem. Ask narrower questions.
1 2
3
4 5
34