All posts tagged Java

Ever had to do copy/clone methods in large objects?

Doing it by hand takes a long time, it’s a nightmare to maintain and can lead to some serious bugs.
You could always use some kind of serialization like Java Object Serialization java.io.ObjectInputStream and java.io.ObjectOutputStream, to do it.

But there is and easier way, you can now use Trimm to automatically create a copy method in all your pojos, just use dk.tigerteam.trimm.mdsd.java.generator.extension.CopyMethodEventListener in your yaml configuration like:

# Extensions (note these listeners can also be groovy scripts containing a single class implement the GeneratorEventListener interface (or
# which extend specializations thereof) 
eventListeners:
    - listener: dk.tigerteam.trimm.mdsd.java.generator.extension.CopyMethodEventListener
    - listener: dk.tigerteam.trimm.mdsd.java.generator.extension.SerialVersionUIDGeneratorListener
    - listener: dk.tigerteam.trimm.mdsd.java.generator.extension.PropertySugarMethodsEventListener
    - listener: dk.tigerteam.trimm.mdsd.java.generator.extension.ToStringListener
    - listener: dk.tigerteam.trimm.mdsd.java.generator.extension.HashCodeAndEqualsListener

Read more

Generating code from UML can be very useful, although the usefulness of the result depends on what type of UML diagrams you use.

We’ve been part of several large projects where we used UML class diagrams to model the domain model, according to the DDD principles. Domain models (being OO persistable class models or Web service model) focus on structural patterns, i.e. how the different constructs (like entities, values objects, aggregate, etc.) relate to each other. For structural models we prefer UML class diagrams as we feel the convey information in a much better way than pure textual DSLs.

Visualization of relationships provides a better overview and is a good platform for communication.

Read more