Archive for the ‘engineering’ Category

A Simple and Free UML Tool

July 17, 2011

Now that I have lost my MagicDraw license, I have been looking for a free alternative to do some UML. In looking around I found a great alternative called Violet UML.

I’m a big fan of it mainly because of how simple it is to use. The usability directly attributable to how stripped down it is or at least appears to be. Honestly it looks to have all the functionality that I need, supporting the following diagrams with necessary objects.

  • use-case diagram
  • class diagram
  • activity diagram
  • sequence diagram
  • state diagram
  • object diagram

It doesn’t have a ton of functionality to generate code, create unusual diagrams or objects, or a million menu options to sort through. I completely appreciate those engineers who leverage that extra functionality, there are situations where you sometimes can’t do without it, so if that’s the case then this tool isn’t for you. Extremely good though for just creating a diagram.


The Importance of Being Testable

October 31, 2010

Designing and building for testability in software at all levels (functional and unit testing) is one of those things most people don’t get. When I first started out in software I remember getting stuck with a last minute task of creating a web client for a test team who needed to test a XML web service. At the time I cursed the task and didn’t really think there was much value in creating the test client. Now though I try and put testing hooks like that all over the place. After looking back at software systems I have designed or worked on, I have realized that one of the main things that people have cursed or praised code on is testability.

Why Testability is Important?

Every developer has their own style for design and coding and some of them are going to think anything else is basically wrong, even if it works. So trying to win people over with coding style or awesome design is a losing battle. The central concept to all good code and systems though regardless of style or design is being able to validate if it works (aka testability). The more you can isolate each part of the system into individual testable parts the easier it becomes for people to feel confident in making changes. Which is ultimately what it’s all about. If someone can come into a system they have never worked on before, make a change, and feel confident about the change, they can’t get too upset.

Designing for Testability

Testability is all about isolation. If you are creating a system with dependencies on another system you need to be able to eliminate the need for that other system for testing. There will be scenarios where you don’t want to have the dependency whether it’s during a unit test or you don’t have access to that system in certain testing environments. Solutions for this could involve the ability to configure different end points at run time and/or putting proxies in front of calls to intercept and return mock responses. The same goes for code, you need to be able to isolate units of code and make them fail or pass tests only if that code is broken. This will involve using factory patterns, dependency injection, and/or other loose coupling strategies.

All Systems Must be End User Testable

Even if your developing a service which operates over an obscure protocol with proprietary message format, there is no excuse for not having a test interface available to allow non-developers to test the functionality. In many cases this means creating a test program or test interface on a system. This may not be in the requirements however it should be. It’s left out many times because they are written in the context of an integrating system which drives testing. Unfortunately the integrating system may or may not be available in all environments and also there could be bugs in the integrating system requiring alternate testing interfaces to validate your system which should validate the need for a end user test interfaces. One of the main places you’ll find integrated systems missing is working locally as a developer. All these aspects of testing make it desirable to get end user testability in what you are developing and it will help people down the line as well.

The No Exception Business Process

September 10, 2010

One of real challenges with custom software is maintenance after the fact. There are always trade offs being made for cost over flexibility. An example that has been a thorn in my side for quite sometime now are business processes developed with no way to plan exceptional cases by a business user. I think the mistake here is idenification of what type of process you are working on. Software developers look at processes and are inclined to think “technology process” not “business process”. With a “tech process” such as rolling logs or backing up files a developer would be right to have assume no exceptional cases are necessary to be administered by a business user. But a nightly business critical process such as moving approved changes or clearing processing queues needs to able to be administered by business users otherwise there will be duplicated efforts, both a business user and a engineer will need to assist. Identifying proper administration over processes will reduce support cost and produce a system which has the necessary flexibility to support the business process.

Web Project Install Wrecks

June 11, 2010

Working in custom software on web applications for a few years now and one thing which is a continual issue is project installs. Its interesting when your developing non-packaged software, the actual install process is an after thought. Projects have sprawling parts spread across the file system, install step on a application server or web server, and some set of database tables/procedures which many custom shops decide to try to enumerate out into implementation steps. This puts great pressure on the team producing the install documentation to not forget anything and someone to faithfully reproduce the steps, which means that even with a test run it can still be error prone. I think there is a thought that because the software doesn’t ship its not worth while to create automated install code to allow someone to simply install the app and the application take care of additional steps. For simple applications it certainly maybe overkill but if your moving into multiple environments for a single release which many larger projects are going to have to do, its worth the investment.

Think Thread Safety

June 2, 2010

In multi-threaded languages such as Java issues related to thread safety can be the most difficult to debug because they depend on timing during program execution. I would guess that most programmers know about thread safety but they aren’t aware of when they need to be thinking about it. The answer is ALWAYS! Many times they just assume that the framework they are working with will take care of any thread safety concerns but thats not the case. Any time you modify code or are creating new code you need to ask yourself “do I need to be thread safe?”  So why do we get caught is the pitfall today with newer frameworks and how can you tell if your being thread safe?

Pitfall: The Singleton…

With the advent of Spring and lots of other frameworks one of the dominate design patterns is the Singleton. By default for efficiency reasons many frameworks when creating objects, create only one instance that is executed on by all threads calling the code. This means your objects need to be stateless when integrating with many frameworks. For many developers this is tough because we want to make objects with lots of state, or have existing objects with state that we want to integrate into the framework with little to no refactoring. That combined with the fact that the actual call of your method will be wrapped in multiple points of indirection in many cases and it will work when you are testing in the simplest case tricks you into thinking your code is integrating properly when you are not. A through read of documentation in almost all cases for the framework fixes the matter but the reality is most folks learn from tutorials and experience first. Don’t get me wrong thread safety has and will be a concern of great significance whether or not your using singletons, but its one of the major patterns used today making it that much more important.

Thread Safe Or Not?

Now with the pitfall identified, how can you identify what needs to be changed and where possible issues are? Without going into much more detail for some specific situations that won’t be possible and I’ll avoid getting into that amount of detail for post length sake. At least I can provide a general rule you can follow to identify if a class is thread safe and once you have determined when the calling code demands you’ll be able to identify if there is an issue…

If a class has no synchronization and accesses a variable that has state that is not appropriate to share with other executions of the class, then the class is NOT thread safe.

For this rule “variable that has state” would include any variables that can be changed by code external to your class’s methods or changed by the methods internal to the class. This rule ignores usage of execution synchronization to simplify the discussion mainly. Take a look at classes like this and make sure they are being used appropriately and not concurrently by different threads.

Not being thread safe isn’t a bad thing. But when creating or updating existing code, knowing whether you need to create something thread safe or not is the something you always need to take into consideration. If you don’t know if the code calling your code will be calling it in a thread safe fashion STOP and research the callers to determine if you need to be thread safe.

Tech Leading 101: Vision

May 15, 2010
Being a technical lead on a project is a complex position with a lot of demands. Recently I have been thinking about what separates
the good leads from the bad ones and one of the main things that keeps coming up is ‘vision’, having an understanding ahead of time of the project’s technical and non-technical aspects and having goals and ideas on how address them. When you have a great lead it seems like they have anticipated everything and things fit together. There is continuity to the code. A direct result I believe in many cases of a tech leads creating a vision for the project, communicating that to the team, and making sure everyone is working toward the vision. I want to discuss some areas of projects where tech leads commonly lack vision because tech leads get focused on the technicals they forget some important non-technical aspects which are unavoidable.

Areas Lacking Vision

  • Schedule – I know this should be the project manager right? Well yeah but a tech lead needs to anticipate what the best ordering of tasks is dependencies and what resources match best with specific tasks. Being a project where you are constantly realizing dependencies which previously weren’t thought to be there makes development painful in many cases. Yeah changing task order mid stream sometimes is unavoidable but put critical thinking into it at the being of the project and make sure tasks get started off with the possibility of the right order.
  • Task Delagation – Creating a pattern for how tasks are going to be handed off could be a tech lead’s best friend. Just saying start on the task isn’t sufficient. Envision ahead of time how your going to kick other developers off on tasks and what you don’t want to happen. This will allow you to avoid lost time on the calendar and getting pulled in too many directions at once.
  • Reviewing Code – This creeps up on far too many tech lead’s (myself included), assuming you practice having project code reviewed either internally or externally, preventing the ability to react to requested changes. Make sure to mentally anticipate tasks finishing and the who/when of code reviewing. The sooner you catch issues the better and reviews are assurance that team members are completing tasks correctly.
  • Documentation – What the right documentation that needs to come out of a project is what I’m talking about here. understanding not only what useful client documents are needed but also documents for people who will be maintaining the project in the future. More projects than not that I come on after the fact as a developer and I think “I wish I had documentation on this”.
  • Project Communication – Communication isn’t a problem for a lot of tech leads especially when everyone is base out of one office. The situation where creating a vision of how communication will play out is when you have team members in diffent locations. Relying on email just isn’t an option in most cases. Too many times communication becomes a problem because someone on your team isn’t available to communicate in real time. Work on a vision that mitigates those situations thinking about the obvious like meeting times but also the not so obvious like what tasks get assigned to who.
I’m a firm believer in working at the begining of a project to create a vision of every aspect of the project possible so you can work towards it and get the team to work toward it as well (so don’t keep it to yourself). Vision can change as things come up too so don’t chain yourself to the original vision, allow project members to challenge it and challenge it yourself. Afterwards if you feel like it needs to change then change it.

When to Repeat Yourself

April 18, 2010

One principle in software engineering is “Don’t Repeat Yourself”. It has been around for as long as I can remember and is the hallmark in many cases of good code.  Many times I think developers fundamentally get stuck in this “don’t repeat yourself” mode outside of the code because we train ourselves so much to be constantly thinking about efficiency. Because of this, it creeps into places where it shouldn’t be. And gives developers like myself an excuse to say “we don’t need that document because the information will be in another document” or “just look at the code if you need to know something”. Both are certainly good justifications in some situations, however they don’t always hold up. I want to throw out some ideas for when its OK to repeat yourself to counter balance the efficiency junkies in all of us.

Where is “Don’t Repeat Yourself” abused?

In code its rare where “Don’t repeat yourself” fails because if it didn’t work then the compiler or testers would tell you. That’s the simplicity of code but the places that I see “don’t repeat yourself” being used as an excuse to avoid additional work…

  • Developer to Developer Communication – I’ll single out us developers here but its not necessarily a unique problem. A developer likes to communicate in the most efficient way for himself. One of the main ways we do that is by trying to not have to repeat ourselves when we communicate things. For instance we’ll send out a group wide email or we’ll schedule a meeting to train everyone at once and assume everyone got the message. The problem is you need to repeat communication in many cases because people simply don’t understand (or listen) the first time.
  • Documentation – In some cases the misuse here is trying to combine documents which have similar content but need different levels of detail to cater the correct audiences. The main offense I’m thinking of though is not repeating yourself in documentation because someone can just look at the code. This applies to documentation meant for other developers mainly, especially when someone put work into in-code documentation. The issue isn’t that the source code can’t explain exactly what is happening, it’s that if you plan on having additional people work on the project it increases ramp up time eliminating any time saved previously.

Repeating Yourself = OK

There are a couple of situations which repeating yourself is probably not a bad idea…

  • Different audiences – Anytime you are preparing something for two different sets of people with different perspectives on an application/system, it’s probably a good guess that you’ll need to repeat yourself in either a different format or different level of detail.
  • Buried Information – Many times you’ll have information which is important but gets lost in a larger document or system. When this happens consider repeating it again in a place which is appropriate for the level of importance.
  • Inability to Properly Cross Reference – When you create anything which is dependent upon another piece of information and your not able to actively reference that piece of information for the user to be able to access easily, consider repeating the information. Partial information can be dangerous and leads to issues and confusion.
  • Informal Communication – This is any communication that is not made in a lasting way or requires additional context to understand. Examples of these are a design notes session, training session materials, and many emails actually as well. In this case any communication that wasn’t made in a lasting way needs to be repeated and potentially any supporting documentation may need to be rewritten.

Limited Efficiency

“Don’t Repeat Yourself” is a key concept for being efficient but there is a limit to the efficiency you can gain from it. If you find yourself breaking the guidelines to be able to not duplicate something chances are you just trading efficiency today for lost efficiency down the road. You need to be prepared to repeat yourself for the sake of efficiency of others.