Martin Fawler in his good "Domain Specific Languages" book heavily uses ANTLR to describe topics related to external DSLs. So, I pick the thing up and got to use it. It can generate lexers and parsers in C# (as well as in some other languages - java, c, c++, python). ANTLRWorks is a IDE with syntax highlighting, grammars visualization and even graphic debugger!
What's rather strange and annoying that the latest ANTLR (3.2) and ANTLRWorks (1.4.2) generate wrong C# code - some attribute classes are just not defined in any assemblies. However, as ANTLRWorks 1.4 (with ANTLR 3.2 integrated) generates proper sources, I quite happy with the tool :)
I recommend the DSL book and ANTLR to every senior developer who needs introduce a DSL into his project instead of tedious XML files or handwritten parsers.
Saturday, December 18, 2010
Sunday, November 21, 2010
"...[existing code] rewrites should be avoided because the programmers will not have been able to understand from the code why the software does what it does and, when rewriting, will revisit all the same mistakes the original programmers made. The same can be said [...] about making big refactorings to code that is new to you when you are not adding any new functionality to the system. It's only by adding a new feature that you can get a feel for the structure that the code needs to have. Otherwise you're just noodling about aimlessly and your refactoring will very probably make itharderto add new features in the future." Nat Pryce
Monday, November 8, 2010
Wednesday, October 6, 2010
The book from my previous post turned out to be a one about POSIX process which in short is old big-up-front design mythology with huge class- and unreadable sequence diagrams, reverse engineering and all the dirty stuff I was absolutely sure died some years ago... Reading the book was a waste of time (especially by the Red See).
Sunday, September 26, 2010
Monday, September 20, 2010
Friday, September 17, 2010
Recently I started reading "Holub on Patterns: Learning Design Patterns by Looking at Code" by Allen Holub and I find it very interesting so far. The author's view on OO design is quite fresh and even extraordinary in places. Although his criticism of accessors and class inheritance may look extreme at first, it's become clearer and clearer to me that the author is absolutely right in his ideas.
Looking forward to continue the reading!
Looking forward to continue the reading!
Monday, September 6, 2010
"...but to me XXX, XXXImpl (or, worse, IXXX, XXX), is a missed opportunity. I want my class name to tell me /something/ about the implementation so I don't have to look in the code: even if it's just that the implementation is backed by a hash set." - Steve Freeman.
Wednesday, August 11, 2010
"Would I use classloader magic and bytecode manipulation to set dependencies in production code? No. Would I use reflection to modify private fields in production code? No. Would I refactor to introduce an interface between objects? Yes. Would I refactor an object to get a dependency through its constructor instead of from a global variable? Yes." Nat Pryce
Tuesday, August 10, 2010
There's a subsystem (a console app that receives tasks and sends reports via WCF). About a month ago I, influenced by GOOS book, wrote a couple of end-to-end tests for the app just before making another refactoring (yes, the app is rather messy) and adding a new feature to it. I liked how it worked.
Yesterday I did a quite big refactoring of the subsystem doing TDD. Things went really smoothly and a bunch of small, focused, loosely coupled classes were the result. At the end, when I was sure that everything is ready to launch the app, I run the end-to-end tests and (uppps) one of them was red! Good! It turned out that I added a class implementing a role interface that'd been already implemented by another one and pass the former as a dependency. The class has default fake implementation (it threw a NotEmplementedException) and cause the app to shut down in a rather rare case (which luckily was covered by the test).
What I realized from this story: we must write end-to-end tests if we want to be sure that all those nice classes really work together. Without them we're doing such a thing that Russians call "a horse in vacuum", i.e. a thing that doesn't has any practical use.
Sunday, August 8, 2010
Saturday, August 7, 2010
"Growing Object-Oriented Software Guided by Tests" by Steve Freeman and Nat Pryce is the most useful, serious and well-written book I've read in last couple of years. It's all about TDD (test-driven development) and OOD. The book shows how unit tests evolve good OO design and how end-to-end tests let the programmer be sure that the hole system actually works. The book is not for juniors - to get the ideas work for you, you must have many years of experience as a software developer, not an architect, a project manager, a coder or whatever.
Every programmer writing in any OO programmer language must read the book twice. I've done.
Among others, I like the authors' conception of "test data builders" which extremely simplifies creating value type objects in tests. There's an open source library for create the builders easier - "Mare It Easy" (its .NET port is available here). I've just tried the latter one and I realized I'll fall in love with it soon :)
Saturday, July 31, 2010
I really HATE regions in C# code. What they actually do is only hide the whole blocks of code. You don't see the entire class when you open it in the editor. What you get is the class's name and a bunch of silly blocks which you must click one after another in order to see what they hide... Even after that the code is messed with the f...ing #region ... #endregion there and here. What's the point in collapsing a class into +fields, +constructors, +properties and +methods blocks?!
However, there's a worse thing to do - "regioning" pieces of a single method (yes, I've seen such a horrible things twice or three times in my career). Just imagine a double nested switch 2000 lines of code length. Done? Well. Now surround each of "case" with "region". I've seen it in reality :(
My opinion is simple: regions cause worse code in general - big classes with tons of big methods.
Monday, June 14, 2010
Just after I set up and got to work a local SVN repository thinking how the thing is really sloooooow, I came across a brilliant sentence in the Uncle Bob blog: "... there’s all the fiddling around with time accounting tools, and horrific source code control systems that perform like a salamander crawling through frozen mud". Excellent!
Saturday, May 22, 2010
Wednesday, April 7, 2010
Friday, April 2, 2010
Monday, March 8, 2010
I feel really wise myself :) Don't wanna ask me why? So, I've been delaying learning .NET Workflow Foundation so much time. It's been very wisely, as the forth version of the library has been completely rewritten by the Microsoft and it's not compatible with the 3.x one. The designer works in WPF (smoooothly), the architecture is elegant and (the last, but not least) the library in general is 10 to 100 times faster than the previous version.
So, I've started think where this new wonderful WF could be fit in my current project.
Sunday, January 31, 2010
Thursday, January 7, 2010
What I really love in living in Moscow - the real winter! It's been snowing and frozen as it should be in winter for four years. The weather is so much different to the one I used to survive in Krasnodar region since my childhood, that I can't believe my eyes and my frozen foots! ;)