Sunday, August 26, 2012

Architexa's Free Tool for Understanding Code

Hello everyone, in this post I'm going to present you a new awesome tool for understanding code through the use of Layered Diagrams, Class Diagrams and Sequence Diagrams generated right from your eclipse IDE! No need of extra software, just an eclipse plug-in. Generate your diagram as general or specific as you want, collaborate and share them through e-mail or through architexa's collaboration server and it's free for individual use!

You: Why do I need a tool to understand my own code? Why this tool if there is project/code documentation? Why do I need this tool if I have the source code and I can read it?
Me: Very often the code you work with wasn't written by you and don't tell me you remember everything  you coded 6+ months ago... Nowadays productivity is key to any company, to any developer so you can't afford spending most of your time reading and trying to understand code and because real world isn't perfect, documentation may not be synced...
You may, also, find this tool useful for rearchitecting your applications as it lets you see the big picture, collaborate and share project documentation.


Layered Diagram
Taken from
http://www.architexa.com/
See relationships between packages in a project using the Layered Diagram. This is actually a nice feature as it lets you check the relantionships not only at package level, but also at class level. You may find this useful when trying to reduce dependency between layers...low coupling? You got it!  You can then share the diagram or upload it to architexa's collaboration server.
You just need eclipse IDE and the architexa's plug-in in order to generate this diagram, right from your IDE and in a matter of seconds.





Class Diagram
Taken from
http://www.architexa.com/
Easily visualize relationships between classes and their methods using the Class Diagram. Great feature when you want to see if that pattern you want to implement fits your design or when you need to present part or the entire application to your co-workers or when you need to check on the coupling between your classes. You may generate the diagram to contain a part or the entire set of classes.  You can then share the diagram or upload it to architexa's collaboration server.
Again, you just need eclipse IDE and the architexa's plug-in in order to generate this diagram, right from your IDE and in a matter of seconds.




Sequence Diagram
Taken from
http://www.architexa.com/
Gain an understanding of code behavior and logic through the intuitive use of the Sequence Diagram. So you need to explain to your team what a method is doing? This feature got your back! Right click on a method to generate its sequence diagram. You can generate a general diagram or a fine-grained one, as you wish, include as many other classes and methods as you want. You can then share the diagram or upload it to architexa's collaboration server.
Again, you just need eclipse IDE and the architexa's plug-in in order to generate this diagram, right from your IDE and in a matter of seconds.




In order to start using Architexa's Free Tool for Understaing Code you should follow three simple steps:
  1. Register: Really easy, just your name, password, email and one or two more questions. Your username and password will be requested to activate the eclipse plug-in.
  2. Download: Start your eclipse IDE, review the instructions to download depending on your eclipse version and let the IDE install the plug-in for you.
  3. Take a Tour: Videos and documentation to get you an idea of which features will benifit you the most.
Get your plug-in from architexa's web site: http://www.architexa.com/

I already installed the plug-in on my Eclipse Helios IDE and I can tell it was a smooth process, just followed the documentation online and installed in less than 10 minutes. I then created a "Hello Architexa" application and tried some of the diagrams they offer. What I liked:
  • Easy right click on package, class or method  to access menu in order to generate diagrams.
  • General to fine-grained diagrams as you wish. Also, you can reorganize the components of the diagram.
  • Ctrl+Z behavior on diagrams.
  • Share diagrams through e-mail (as attached images) in simple steps. And the email was not detected as SPAM by gmail.
  • New menu on the Eclipse menu bar for diagrams and collaboration options and to access online documentation about the tool directly from the IDE, no need to open the Internet browser.
  • Free for individual use.

Hope you find this tool as useful as I do, but if you don't, please share your comments...

See ya!

Thursday, August 23, 2012

Head First Design Patterns Book Review

Book cover from
http://www.headfirstlabs.com
I guess every software engineer should know about design patterns, they give us a way to solve design problems based on the experience of many other software engineers who have had the same or similar challenges in OO design. To be honest, I remember studying them during my B.S., applied some of them in my projects, but after years of experience in software development, is now that I realize how useful they may be. In this post I'm going to review the book "Head First Design Patterns", written by Eric Freeman, Elisabeth Robson, Bert Bates, Kathy Sierra and published by O'Reilly.
As others "Head First" titles, this book is well written, easy and funny to read, it has a lot of graphics, jokes, examples in the book and on the web site to be downloaded... I just loved it! Click here to know why Head First books are great.

The book covers the following design patterns:
  • Observer: Subscribe to receive updates when object's state changes.
  • Decorator: Wraps an object to provide new behavior.
  • Factory: When you want to encapsulate instantiation.
  • Singleton: Ensures one and only one of a kind.
  • Command: Encapsulates a request as an object.
  • Adapter: Wraps an object and provides a different interface to it.
  • Facade: When you need to simplify the interface of a set of classes.
  • Template Method: Subclasses decide how to implement steps in an algorithm.
  • Iterator: Allows to traverse a collection without exposing its implementation.
  • Composite: When you need to treat collections of objects and individual objects uniformly.
  • State: Encapsulates state-based behaviors and uses delegation to switch between behaviors.
  • Proxy: When you need to control access to an object.
  • Some other patterns: Bridge, Prototype, Interpreter, Chain of responsibility, mediator, etc.

Each pattern is explained in detail using an application sample in what they have called "ObjectVille". They also give you examples of its use in real life and its class diagram. Each chapter has a summary at the end (they've called it "Tools for your Design Toolbox") with the most important concepts and definitions.

Many of the above patterns were discovered by the Gang of Four (GoF), who were the first ones in writing about this topic back in 1995. Since then, new patterns have been discovered (yes, they are discovered not created), this book guides you to other reading materials where you can find more design patterns, shows you how looks the formal documentation of a pattern and describes the steps you should consider if you discover new ones.

But it is not all about design patterns, the book also explains the Object Oriented Design Principles (OODP) that every software engineer must know in order to design extensible and maintainable software:
  • Encapsulate what varies
  • Favor composition over inheritance
  • Program to interfaces, not to implementations
  • Strive for loosely coupled designs between objects that interact
  • Classes should be open for extension but closed for modification
  • Depend on abstractions. Do not depend on concrete classes
  • Only talk to your friends
  • Don't call us, we'll call you
  • A class should have only one reason to change

Something really important I learned with this book is: Always use the simplest solution that meets your needs, even if it doesn't include a pattern. So don't try to fill your design with patterns all around, first try using the Object Oriented Design Principles (OODP) then, if necessary, make use of patterns.

One more thing, the book is published in a lot of formats: printed book, kindle, PDF, so you have many options to read it. I have the kindle edition and it looks pretty much the same as in PDF. The kindle edition is available only on Kindle Fire, iPad, PC and Mac (not the portable kindle device).

In future posts I'll write about these patterns and how they are applied in the Java API.


See ya!!