I try to describe how to write well designed software application. In addition it is important to know how we want test and support our application.
There is a lot of rules for writting good/Clean code. I'll try to expand this description if you need it.
We try to develop a WPF application which could monitor specific folder and do some actions if new file will be detected. Our application will have the unit test and logging possibility. In addition we try to write system tray application.
Some themes will be described more detailed:
Why MVVM is better approach??
How to write testable application?
How to write unit test for system calls?
What is mocking?
Details here
How to use Logging?
How to handle exceptions in WPF?
The requirements for sample application was not created by me. From one side it is simple tasks but some tasks have pitfalls.
- Create a tool to monitor a specific folder for the new files.
- The tool should automatically move files into another folder.
- Files must be compessed before moving.
- Display list of the moved files in UI.
- Show date/time of each file.
- Allow delete an item from the list.
- Allow delete all.
- Export list as CSV-file.
- Implement Double-click on list item to open zip-file using associated default windows handler.
- The list should be persist between tool restarts.
- Monitored and output paths must be configurable.
- Implement menu to pause/resume monitoring.
- Log all the actions.
- Add unit tests.
- Protect tool with configurable password.
- Create system tray application.
R1 implemented as WPF application.

List of files contain additional columns as we need to know when file was moved and visualize the error state.
In addition there is the selector box for removing selected items only.
For r11 missed requirement htat after observation start must not be possible to chage the directories.
For r16 created additional system tray apllication.
For directory observation FileSystemWatcher used. From description some field settings could be misuderstanding. For sample IncludeSubdirectories mean then subdirectories content must be observed in addition. If we want to watch files only, we need to use NotifyFilter
_watcher.IncludeSubdirectories = false;
_watcher.NotifyFilter = NotifyFilters.FileName;R3 added additional troubles:
- we can't use watcher notification for immediate compession as for the big files we need a lot of time and we can miss sequentual notification. As a solution we put all notification into thread-safe queueand then process the items one by one in one thread.
- by compression start new file will be created in observed directory so we must ignore this file. As simple solution we ignore all *.zip files.
R9 implemented very easy
Process.Start(FilePath);For another requierements I have more detailed description:
R13 How to use Logging?
R14 How to use Unit test - project local tests are commented on.
R15 How to show dialog before main application?
R16 How To create System tray application?
Update I - added xUnit project with fluent assertions. See
SOLID Principles In C#
The Don’t-Repeat-Yourself (DRY) design principle in .NET
KISS — One Best Practice to Rule Them All
YAGNI design principle from Martin Fowler