61,182 reputation
6185277
bio website mathprogramming-intro.org
location St. Petersburg, Russia
age 38
visits member for 2 years, 11 months
seen 3 mins ago

Ok, an obligatory note: opinions expressed here are mine and not those of my employer.


Sep
23
comment How can I regroup elements in a list into a tree based on their values?
@halirutan It took me some time too to construct the correct pattern for this problem. I also recall many similar cases where I did not succeed and someone else here on SE did. So, I wouldn't be ashamed, sometimes we get it, sometimes we don't.
Sep
22
comment How to create a list of variable names to some function of that variable
I discussed Unevaluated in some detail in my post in this Mathgroup thread(my second post there). Some people found that useful.
Sep
21
awarded  Custodian
Sep
21
comment Proper way to deal with lists and map
I specifically discussed this issue here
Sep
20
revised How can I regroup elements in a list into a tree based on their values?
removed the first rule, it turned out to be redundant
Sep
20
revised How can I regroup elements in a list into a tree based on their values?
Changed to a slightly shorter and more elegant version
Sep
20
answered Subvalue and level
Sep
20
answered How can I regroup elements in a list into a tree based on their values?
Sep
17
comment Is it possible to replicate the “magic” of OptionPatterns[] with DynamicModule's local variables?
@RonaldMonson ...total state into loosely coupled parts, which then encapsulate those parts of the state and isolate from others. Thanks for the accept b.t.w., I will try digging some larger and more convincing example and add it to my answer as time permits.
Sep
17
comment Is it possible to replicate the “magic” of OptionPatterns[] with DynamicModule's local variables?
@RonaldMonson But the approach to UI debugging you describe is exactly the one which is made possible with code generation. Basically, you don't divide and conquere a complicated state, instead you automatically generate smaller systems and consider those in their entirety. This is what code generation buys you - basically, your specific UI becomes just one of the possible family of UI-s which you can generate with the same components more or less automatically. So, it gives you a continuous simplification path. Also, when you develop in this way, it becomes more clear how to divide the ...
Sep
17
comment Is it possible to replicate the “magic” of OptionPatterns[] with DynamicModule's local variables?
@RonaldMonson ...its problems (complexity, lots of mutable state), but at least allows you to test the propagation of a given event separately. In Mathematica, the event handling is done for you by the mechanism of symbol tracking in Dynamic. This makes coding easier but debugging harder, because you have no direct access to individual events causing this or that. Code generation allows one to alleviate this situation by having automatic means of generating simpler UIs for all components involved, and allows one to use the "functional" style of debugging for UIs.
Sep
17
comment Is it possible to replicate the “magic” of OptionPatterns[] with DynamicModule's local variables?
@RonaldMonson The usual way I test functional code is that I take a function call out of its enclosing function of which it is a part, and test it on some data separately. The same is true for the UI in this approach: you take out a given component, and test it with a simpler environment (state). You still need to create some state for the tests, but it can be much simpler than in the real case that gives you trouble. A more standard approach to UI (used in say Java or Javascript) is based on event-handling model where events are explicit objects, and one writes event handlers. This has ...
Sep
17
awarded  Constituent
Sep
17
comment Is it possible to replicate the “magic” of OptionPatterns[] with DynamicModule's local variables?
@RonaldMonson The advantage is that all the component functions do not carry any state, and therefore can be tested in isolation, since they don't depend on the environment. This is a toy example, which is why this advantage does not look like a big deal. For comples UI-s, this testability of components and isolation of state makes a big difference. The whole point of code-generation is that you can test relevant parts separately, and only very rarely have to resort to the full generated expression for testing. This is similar to compilation.
Sep
17
comment How can I build an inline documentation utility?
@Mike I don't see a simple way, since Eclipse is a different environment.
Sep
15
comment How to check if a database connection is open?
+1, converting to formatted form is clever. Also, testing for being a Java object reference is clearly better than testing for a symbol being removed, since the latter is a deeper level implementation detail than the former.
Sep
15
awarded  Nice Answer
Sep
15
comment How to check if a database connection is open?
Actually, one can use functions similar to removedNames of that linked answer, to check whether or not the symbols has been removed. Something like SetAttributes[removedQ, HoldAll];removedQ[s_Symbol] := StringMatchQ[ToString[Unevaluated@s], "Removed[" ~~ __ ~~ "]"], and then test as Cases[SQLConnections[], SQLConnection[_, Except[_?removedQ], __]]. I think this should work. In any case, +1 for finding the right direction.
Sep
15
comment How to check if a database connection is open?
The problem is that the head Removed is not really a normal head, see e.g. here. In particular, direct pattern-matching attempts with Removed don't work. So, good idea, but I guess the realization should be more tricky (no time now to try).
Sep
14
awarded  Good Answer