This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

What to do if you are building on existing code?

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.
I was wondering how could one introduce Patterns to existing code?
I am talking about thousands of lines of code.
Furthermore, what if other developers on the team are not as keen to adapt Patterns?
Curious to know if anyone else has encountered these issues and how they overcome them.
Regards,
Angelo.
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I would like to share with you what we went through when we wanted to use Design Patterns in our project. Some of our team members were not enthusiastic about that. So we thought we should let them appreciate it by giving a talk or something. We started with the users (who are not end users, by the way). Once the users were keen on that, then our team members also started appreciating.
We have completed the project now and everyone is interested to use it in our upcoming projects.
 
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Angelo,
With your situation, you're most likely will be involved in refactoring the code. I trust your goal for introducing patterns is mainly to make the code more readable & adaptable to change. Thus any update of the existing code must not introduce any changes to its intended function - that's where XP's code testing recommendations come into play.
1) Write test cases to exercise all the software's features.
2) Make small changes and test often.
Pho
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Angelo Celeste:
Hi all.
I was wondering how could one introduce Patterns to existing code?
I am talking about thousands of lines of code.
Furthermore, what if other developers on the team are not as keen to adapt Patterns?
Curious to know if anyone else has encountered these issues and how they overcome them.
Regards,
Angelo.


What I would strongly suggest is that you buy everyone a copy of "Refactoring: Improving the Design of Existing Code" by Martin Fowler. What this does is introduce design patterns in a "stealth" way. In fact, if you follow Fowler's refactorings you will have implemented many of the GoF patterns without knowing it. If your team can see the value of refactoring by itself, it's easier to introduce the patterns as just a restatement of the same principles.

------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also recommend Fowler's refactoring book. It approaches patterns from the code point of view. As a consultant who teaches patterns, I run accross this problem all the time. Very few clients (I can count 1) in the last couple of years have been writing things from scratch. Most of the time we have existing stuff we need to modify. I have found it very valuable however to be able to create a vision of what we want done. Once you know enough patterns and can sort of think in terms of them, it is easier to see where the layers in the code _should_ have been placed. Then, when you have to make changes to the code, you can see better how to refactor it to get where you want to go.
You can also take situations where you wish a pattern had been applied and start applying it when new situations come up. For example, let's say you have a situation where 3 different algorithms are in use and a switch is used instead of a factory. When you get a fourth case, you don't necessarily need to refactor the first three, but just wrap them in one class, then add the new case in another. Have both classes implement the same interface and you're using the strategy pattern now. New cases can take advantage of it and you can fix the original three if you ever need to.
------------------
Alan Shalloway,
Look for Jim Trott and my book: Design Patterns Explained
Visit our site Net Objectives.
Visit our on-line companion to the book
 
angelo celeste
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for your input.
Recommended by two authors ("Refactoring: Improving the Design of Existing Code" by Martin Fowler) I am impressed. I guess going to the bookstore tomorrow is on the agenda.
We actually had a meeting today, we are doing a rewrite of a piece of middleware, and it seems that we are heading in the right direction.
Patterns were discussed and it seems that they are being accepted for the rewrite. We also discussed ways that we could utilize them in the existing code!
I am really looking forward to this challenge.
Thank's again,
Angelo.
reply
    Bookmark Topic Watch Topic
  • New Topic