The Artima Developer Community
Sponsored Link

Java Buzz Forum
Joshua Bloch: A conversation about design

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ben Hosking

Posts: 208
Nickname: hoskinator
Registered: Apr, 2006

Ben Hosking is Java Developer with about 5 years experience and interest in OO
Joshua Bloch: A conversation about design Posted: Jun 7, 2006 5:56 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Ben Hosking.
Original Post: Joshua Bloch: A conversation about design
Feed Title: A Funny Java Flavoured Look at the World
Feed URL: http://businesslogs.com/WebLog/RSS.xml
Feed Description: The blog looks at using Java and programming in general as it pops up in life as a Java programmer. It will have links to interesting Java articles and resources. It will also have a lot of SCJP Java 1.5 information and links as I am currently studying
Latest Java Buzz Posts
Latest Java Buzz Posts by Ben Hosking
Latest Posts From A Funny Java Flavoured Look at the World

Advertisement

I read this interesting article about API Design and reuse from Joshua Bloch being interviewed by Bill Venners.  The article is from 2002 but I think the points are still relevant today.

 

I have found that the Java developers I have worked with and including myself don't reuse much of their code.  The problem usually occurs because the code written is often tightly coupled with the project they worked on to create it.  I think Bloch makes good points stating

 

"Decomposition into subsystems is important, but as important is to have each subsystem be a well-designed, freestanding abstraction"


 

I think this is something that doesn't occur often enough.  If people split the work into small self contained modules/components then these could be reused in other projects.  I have found recently that I have been trying to make sure that my methods will have "only one reason to change" this sometimes means creating more methods but it creates methods that don't depend on too many variables or are tightly coupled with code you are currently writing.  This also means that if I want to reuse these methods/classes then it should easy. 

 

I often find that these changes happen when I am refactoring and trying to eradicate duplication.  This article puts to words what I have been thinking about and trying to do whilst writing code recently.  If you write code like this it is also a lot easier to write unit tests for.  Writing unit tests can be a good guide, if you are stuggling to write a unit test for some code then perhaps the code is doing to much.

 

I like this question

 

"Venners: You also claim in your book that thinking in terms of APIs tends to improve code quality. Could you clarify why you think that. "


I have been trying recently whilst trying to write smaller methods with one focus and then use the smaller methods in bigger methods etc.  I have been trying to think of my code as a library or code.  I have been trying to think about the code as an API, I suppose basically trying to create a self contained component which I can use again.


I don't know why I have been trying to do this more recently, I think it's because I want to be able to reuse more of the code I write and looking back at the code I have written before I can see that it's very difficult to reuse the code because it isn't really very modular and not very cohesive.  The code I have written in the past seem to try and do to many things which ends up that lots of the code is too dependant on each other and means I can't take bits out and use them in other projects.


Anyway I found the article really useful as I do most of the articles involving Mr Bloch.

 

Read: Joshua Bloch: A conversation about design

Topic: DrunkAndRetired.com: Service Bartering in Austin: Austin TimeBank Previous Topic   Next Topic Topic: Ubuntu Linux to Support Sparc Based Sun Niagara Servers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use