Skip to main content

What code makes you happy?

I can't say what code makes you happy but I can tell what code makes me happy.

My greatest satisfaction is from :

  • Getting things done (documents, features, working with people, etc).
  • Understanding / learning how a specific framework, library or tool ready works.
  • Visualizing how and why a design works or does not work.

A while back I had a couple of very pleasurable moments working with some code.  One moment was working with the Java Swing GUI Library and the other was in a design pattern that was a variation of MVC (Model View Controller), or so I thought.

I was working with the Java Swing library trying to get a panel contained in a JScrollPane to set the scroll bar at the top of the viewport.  For a normal panel this is a piece of cake but not when the panels components are dynamically added to the panel after it's made visible.  What made me happy about this task was that it forced me to think of not what I wanted to do but what was really happening inside the library.  My first try at a solution was the standard brute force method (which did not work), then scanning the forums for solutions (which did not cover my issue or work) and then looking at the problem from a very different angle.  I needed to logically think of what must be occurring in the Swing library during the dynamic addition of components and look for injections points where a solution could be applied.  This lead to a very simple, clean and easy solution to my problem.  It's the re-training of the thoughts to come after a problem in completely different direction that makes me happy.  It's the Aha moment that makes me happy.

My second happy moment is from looking at a design pattern that I have seen used long ago involving an SOA service request where the results used a Publish / Subscribe pattern to update the (MVC) Views that utilized the returned data.  I had seen this pattern decades ago when Window's development was just getting started.  Developers where using the WinAPI for not only the built-in messages but also created their own messages by defining new MessageIDs (aka "WM_USER + n") and passing their own data around inside the application.  You do not see this patten anymore as the number of messages and transient data gets very complex as structure and API are replaced with messages that magically go somewhere.  I could not quite put my finger on the other reason for why this pattern felt wrong, and then it hit me.  It was combing the behavior of both the Model updates with the View notification.  These are two separate concerns that are being combined into a single operation.   This variation of the MVC pattern was not MVC at all, it was just the old WinAPI message pattern but with very little structure behind it.  It was being called MVC was it was not.  It's this process of removing hype and comments from others and learning for myself what is really occurring that I enjoy.  Again it's the pealing away of miss-information, hearsay and preconceived notions to find the facts buried beneath that make me happy.

By diving deeper into what is really occurring in the code or design I get to understand what I need to do.  For me this generally results is writing less code that I hope is clear and easy to maintain.  This is what makes me happy.

Next: Truth -vs- Facts.

Comments

Popular posts from this blog

Still Life

 Life is never still, at least I don't think you would want it to be.  That's why so many of us (i.e., retired care free people) travel.  Keep seeing new things and places.   Well the Hurricane so far inland was a new thing and one I would have rather forgone but life is what happens.  Life keeps moving. Except a still life is forever and captures a slice of time frozen in a painting.  This is from a wooden bowl of pears onboard our ship during dinner one nice.  Again, just thought it looked nice. Enjoy.

A Trip Abroad

 Just back from our trip abroad as Asheville continues to recover from the hurricane.  This trip has been planned for a long time and we almost didn't make it because our dog sitting business will be closed for a while. But make it we did and now we are back. We love Amsterdam.  What a fun place to visit.  So many things to too and do there.  The weather was not the best but it did not have an impact on our visit.  Just bundle up. Got some quick painting in while on the boat (i.e., Viking) as we moved from port to port.  This painting is of a garden at a heritage site of windmills.  I thought it looked nice. Nice time on the trip to de-stress from what was happing back home.  We were fine back home but not everything is well with many others.

A Process

Once in a while I take photos of a work in progress.  This is for me as well as others as the work moves from stage to stage.  And it is done in stages with defined processes for each step.  On this walkway overpass up in Spruce Pine, I've done both an ink / marker and an Ink / Wash on the same piece. This is the finished watercolor of the work.  To start the process I did an ink drawing of it and then took a tracing from that.  It's the tracing where I did another ink drawing but this time on watercolor paper. Tracings of a work is done with standard tracing paper.  I get mine from CheapJoes.com and use the 8x10 size as that covers most of my needs.  The tracing is done with a 0.3 ink pen (Winsor & Newton Fineliner).  Once I have the tracing I can then use it for other paper or to do another work of the same subject. The tracing is just a start as I still need to get it transferred onto other paper.  For that you need a very bright light...