8,954 reputation
63681
bio website
location
age
visits member for 3 years, 5 months
seen 13 mins ago

0x2B | ~0x2B


Dec
16
comment Does agile contradict to Open/Closed principle?
My understanding of O/C is that if you need new behaviour you add new classes or new methods to existing classes. Existing methods in existing classes should not change their behaviour. Once a class has become mature and stable enough and a lot of code depends on it, I do not see why this should be a problem.
Dec
15
comment Coerce bad input or always crash early
@Doval: I totally agree with you. I think you misunderstood what I wanted to say. I would not try to repair the data: return None (if this clearly signals a problem to the caller) or throw an exception as soon as you find an error. The only thing I want to avoid is to implement "only the happy path", assuming that the code will crash anyway when it receives invalid data, and that this is enough.
Dec
15
comment Coerce bad input or always crash early
@Doval: I would not like to go back to my back-end code in six months and change all the places that might receive invalid data to send back a proper "sorry, I can't do anything with that data" response. So, I think that programming each component as if it were external is more robust and requires less maintenance.
Dec
15
comment Coerce bad input or always crash early
@Doval: So, yes, your distinction between internal and external components is a good one, as long as you are 100% sure that a component is really internal. E.g., in my current project we are developing an HTTP back-end that responds to requests generated by our JavaScript client. So the back end is now an internal component. But in six months from now we might decide to expose the back-end and let an external tool send it requests.
Dec
15
comment Coerce bad input or always crash early
@Doval: I agree with you. My point is how you handle this data: you throw an exception as soon as you detect the invalid input? Or you ignore it and let it crash in an uncontrolled way as soon as that data is accessed? Also, in some cases it makes sense to ignore the data without crashing. Consider e.g. a mail client that downloads a badly formatted message: in this case, the client should handle the bad data and not just crash.
Dec
15
comment Coerce bad input or always crash early
"If a negative value comes in, you should be asking yourself: why? If it's from direct user input, why did your front-end allow the minus sign in the first place?": Shouldn't each component be self-contained and not depend on the specification of other components? I.e. the back-end should have a clear specification like "crash on invalid data" or "skip invalid data" or "coerce invalid data", no matter where that data comes from.
Dec
15
comment Coerce bad input or always crash early
"In the long run, programing like this makes your code unreadable, long, ugly and unmaintainable.": Why? Can you elaborate on this? Letting the code crash or handle an error is a matter of requirements (how should the software behave), not of coding style.
Dec
14
awarded  Famous Question
Dec
14
comment How should I represent composeable, associative computations to be repeatedly applied to units of data?
Let us continue this discussion in chat.
Dec
14
comment How should I represent composeable, associative computations to be repeatedly applied to units of data?
@blz: Monad could be useful if the operation you apply to element i depends on the result of the computation performed on element i - 1. If you are only mapping from individual stream elements, then it is just a functor map (fmap), as amon has pointed out.
Dec
14
comment How should I represent composeable, associative computations to be repeatedly applied to units of data?
So, if I understand correctly, Oi indicate different operations on the same frame. So you never have an operation on frame j depend on a previous operation performed on an earlier frame, am I correct?
Dec
14
comment How should I represent composeable, associative computations to be repeatedly applied to units of data?
A few questions. (1) Are you applying a fixed operation f to each new image, or what does the function to be applied to each image depend on? (2) By operation Oi, do you mean the application of such a function f to image i? (3) When an operation Oi depends on the result of a previous operation O(i-n), how far in the past is this previous operation? (4) In general, can an operation depend on the result of one previous operation only, or on more than one (list of previous results)?
Dec
14
comment How should I represent composeable, associative computations to be repeatedly applied to units of data?
Maybe you can define a monad that can help you structure your solution: monads offer associative chaining of functions.
Dec
14
comment When we say a monad 'encapsulates a computation' - is this just saying 'wraps a functional transformation of data'?
@paul: "The monad by itself just "wraps" the data, but monad composition offers the transformation. These 2 facts may be used and in fact used to encapsulate the computation inside the transformation. But in general, the monad is not about wrapping the computations.": Could you expand on this in your answer?
Dec
14
awarded  Popular Question
Dec
14
comment How can I run the FOR loop for more than the size of long long int
@Clockwork-Muse: You have a point there: even if the loop body ran in 10^-6 seconds, the whole loop would take billions of years to execute.
Dec
12
comment Is there something as a bug-free application?
-1: "If you mean, an interactive program where you need to be certain that the real-time behaviour is exactly such and such under any given circumstances, then it's basically impossible to prove there aren't any bugs in it.": This is a very strong statement: can you provide some reference to some book or paper where this statement is defined precisely and is proved to be correct? As it is formulated in your answer, it is difficult to judge if it is correct or not.
Dec
12
comment Is there something as a bug-free application?
@leftaroundabout: If you do not know the exact purpose of a program you cannot write a precise specification of its expected behaviour. On the other hand, you need a precise specification to prove correctness. A program that loops forever might be correct wrt to a certain specification, think e.g. about a web server.
Dec
12
comment Is there something as a bug-free application?
@leftaroundabout: And what would be the purpose of such a program?
Dec
12
comment Is there something as a bug-free application?
@leftaroundabout: A type system can prove certain properties of a program, but they are not the only formal method that you can use to this purpose. Showing that type systems are not sufficient does not show that all formal methods are insufficient.