Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Carey Brown
  • Frits Walraven

Which design pattern improves software testabilty HELP...

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please some expert helps which design pattern improves testabiliyy and can anyone give example.. need for school project
Saloon Keeper
Posts: 11882
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

All good design patterns improve testability. It's easier to ask which anti-patterns reduce testability.

Here's a good guideline though: Never use static variables for anything other than constant values. A constant value is either a primitive or an immutable object, and the static field must be final.

Also, don't use constructors for anything other than initializing fields. Don't use them for complex logic and never spawn threads from constructors.
Posts: 15519
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you explore the subject of testing enough, you'll eventually come across the advice to avoid static methods and variables. I'll explain more about static variables and let you look into static methods yourself—there are plenty articles readily searchable on the topic.

Static non-final variables present a problem for testing in that they hold globally (to whatever degree their declared visibility allows, that is) accessible data. This is problematic when you need tests to be independent of each other (The "I" in the FIRST acronym for tests: Fast, Independent/Isolated, Repeatable, Self-verifying, and Timely). Global state messes up Independence by potentially making one operation dependent on the result of other operations performed before it. Immutability, of course, eliminates that problem, hence the advice to make static variables final so that their values won't ever change.
Their achilles heel is the noogie! Give them noogies tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic