• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A sample of template class code realization

 
Ranch Hand
Posts: 89
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Could someone provide a source code in Java for the class diagram attached below? This class diagram was borrowed from the book "UML Distilled" by Martin Fauler, p. 82. The book itself does not provide any source code for an entire diagram, only for a template class.
UML_class_diagram_template.png
[Thumbnail for UML_class_diagram_template.png]
 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sergey Zhylinsky wrote:... Martin Fauler ...


I'm not sure Martin Fowler will thank you for that.

Unfortunately you are unlikely to find anyone here who will just hand over the code for you (NotACodeMill <-- click). However, if you make an attempt at implementing this pattern yourself and come back with any specific problems you encounter then I'm sure you will be very successful with finding some help.
 
Sergei Zhylinski
Ranch Hand
Posts: 89
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. I do have some assumptions. In our case, "EmployeeSet" is not marked as a template subclass, therefore "Employee" is a type but not a type parameter. The code is as follows:



If you suggest copyright infringement, I will edit my message.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sergey Zhylinsky wrote:If you suggest copyright infringement, I will edit my message.


I think Tim was only suggesting that Martin would appreciate getting the spelling of his name right. It's "Fowler", not "Fauler" as you wrote in your original post.

The Java Collections library already has interface Set genericized, so you don't need to define a class Set<T> like that. All you have to do is declare something like this:

I see no reason to define an EmployeeSet class just so you can conform to the diagram down to each little detail.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic