Stop Coding Bad Practices

The Actual Problem

  1. validates if the provided number is valid
  2. looks for the chosen number in the board and changes it with the provided symbol
  3. Prints out the board
  4. returns true if the number is valid
  5. if the input is invalid displays ‘Already Chosen’ into the console

Object-Role Stereotypes

  • Information holder — an object designed to know certain information and provide that information to other objects.
  • Structurer — an object that maintains relationships between objects and information about those relationships.
  • Service provider — an object that performs specific work and offers services to others on demand.
  • Controller — an object designed to make decisions and control a complex task.
  • Coordinator — an object that doesn’t make many decisions but, in a rote or mechanical way, delegates work to other objects.
  • Interfacer — an object that transforms information or requests between distinct parts of a system.

Structuring The Code

Testing

Pure Functions

Conclusions

  • Test The interfacing of your objects, not the inner implementation
  • Try to write just pure functions
  • You do not have to test the puts method or the console output
  • learn and apply the SOLID design principles
  • The code is not just for the computer is for people too!!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store