/clean-code-workshop

A module in the Bouvet Bergen developer school.

Primary LanguageC#

Clean Code Workshop

Length: ~ 3 hours

A module in the Bouvet Bergen developer school. This module is split into five parts, and the course includes hands on coding, a lecture and presentations of the code you just made.

Part 0: Plan, Goals and Motivation

Length: 10 minutes

Q: What do you associate with clean code?

Part 1: Hands On: Code Yourself a Small Algorithm

Length: 45-60 minutes

This is for you who have several years of experience and want to refresh your skills a bit, or you are a relatively new coder who want to write better code. In this part you are supposed to write a program in your desired IDE and language. If you prefer Python you can write Python. If you already know Java and want to challenge yourself and write in Kotlin, you do that. As long as you write an executable program.

This is going to be console application where you can convert numbers into roman numerals. You should follow these rules: https://www.hunter.cuny.edu/dolciani/pdf_files/brushup-materials/reading-and-writing-roman-numerals.pdf

You do not need to write clean code, it can be dirty and should only work. In part 3 you will perform the code cleaning.

If you finish before time, you should test your code thoroughly. Try to look for errors and bugs. And don't worry if you're not done, you will get another 45 minutes to write code.

Part 2: Presentation

Length: 30-45 minutes

  • Story of a time I messed up (not writing clean code)
  • Meaningful Names: Class, Functions and Variables
  • Functions and Classes: Keep Them Small! Should do one thing, explanatory names.
  • DRY KISS
  • Comments and Documentation
  • Formatting
  • Error Handling
  • TDD and Testing
  • Consistency
  • Code Smells: Argumnents, dead code, duplication, information at the wrong level of abstraction, understand the algorithm, conventions, negative conditionals, don't be arbitrary, use datatypes
  • Example of Code Transformed From Bad Code To Clean Code

Part 3: Improve Your Code

Length: 45 minutes

Use your knowledge and the piece of information you have just learned to tidy up the already working code. Maybe you found an error within the program?

Part 4:

Length: 20-30 minutes You can either choose option a) or option b).

  • a) - Joint review, everyone presents how they cleansed their code with the presented principles.

  • b) - Pair review, group up and present your solution to each other.

Part 5: Conclusion and Discussion

Length: 10 min

What have we learned from this? In pairs; list 2 things you have learned and present them to the rest of the group.