It Will Take A Lot Longer Than Estimated
- Its navie to actually think this but if a system has been in production for say five years, expecting to reproduce it in five weeks is not possible. You may be able to get 80% of the core functionality done, but the remaining 20% that was added to, iterated and stabilized over the remaining five years is what will destroy any form of schedule.
- If your estimate exceeds three months, you need to reasses what you are doing by breaking down the work, or changing plan. The bigger the estimate, the bigger the risk.
Deploy Incrementally Via CI
- If you aren't deploying to a live environment as soon as possible, any future releases are destined to be failures, troublesome or just plain difficult.
- Soft releases and feature toggles should be used to aid constant releases.
Morale Will Drop The Longer It Goes On
- Probably the biggest and most surprising realization is the drop in personal and team morale.
- If you miss a "deadline" or keep failing to ship, then morale will tank.
- While software is never complete, a rewrite has a definitive target. If this target continues to move, team morale will move too.
Users Will Probably Hate It Anyway
- Predominantly the UI, but your users will complain about change.
- Big sweeping changes often receive the most hate. A website I frequent had a major change both in visuals and the underlying technology used. While there was warning, you were left to your own to figure out where features were. This caused a great deal of frustration and negative feedback.
- Small, incremental changes allow your users to keep pace.
- Alternatively some tutorial or hint system can help reduce user pain.
Do What The Legacy System Does
- As many of the original developers will likely have moved on, no one is really sure what the legacy system does.
- Even with the source code available, it is likely going to be hard to figure out the intent, afterall that's one of the reasons for the rewrite.
- If you are not careful you will end up simply reimplementing the same legacy in a new language or framework. Always weigh up preserving existing behaviour versus introducing technical debt.
Be Cheap And Quick - Use Stubs
- When implementing the new system, don't build a thing. At least at first.
- Use stubs to build the simplest, dumbest thing you can to get feedback.
- Without fully integrating the system in an end to end manner you'll end up throwing away a great deal of code.
Feedback, Feedback, Feedback
- Early and fast feedback is essential.
- With a working end to end system gather as much as you can from any stakeholders.
- Chances are as you begin you'll naturally incur some additions, removals or modifications.
- Waiting months or longer for feedback is a guaranteed path to failure.
Thin Vertical Slices Over Fat Technology Splits
- Avoid the temptation to have a UI team, a backend team and a data team and so on.
- Splitting at technology boundaries leads to systems that do not integrate well, or worse fail to handle the required use cases.
- Your first iteration should consist of all parts of the technology stack, in the thinnest manner possible. Combine this with early feedback and the fast development speed of stubs.
Strangle Existing Legacy Code
- When rewriting in increments or by logical sections the technique of strangulation is useful.
- Instead of releasing the new code as a standalone piece, integrate the new code into the existing legacy code base.
- This may be tricky at first however over time the legacy system will form nothing but an empty shell that integrates with the new system.
- The beauty of this approach is early feedback, and a guarantee that the new system behaves as intended.
- The final step would be to replace the legacy shell with the new modern interface or frontend.
Refactor Where Possible
- Deciding to refactor or rewrite is never easy. Refactoring should be the default approach in many cases.
- Old languages or unsupported frameworks are good reasons to adopt a rewrite, but this varies case by case.
- If business agility is suffering such rewrites can be beneficial when using some of the techniques above.
Saturday, 25 June 2016
Tuesday, 14 June 2016
A single domain can grow large when applying Domain Driven Design. It can become very hard to contain a single model when using ubiquitous language to model the domain. Classic examples prevalent in many domains would be
User models. A bounded context allows you to break down a large domain into smaller, independent contexts.
In different contexts a customer may be something completely different, depending on who you ask and how you use the model. For example, take three bounded contexts within a typical domain that allows customer administration, customer notifications and general reporting.
A customer is their account id, social media accounts, email and any marketing preferences. Anything that would be required to uniquely identify a customer, and send a notification.
+ Id + Email + Marketing Preferences + Social
When reporting customers are nothing more than statistics. A unique customer ID is more than enough just for aggregation and statistic collection.
Allowing the customer to administer their account would require anything personally related to the customer to be modelled.
+ Id + First Name + Last Name + Address + Email
Despite the common elements such as Id and email, the other elements are specific to the context in which the customer is used. One of the biggest mistakes I've made by ignoring a bounded context is to see a common model and try to apply this everywhere. This leads to less code, but increases coupling. A single small change in one context can cause a rippling effect. In fact the best solution is to have a customer model per context.
The result of this approach is you will end up with at least three models using the example above. While structural duplication increases, coupling decreases. Each context can change and evolve at its own pace. This is a good thing. No business logic here is being duplicated, only the model. As each context operates in its own speciality, there should never be a case where this is problematic.
- Structural duplication outside of bounded context is not a bad thing.
- Resist the urge to use a base class for common attributes. This is especially true if you use an ORM or anything that will couple you further when these models are used.
- Ending up with multiple models per bounded context is likely going to happen, embrace it.
Tuesday, 7 June 2016
There are two common ways of writing automated tests which apply from unit to acceptance tests. These are typically known as test fixtures and Given-When-Then scenarios.
- Traditional method of writing tests.
- The common JUnit/NUnit approach. Other languages have very similar concepts.
- Single test fixture with multiple tests.
- Test fixture is usually named after the subject under test.
- Can grow large with many test cases.
- Works well with data driven tests.
- Suited to solitary tests such as integration tests where GWT syntax would be verbose or hard to include.
- Behaviour driven approach (BDD style).
- Made popular by tools such as RSpec.
- Single test fixture per behaviour.
- Test fixtures named after the functionality being tested.
- Often nested within other test fixtures.
- Smaller test fixtures but more verbose due to fixture per functionality.
- Easy to see why a test failed due to naming convention - assertion message is optional.
- Suited to sociable tests where the focus is on behaviour.
Givenforms the pre-condition of the test.
Whenperforms the action.
Thenincludes one or more related assertions.
- GWT can be difficult to name in some cases, often more thought and discussion can be required around good naming conventions.
- Can act as useful documentation on how the code is meant to function.
- No single way of writing automated tests is better.
- Favour single test fixtures for integration tests.
- The core of your tests can use GWT style.
- Mix and match where appropriate however.
- Your choice of tooling and language may influence your approach.