SmartQA Community

10 Simple Tips to Clean Code

by T Ashok @ash_thiru on Twitter

Summary
As much as testing is seen as a key activity to deliver quality, there are simple practices that can ensure that code developed is constantly cleansed. In current times where code is churned out at a rapid pace, it makes great business sense to contain the entropy continually. This article outlines ten simple tips to help produce clean code continually.


“Great quality code is not the result of intense system testing, it is result of well structured filtration of issues from the early stages. A compromised ‘unit test’ puts unnecessary strain on the QA folks who seem to be compelled to go after these issues at the expense of system test.”

Developers do not deliberately write bad code, it is just that accidents happen. Accidents happen due to a variety of reasons – unclear requirements and therefore making assumptions, just sloppy coding, brute force push of unit testing without it being simple and practical, over reliance of testing rather than prevention, not enough refactoring, not enough focus on non-functional requirements(NFR).

Here is  how I feel as a developer as a poem titled “Hug each bug”

On a quiet  night
I sat down to code
Happiness in every byte
On the keyboard, it just flowed

Sheer poetry it was
But quietly slipped in tiny flaws
Silly it was, what I found
When the code ran aground

An exception I missed
And the code really pissed
Forgot to catch the ball
The system had a mighty fall

Bugs are uninvited guests
Makes you beat your breasts
That is why you need to test
So that you deliver your best 

I say Hi to every bug
From each one I learn
Embrace with a warm hug
For perfection is what I yearn
—
If you want a lovely poster version of this, click here.

What may be some tips that I as a developer can follow to write clean code?

  1. “Never assume, ask, question”
    Requirements are never complete, it just gets refined with time. Don’t assume when something is unclear.
  2. “Think of behaviour in terms of conditions”
    Good behavior is about compliance to conditions
    ,ensure combinations are well taken care.
  3. Be friends with bug(s)”
    Do not hate bugs, for they are the ones from who teach you constantly to do better. Learn from each, so that you find it and not others.
  4. “Use smart checklists”
    While coding, be sensitive as what issues can occur. Sensitise & prevent rather than rely only on test to find issues.
  5. “Treat code as a living entity”
    Nothing is frozen. Refactor, refactor constantly to simplify. Clean code is really never done, how much you can do is simply limited by time.
  6. “Be sensitive to NFRs”
    Non-functional requirements cannot be ‘fitted’ in later, so pay attention to load, performance, usability scaling, security, maintainability etc. always.
  7. “Don’t be scared to inject bad inputs”
    Checking correctness with good inputs are fine, but it is incorrect inputs/settings that create unwanted technical debt. Get these out of way early, by ensuring robustness at early stage.
  8. “Be purposeful of issues to find via unit test”
    There are different types of issues that may be there, be clear as to what to strive to prevent, what to go after via unit test and what at higher levels of testing. Ensure clarity of what you are going after.
  9. “Strive to understand how your code will be consumed
    It is not meeting a spec, it is not working in isolation, it is about visualising who (i.e other code) will use/consume my code so it can take care of the situations in future.
  10. “Unit test is not an after thought or compliance”
    The act of unit testing is not a chore or compliance to satisfy someone, it should be natural thing that we do to ensure our code does not stray. Treat this as part of coding, not as another activity post code. Write a script while doing this or jot down stuff to perform this manually. Stay lightweight so that you can repeat this continually. After all, development should be friction-less.

About SmartQA The theme of SmartQA is to explore various dimensions of smartness to leapfrog into the new age of software development, to accomplish more with less by exploiting our intellect along with technology.  Towards this, we will strive to showcase interesting thoughts, expert industry views through high-quality content as articles, posters, videos, surveys outlined as a SmartQA Digest weekly emailer. SmartBites is soundbites from smart people”. Ideas, thoughts and views to inspire you to think differently.


12 tips to reinvent yourself in testing 

T Ashok (ash_thiru on Twitter)

Summary
The way we build systems has changed, both in terms of technology and the process. The expectations of end users/businesses have changed in terms of speed of delivery and in terms of expectations.  In this article are outlined 12 tips to morph and reinvent oneself to become a modern smart tester.


1.Become tech savvy. Know the insides.
Understand what happens behind the hood. Know what your system is composed of. Learn to think of issues resulting from integration of various technologies, of different systems that make your solution.

2.It is ‘-ities’ that is key. Go beyond functionality.
Yes, correctness of functionality is important. But in these times, it is ‘-ities’ that are key to success. Well we know for sure how usability has become mainstream. We also know ‘compatibility’ is critical especially device compatibility of mobiles/tablets. Performance, security, error recovery is  now a given. So it is necessary to become adept in evaluating ‘-ities’ too.

3.Focus on value. It is not about activities.
What matters now is not how-many, it is really how-valuable. End users are keen on the value-offering i.e. how does it help me do better, how does it ease my life..?

4.Automated test is basic hygiene now. Become comfortable with tooling.
Well it is expected that you exploit technology/tools to accelerate what you do and replace what you do. So being comfortable with tools and rapidly able to exploit other tools/languages to getting things done is expected. Tooling is no more an esoteric skill. Remember it is not about ‘big’ tools, it is about also having a a nice ‘SwissKnife’ tool set to enable you to do faster/better/smarter.

5.Be Agile. Respond quickly.
It is no more about days, it is about hours. Change your mental model to test in short sessions, change your mental model to re-test far more efficiently, change your mental model to focus on impact far sharper.

6.Test is no more just an activity. Make it a mindset.
As we morph to deliver clear code faster, it may not always be an explicit activity. It is about having a ‘test/perfection mindset’ so that we built/craft code quicker and cleaner. 

7.Go beyond our discipline. Copy from others.
Stay sharp and wide open to see how great quality/perfection happens in other disciplines.Unabashedly copy and adapt. It is necessary to be non-linear. Be inspired from lateral disciplines and humanities/social, nature, arts etc.  to evaluate, to prevent, to build better.

8.Don’t just do. Enable ‘how not to do’.
It is not just about evaluation anymore, it is about how we can prevent evaluation. Enable building robust code. Enable better sensitisation of issues early. Do more ‘what-if’ to build better code. 

9.Go beyond software metrics. Measure in business context.
It is great to use measures of testing to guide the act of testing. Given that we are in the age of speed and instant gratification, it is is very necessary to relate the software measures to business & end user context to ensure success. For example (1) it is no more just a performance metric, it is about how (say) response time affects the business(end-users) positively (2) it is not about overall coverage alone, but about what it means to the risk of the immediate releases. 

10.Constantly unlearn.
Unlearning is a skill. The ability to constantly question if what we know is relevant and drop it to make way for newer skills is paramount. 

11.Abstract well. Visualise better.
Today the act of building systems is brilliant with excellent abstractions facilitated by frameworks. The focus is on great clarity and the ability to reassemble/morph quickly, much like ‘Lego’ bricks. The same is applicable for us test folks too. Abstract well (1) the system and how it is composed (2) the issues you are going after and therefore the strategy (3) test assets to facilitate continual adjustment (4)automated suites so that you can flex it to suit the changing needs (5) test data so that it can be relevant for a longer time.

12.Get out of the well. Be able to scale across.
What we do now is no more a silo related to evaluation. It is imperative to build/tweak code, setup environments, deploy, assist in debug, help ideate features to improve value, in addition to testing. Be able to do ‘everything’ to scale across.


About SmartQA The theme of SmartQA is to explore various dimensions of smartness to leapfrog into the new age of software development, to accomplish more with less by exploiting our intellect along with technology.  Towards this, we will strive to showcase interesting thoughts, expert industry views through high-quality content as articles, posters, videos, surveys outlined as a SmartQA Digest weekly emailer. SmartBites is soundbites from smart people”. Ideas, thoughts and views to inspire you to think differently.


10 Habits to Help You Speed Up Testing

by T Ashok @ash_thiru on Twitter

Summary
In today’s age of speed, technology/ automation is seen as the key enabler for rapid QA. Yes, it is indeed, but the limiting function to speed is one’s skills. And this is where good habits come in. Here are TEN good habits for QA that can help you speed up significantly.


Habit #1  Practice… Practice… Practice..
Practice exploration. Practice looking for bugs. Practice modelling behaviour. Practice writing tersely. Practice scripting. Practice observation. Practice.. Practice.. so that you can unconsciously do, speedily and well.

Habit #2  Focus… Focus…
Focus on the who. Focus on the what. Focus on the where. 
Focus on the what-for. Focus on value. 
Relentlessly discard the noise, the unnecessary.

Habit #3 Analyse… Analyse…
Should I regress this? Should I look for this issue? 
Should I test on this environment? Should I document so much?
Should I really do? How much should I do? Can I do lesser?
Constantly analyse as to how to do less.

Habit #4 Steer… Constantly steer…
Course correct. Adjust. Revise Improvise. Adapt. Repeat.
As you do, continually revise becoming quicker and better.

Habit #5 Immerse… 
Be aware of the act now. Stay in the present. Be mindful.
Immerse yourself ‘stopping’ time, accomplishing more.
Explore immersively, centering to see everything.   

Habit #6 Sharpen…
What issues matter for who, where and why? What is the business benefit? What is the user experience? What may be the potential impact?
Stay purposeful. Sharpen the objective.  Setup the route. Stay on it.

Habit #7 Simplify… Simplify…
Too complex to understand. Break it down. To complicated to execute. Decompose.
Relentlessly simplify. Never muddle the clarity. 

Habit #8 Discard… 
Learnt that this is not working? Discard. 
Figured you were wrong? Discard.
Saw something better? Discard what you did.
Metamorphose all the time.

Habit #9 Organise… 
Setup goal. Plan. Do. Observe. Take notes. 
Distractions happen. Problems surface. Chaos threatens. 
Yes, that is natural law. Stay organised, in the mind. 
Discipline, structure smoothens disruptions, in the mind.

Habit #10 Leverage… 
See patterns and exploit it. Observe others work and improvise on it. 
See parallel in other disciplines and apply it. 
Use smart checklists.  Use tools. Reuse strategy, scenarios, scripts.


About SmartQA The theme of SmartQA is to explore various dimensions of smartness to leapfrog into the new age of software development, to accomplish more with less by exploiting our intellect along with technology.  Towards this, we will strive to showcase interesting thoughts, expert industry views through high-quality content as articles, posters, videos, surveys outlined as a SmartQA Digest weekly emailer. SmartBites is soundbites from smart people”. Ideas, thoughts and views to inspire you to think differently.


50 Tips to Smart QA

by T Ashok

SUMMARY
Here is an interesting collection of FIFTY tips that spans across many dimensions to enable one to become “Smart Tester”.


1. “Don’t do work. Prevent.”
Smartness is about thinking well, so as to not do. It is not avoiding it, but about quashing the need of it. For example, do I need to regress this? With smarter analysis of change, should I really regress this? Can I inject code to self test, so that I don’t have to test it?

2. “Do less.”
Smartness is about doing minimally. It is not because of lack of time/effort, it is about being sharply focused to not spread thin. For example what may be the minimal data sets to ascertain correctness, what may the optimised combination of environments to test on.

3. “Do just as much.”
It is kind of mix of (1) & (2). How much to do and what can be avoided. The continuous sharp sensitivity to be just right enough. Selecting just the right set for scenarios from a larger set for (say) a given specific customer.

4. “Do anything beautifully.”
Be it writing a document, or presenting a report, or test data sets, let it be beautiful. Great aesthetics nourishes the should making us do great work.

5. “Do quickly.”
Chunk tasks, get it done quickly. Don’t stretch an activity, strive to complete quickly so that you can get feedback, learn and refine and of course, get the work done faster!

6.“Detect at the earliest. Prevent if possible.”
Guess this is self explanatory!

7. “Exploit technology.”
Automate maximally, use tools for setup, compare, manage, check, monitor etc, to help you do, to help you gain better insight.

8. “Adapt, adjust, adapt, adjust..”
Be like the water that flows, not fixated, open, to constantly adjust and refine the strategy, plan, scenarios, scripts, tools, priorities, understanding..

9. “See the mirror constantly.”
Setup measures for feedback, to constantly analyse and stay on course continually.

10. “See consciously, see unconsciously too.”
Observation is a key skill for test folks, to judge, to see patterns, to connect the dots and enhance test strategy and action. 

11. “Add, delete, refine. Evolve.”
Utility of anything is never fixed, everything looses shine with time. Constantly egg yourself to evolve. For example test cases over time will stop finding issues, in certain customer environments, some flows may be never be done requiring continuous evolution.

12. “Empty yourself periodically.”
Make way for new thoughts/ideas, by discarding the ones we have periodically. Consciously discharge to recharge.

13.“Focus on outcome, enjoy the journey.”
Repetitive testing can become boring, the trick is to enjoy the journey by noticing the finer nuances that are different each time.

14.“Doing is great, but value matters.”
It is not just doing activities, but about producing great outcomes. Doing excessive testing without demonstrating high utility to end customers is sadly an exercise in futility.

15. “Be mindful, immerse yourself.”
Being in a flow allows to be very sharply observant unconsciously enabling us to deliver great work and making it enjoyable!

16. “Leverage other people work.”
Don’t do what has been done before. Leverage assets aggressively be it tools, frameworks, scripts, scenarios/cases/data, strategy/plan. Before embarking on activity check if this has been done before.

17. “Blend your left and right.”
It is not just about using the logical left brain or the creative right , it is about a harmonious combination of logical/scientific left brained thinking with the creative right that makes testing super effective and super efficient.

18. “Be rational, but trust your gut too.”
Staying engaged, being immersive results in deep unconscious learning resulting in the gut feel. Something we look for certain issues in certain situations kinds based on gut feel. Staying logical and rational is important, but don’t understand the power of gut feel.

19. “Analyse situations logically, but act on the choices.”
We analyse situations (say) ‘why did this occur’ and come up with a list of choices. It is necessary to use and on these choices, to realize the full benefit of logical thinking.

20. “Stay focused and purposeful.”
A purpose gives the power to focus,  for example looking for specific issues allows to sharpen the approach and test cases. 

21. “Focus is great, but meander too.”
Focus enables to being purposeful, but it is like a horse blinder. Some bit of meandering, observing the system at large while performing a focused test improves our overall understanding enabling us to refine to do better.

22. “Look outside, learn from other disciplines.”
The stick robot was inspired by the insect, velcro was inspired by lizard feet. Read, watch, experience things outside of our discipline to innovate.

23. “Stay curious, question, explore.”
Testing is scientific exploration, driven by curiosity and fueled by intense questioning.

24. “Decompose well, and problem solve itself!”
Well the problem may not solve itself completely, but good decomposition of a problem is very to solving it. For example clearly decomposing ‘what-to-test’ into various granular entities like screens, features, flows and ‘what-to-test-for’ into different types of issues and therefore clear set of tests ensure clarity of problem and also of the solution.

25.  “Relentlessly simplify.”
Albert Einstein said “If you can’t explain it to a six year old, you don’t understand it yourself”. So relentlessly simplify to sharpen clarity and understanding, the key ingredient to great testing.

26. “Write less, accomplish more.”
Documentation is useful history and that happens only when the present is meaningful and valuable! So think better, write just enough, focus on doing great.

27. “Sift continuously to sharpen clarity.”
It takes tremendous sifting to separate gold from rocks! To understand a system, play with it, read, explore, discuss, repeat by varying, discard what is not need, repeat until time runs out. A deep understanding of context, usage, system is central to great testing.

28. “Think like a scientist, do like an engineer, feel like an artist.”
Deep scientific thinking, pragmatic implementation and enjoying the aesthetics of doing and outcomes in a brilliant combination makes the activity enjoyable and outcomes very valuable.

29. “ Visualize in the mind’s eye.”
Seeing the system flows, the perturbation of a modification, the structure of systems in one’s mind eye clearly, the ultimate result of great understanding, makes probable issues stand out.

30. “Fly high to abstract, stoop low to see details continually.”
See the forest for the trees to gain a great systemic understanding, and also dev down to look at the individual leaves to understand the details, repeating this in an endless cycle to understand a system and context better.

31. “Keep your cup half empty.”
“Exactly,” said Master Ryutan. “You are like this cup; you are full of ideas. You come and ask for teaching, but your cup is full; I can’t put anything in. Before I can teach you, you’ll have to empty your cup.” Create space in your mind to space to absorb, to learn and understand , and therefore defer what is not needed now.

32. “ Problem solving is a mix of techniques, principles, heuristics.”
Apply techniques to solve clear problems, employ principles to chart the direction and use heuristics to guide you. There is no formula, not is everything from experience. It is a judicious combination of techniques, principle and heuristics(guidelines)

33. “Trust what you do, prove what you have done.”
It is not just about “trust me”, it is about demonstrating proof in what you have done. Justifying  test adequacy is one key application of this in our discipline.

34. “Understand the behavior outside, know how it composed inside.”
It is not ‘black’ or ‘white’. it is about knowing the external behaviour and also the internal structure in terms of architecture, data/control flows, interfaces and so on.

35. “Never forget that human uses the system.”
Testing is not a clinical examination of the system, it is being empathetic and ensure the human end user benefits from the system.

36. “See the many dots, connect them continually.”
Testing is not deterministic following a simple set pattern, it is about observing, experimenting creating and seeing dots and constantly connecting them to do better and better.

37. “Be open to different points of view without bias.”
Testing requires a very open mind, to see various points of video, engage in arguments and disagreement without bias so that we may get new ideas to ‘poke’ the system and find issues.

38. “Form opinions based on facts.”
As much as it is important to be open, formulate opinions based on pure facts so that you can anchor and explore better.

39. “Relentlessly pursue, but know when to timeout.”
Sometimes bugs vanish down the rabbit hole, sometimes systems behaves weirdly, these are not to ignored, these are opportunities to pursue relentlessly, be watchful of the large picture of business and timelines, know when to timeout.

40. “Constantly assess what you don’t know, not gloat about what you know.”
It is the gaps in knowledge that help us to become better forcing us to learn and refine and not just the knowledge that we possess.

41. “Do with pride, stay humble about outcomes.”
Pride in work comes from confidence we possess, very necessary for great testing. When test artefacts are reviewed, demonstrating confidence is key. To be able to stay that way, it is important to be humble enough so that we don’t become over confident!

42. “Prioritize continuously.”
Testing is risk reduction, and given the challenges of time, cost and quality, staying focused and continuing to do with the issues and challenges demand we constantly re-prioritize focusing on what is most relevant as of now.

43. “Stay balanced.”
Extremes of too much testing or less testing, too much reliance on tools on only on facts etc may not be very productive. It is the fine art of attempting to staying in balance that is key to great outcomes.

44. “Try to connect cause to effect constantly.”
Attempting to figure out the potential cause from observed effects enables us to refine our strategy and explore better.

45. “Pay attention to special cases, not be satisfied with common causes.”
It is the interesting one-off situations that help us to understand somethings far more deeply rather that the common occurrences that cause issues.

46. “Time is not a constraint – It is what can I do, not how much do I need.”
We all know that the clock does not stop, we can only freeze what we can deliver. Given a time target, it is about how much I can accomplish that matters in today’s world.

47.  “Listen silently, talk excitedly!”
When we listen to some one’s views silently without bias, new ideas emerge. On the same view, when we talk excitedly about our view with the other person silently listening to us, ideas refine and sharpen!

48. “Take notes copiously.”
While observing, listening, experimenting, exploring, take notes liberally to help you remember, and more importantly come with interesting ideas when you re-read it.

49. “Stimulate all senses – write, draw, colours, direction, voice.”
When you note down observations, put together a plan, jot down scenarios etc., mix it up – write words/sentences, using colours and directions (up, down, angle..), voice record too, so that you keep the right brain vibrant and stimulate the unconscious to see the unknown.

50. “Code, design, build, troubleshoot, write, read.”
It is not just testing that matters, it takes well rounded skills from the entire life cycle that ensures we deliver clean code. Design and code to build systems, troubleshoot and support, write documentation and read other people’s outfits to become a great software professional!


About SmartQA The theme of SmartQA is to explore various dimensions of smartness to leapfrog into the new age of software development, to accomplish more with less by exploiting our intellect along with technology.  Towards this, we will strive to showcase interesting thoughts, expert industry views through high quality content as articles, posters, videos, surveys outlined as a SmartQA Digest weekly emailer. SmartBites is soundbites from smart people”. Ideas, thoughts and views to inspire you to think differently.


Exploit visual thinking – Smart exploration of software 

In today’s world of Agile development, where minimal documentation and rapid evolution of features rule, understanding what may be appropriate for end users, what may be intended behaviour and what is actually present, requires not only a logical mind but a very creative mind. A smart approach to understanding the various parts, connecting to the bigger picture, and identifying missing parts in a rapid manner is the order of the day.

It is interesting that in the current technology/tool rich world, we have realised that human mind is the most powerful after all, and engaging it fully can solve the most complicated problems rapidly.  One of the key ingredients of an engaged thinker is “Thinking visually”, to clearly see the problem, solution or gaps. 

Design Thinking relies on sketching/drawing skills to imagine better ideas, figure out things, explain and give instructions. Daniel Ling(1) in his book “Completing design thinking guide for successful professionals” outlines this as one of the five mindsets – “Believe you can draw”. 

Sunni Brown(2) in her book “The Doodle revolution” states “doodling is deep thinking in disguise – a simple, accessible and dynamite tool for innovating and solving the stickiest of problems“ by enabling a shift from habitual thinking pattern to cognitive breakthroughs. 

David Sibbet(3) a world leader in graphic facilitation and visual thinking for groups in his brilliant book “Visual Meetings” outlines three tools for effective meetings to transform group productivity : (a) ‘Draw’ to communicate visually (b) ‘Sticky notes’ to record little chunks of information and create storyboard (c) ‘Idea mapping’ which are visual metaphors embedded in graphic templates and worksheets to think visually. 

Dan Roam(4) in “Show and Tell” states that the three steps to create an extraordinary presentation are (a) Tell the truth (b) Tell it with a story and (c) Tell the story with pictures. The book ‘written’ beautifully in pictures entirely is about ‘how to understand audience, build a clear storyline, create effective visuals and channel your fear into fun’. 

Jake Knapp(5) in “Sprint – How to solve big problems and test new ideas in just five days” outlines a five-day process to problem solving relies on SKETCHING on Day 2. He says that “we are asking you to sketch because we are convinced it’s the faster and easiest way to transform abstract ideas into concrete solutions. Sketching allows every person to develop those concrete ideas while working alone”. 

Not to forget my very good old friend “mind mapping”, from Tony Buzan which I have extensively used to understand, document, come with up with ideas and the plan.

It is interesting to note that visual thinking has taken centre stage now with mind mapping, sketch noting and doodling as a means to unleashing the power of the mind. 

As software QA folks, going beyond the given documentation (detailed or otherwise) is very necessary. In the current times with documentation being terse, a logical approach to exploring and covering a lot of ground rapidly and taking notes that forms the basis for a great visual summary is very necessary.  Mind maps have been very useful here and we now have other tools like SketchNote and Doodling.

These visual tools are useful not just for capturing information to aid understanding but can applied to create plans, and design scenarios to validate better. These allow us to move from the structured templated documentation to a breezy and creative way that not only allows to expand our thinking but ensures that we are terse and focused and in a flow. 

As I explore the product and ideas start to flow, visual tools are what I resort to using both software tools and good old paper to ensure that I can capture this rapidly and ensure I stay in the flow.

I use mind mapping extensively to take notes as I explore a product to understand using the tool iThoughts on my iPad along with sketches and doodles in my notebook accentuated with colour pens and PostIt.

Templates that have typically served as the backbone for test documentation are like “horse blinders”, for they provide a sharp focus in a narrow field restricting purposefully the peripheral vision enabling strict compliance. On the contrary “Fish Eye Vision” allows for a 360 degree vision to be able to see all around. Visual thinking enables this “fish eye vision”.

“Software testing is a funny business where one has to be clairvoyant to see the unknown, to perceive what is missing and also assess comprehensively what is present ‘guaranteeing’ that nothing is amiss.”

As much as tools and technology helps us to perform tests far better,  “Smart understanding and documentation” based on visual thinking tools can be very useful in today’s rapid product development cycle.

Testing is scientific exploration and the first step to do this smartly this is
“Exploit visual thinking – Smart exploration of software”.


References
(1) Daniel Ling “Completing design thinking guide for successful professionals”, CreateSpace Independent Publishing Platform, 2015.
(2) Sunni Brown, “The Doodle Revolution: Unlock the Power to Think Differently“, Portfolio, 2014.
(3) David Sibbet, “Visual Meetings: How Graphics, Sticky Notes and Idea Mapping Can Transform Group Productivity”, Wiley India Private Limited, 2012.
(4) Dan Roam, “Show and Tell – How everybody can make extraordinary presentations” Penguin, 2014.

(5) Jake Knapp, “Sprint – How to solve big problems and test new ideas in just five days”, Bantam Press, 2016.