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

There is no "Right" way.

It's not that your way is not the right way, it's that everyone has their own right way.  So which is the right way?  Is there a right way? Software development is full of discussions that revolve about the "right" way of doing something. The terms used in discussing software design, tools and implementation are so undefined as to make them meaningless.  Code is not designed and written in a vacuum, it's designed by real people in real companies, each with their own constraints and issues.  Code that may look like a hack could have been the result of an employee dragged out of bed at 2am by a company shirt that only cared that they they did not lose their personal client the next morning.  Everything must be looked at in context.  A project written to "Best Practices" may never be finished before development funding dries up.   Goals, vision, constraints and thoughts should be somewhat aligned for project to be successful (or at least enjoyable ...

3rd Try is a Charm

I've been trying to draw / paint these barns for a couple of years but never felt or got them right.  This time I think they turned out right. So What went wrong before and what's right now with this drawing?  This time, the light was right.  It's coming from the upper right and the shadows just looked right.  The other thing is the corn field on the left had to "be in season", otherwise it's just a plowed field.  I had taken other photos from different angles but they never felt right.  This angle has the road, power lines, corn field, etc. all leading to the right.  The shadows on the lower right helps fill in that corner (don't forget about the corners!).  The last part is trying to draw (ink paint maybe) the trees in the background.  Not so easy when they are kind of a blob is green shades. So yeah, it's composition that is king.  Many times I just don't see it until the drawing / painting is finished and when it's right it feels goo...

So THIS is My Style?

 If I play around long enough my style will appear.  I'm guessing that this is kind of it.  I'll keep working on other techniques in watercolor but for now this appears to be my style. I do like it and others appear (to my face) to also like this.  Not every one of my paintings is a success.  About 1/3 so far, but when they do I am rather pleased that anything good comes out of it at all. I do love color.  Color is happy and outdoors is full of color, be it the west or back east with the greens.  Color color color. Also doing some painting on hot press paper and see how that goes. Later......