In training a developer new to object orientation, the discussion of encapsulation took a turn into composition. It all started with the developer attempting to make an object completely stand alone. When he was done, the object was so bloated with code that you practically had to use a wheelbarrow to move it around. Rather than drowning the boy in design patterns I tried a different approach. I tried to explain that although his intentions were good, how he went about it was not. In his efforts to encapsulate everything relevent to the object, he had also begun to encapsulate functionality in such a way as to make the object a composition of functionality. When we first learn to develop, our throughts tend to be sequential and subsequently, we lay our code down the same way. What that does is to combine the code into streams of functional activity. The coder sees what they want to put in and what they want to get out and think that the gigantic mound of code in the middle ‘encapsulates’. It does not. Say it with me: segregate, segregate, segregate. To keep our code agile we must break out functionality in the same way that we break out the changable v/s non-changable portions of our code. What I did to help the developer was to help him see the individual pieces of functionality and help him begin to move those out into separate classes that will manage that functionality for him (I didn’t break it to him that he had just started his journey down ‘behaviorial programming’! 🙂
When you’re teaching or training or simply helping another developer, don’t show off how many technical or OO or DP terms you know. Rather help them by guiding them to the point where they can discover how best to architect their code. They’ll learn more, appreciate and respect you more and you’ll have a much better developer.
JohnMarkHowell Twitter
- @kellabyte Hey, I resemble that remark! 😉 2 months ago
- My love affair with Ubuntu might be over. Installed Win11 22H2 and it is fast and uses less resources than prev ver… twitter.com/i/web/status/1… 2 months ago
- @rrelyea My thoughts are with you and your family, Rob. 4 months ago
- RT @buhakmeh: I wrote "Using SQL Server Cursors with Entity Framework Core" (05/17/2022) by @buhakmeh #entity-framework #dotnet #sql RTs ap… 4 months ago
- RT @JeffHicks: New #Petri content from Rabia Noureen: Microsoft Partners with Canonical to Add Native .NET 6 Support to Ubuntu 22.04 https:… 5 months ago
-
Recent Posts
Archives
- August 2014
- July 2014
- January 2013
- December 2012
- November 2012
- August 2012
- July 2012
- June 2012
- May 2012
- March 2012
- February 2012
- January 2012
- December 2011
- August 2011
- June 2011
- February 2011
- January 2011
- December 2010
- October 2010
- September 2010
- July 2010
- May 2010
- December 2009
- September 2009
- August 2009
- July 2009
- March 2009
- January 2009
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- March 2008
- January 2008
- December 2007
- November 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- December 2005
- November 2005
- May 2005
Categories