Java Lecture Notes - July 14 - Patterns, Refactoring, Testing
- Old business
- Unit Testing
- Done by developers, for independent pieces of code
- Not functional testing, which is left to quality assurance
- Makes you faster (I know, this is counterintuitive)
- Makes you more confident and makes changes easier
- Code a little, test a little
- Best to write tests before you write the related code- the tests help you see code from a client perspective and make you think about what it's really supposed to do
- xUnit framework for many languages
- JUnit
- Example
- Reading
- Refactoring
- Modifying code without changing its behavior
- Done to make code easier to understand and maintain, for yourself and others
- Another one of those things that seems like extra work, but actually makes you more productive
- Code a little, refactor a little
- Example
- Lots of automated tools exist for refactoring
- After all, refactoring doesn't change the behavior of your code, just the structure, and yet it's easy to mess up, so why not let the computer do it?
- JRefactory
- Reading
- Patterns
- Patterns aren't software, or algorithms, or design specifications.
- Patterns are solutions to common problems in software design. Think of them as "best practices"
- Design patterns are specific to software design
(there are other kinds of patterns for other areas of software, like concurrency, analysis, gui, realtime, etc)
- Patterns let you apply the distilled experience of other programmers to your project
- Patterns become part of your vocabulary, and allow you to more effectively communicate with other programmers
- Examples
- Iterator
- Decorator (see streams)
- Strategy (see refactoring example)
- QWAN
- Reading
- Assignment