I don't know about the rest of you, but I was a procedural programmer (COBOL, PL/1, C et al) for nearly 20 years before I was introduced to "Object-Orientation", 25 before I started with Java, and 8 years after that to finally break out of the cycle of procedural thinking.
And it really was one of those "Eureka" moments. I was mulling over a problem and then, quite literally, suddenly "got it".
The problem is: How do you explain such a moment? They're incredibly rare (I've had maybe three in my entire life) and I suspect it would be quite valuable to people in the same boat as me to understand how I got there, but these sorts of things are very difficult to explain.
I've written a page called MomentOfClarity, which is my attempt to describe the process, and it was suggested that I post here to try and get some discussion going.
I'd really like it to be a useful page, so please let me know what I could do to improve it. Or indeed, any general points you may have about describing a "light-bulb" moment.
Don't spare my feelings. The page is a work-in-progress, so if you think it's crap, say so. But please tell me why.
Thanks in advance.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Frits Walraven wrote:Great stuff, well written and I am sure many people will benefit from your story!
Thanks Frits. Do you have any suggestions where it could be improved? I've already had a few, including adding a sample implementation for a "Rule" - which I think might make a good appendix - but any others would be gratefully received.
Creator of Enthuware JWS+ V6
Frits Walraven wrote:The only thing I could think of is to add a few drawings to make it a bit easier to grab (e.g. interface rule, and their implementers). Although it is not necessary it just breaks the text a bit.
Yup. Very good idea, thanks. I'll have to dig out an old copy of Visio.
Apart from that, just a small question: why didn't you feed the lines into the getRule() method as a parameter?
Because the lines are a member field of the class containing the getRule() method. But I agree that passing them as a parameter would probably be more loosely coupled.
Thanks for sharing your experience, Winston! I believe I can understand the feelings, as I did experience my own moment of clarity years ago, when I eventually grokked the concept of pointers. In one moment it was all foggy, then it clicked and - voila - everything was clear and easy. I don't recall any such moment in the field of object oriented programming. My transition from "structures with methods" to "object oriented design" was much more gradual and perhaps isn't finished yet. I do remember the first time I've, somewhat grudgingly, favored composition over inheritance in certain solution and it turned out very pretty at the end - to my own surprise.
I like your example - it is very clear and concise. I believe it would easily fit into an OOP textbook. My own problems with the object oriented design usually start when things get more complicated than that. For example, if the rules would need to "know" about each other. Let's modify your original task:
Write a parser that can go through a source file made up of lines of text and store all comments and quoted strings to a separate file. Quoted strings inside comments need to be recognized as well (but not the other way around!). And, of course, do it "intelligently".
I'm sorry if it doesn't make much sense, but it is similar to tasks I've already had to solve in my career. What we have now is some hierarchy of rules, as strings inside comments need to be caught, but comments inside strings not. Whenever I've bumped into something like this, I always produced code I didn't exactly like. I'd be interested to know what would your take on a similar situation be.
Martin Vajsar wrote:Thanks for sharing your experience, Winston! I believe I can understand the feelings, as I did experience my own moment of clarity years ago, when I eventually grokked the concept of pointers. In one moment it was all foggy, then it clicked and - voila - everything was clear and easy.
Glad you liked it; and my apologies for not replying sooner. I had a few distractions, and then of course Christmas back in the UK with family (where I don't currently have 'Net access).
My problem was always breaking out of the "procedural mould". To me a class was always a procedure, and that's how I wrote them; and it's surprising how far you can get with only decent modular technique.
My breakthrough was finally learning how to "visualise" the problem from the object's point of view - the "turning it on it's head" bit. And the fact is that I still can't do it all the time; but that experience (and in particular, writing it down) has really helped me to "smell" when there may be a better (more OO) way of looking at a process.
Actually, I've had 2 Eureka moments in my life, one of them related the programming. It feels to me like a crystal taking shape in my head
My programming Eureka was similar to Martin's above. I remember clearly when I understood pointers. I didn't know it one moment, and the next moment it all clicked. It was back in college and my university didn;t have C++ (which was stupid). I wanted to learn C++ on my own, so I started reading Stroustroup. Man, I tried everything with that book and I wouldn't understand pointers. I read the book, slept with the book, put it under my pillow, tried snorting it. It just didn't click. Then one day, I was stuck in traffic in a bus, and I started dozing off, and then I woke up "I understand pointers". All the things that I had read in the book, maybe 10 times already, suddenly came together. The crystal finally took shape. It's like in the Matrix. They plugged Neo in "I know Kung fu" It was like that (waayy before Matrix came out) sleepy sleepy sleepy "I know pointers". I don't even remember what the Stroustroup book looks like anymore. I remember the crystal moment
Second one was actually the first one. This was right after I started going to college. In school, I was a simple boy. I was entirely dependent on my parents to take care of my needs, and I used to study. Espescially, I loved Math, Algebra in particular. Oh, I could solve those equations all day. Actually, I would make up equations just to solve them. Actually, I was dissapointed when I learnt the Quadtratic method. It took the fun out of it. Outside of Math, I was rather dumb. I was like the dumbo of the house. I used to do dumb stupid things. They would send me to get some food, I would drop it on the way. I would lose my money, my hat, my school items. I was fucking stupid. Someone had to be behind me making sure I'm taking care of my things and myself. My mom used to be worried that I wouldn't be able to hold my own. Then when I started going to college, I had to be independent, and it was scary. However, after commuting to college for couple of days, I made a realization:- I could use Algebriac thinking for everything else. Like when if you look at x^2 + 12x + 36, and you kind of have to keep 12 and 36 both in your head to refactor them, it was kind of the same thing that you need to do to make sure you get on the bus and make sure you don't drop your money. BTW, I don't think this makes sense to anyone besides me. The main thing is that I realized that the kind of mental gymnastics that I do for math doesn't have to stop at math. I could use the math thinking in everything. It was kind of the moment I went from being really dumb to being really smart.. in everything. The crystal formed. I remember that thought creating a physical sensation in my head, but I'm entirely sure that the physical sensation is a made up memory. Another reference to Matrix:- It was like when Neo saw the code behind the matrix, and went from running away from the agents to fighting them back. It was exactly like that. I cracked the code, only I got the power to navigate through life instead of dodging bullets