Welcome back to the The Globe In My BucketList Application (TGIMBA) Windows Presentation Foundation (WPF) client creation. This blog post will be short since the implementation builds on the previous blog entry work.
- I ended up stretching the add/edit view on the main window. There may be a better way to this, but with many things in software, this is good enough for now. If this client gets used, I will explore better options with a refactor.
- I also had to figure out a good way to pass the selected bucket list item to the add/edit view. I opted to pass it into SetCurrentPanel() on the main window so I could pass it in a set property. I broke the AddEdit enumeration value into Add and Edit so I could set the same control to different functionality based on need. This is also set in SetCurrentPanel() on the main window.
- I added a FlattenBucketListItemArray() method to the add/edit view model so both the add and edit routes of modifying the database could share the same code. On a personal note, this is one of the biggest issues I see in other code bases I work on. Duplicate copies in the same code. For me, Don’t Repeat Yourself (DRY) is one of the most important software creation principals because it cuts down on spaghetti code and makes things more understandable and most importantly, maintainable. I really strive to keep my methods short and in the right place depending on their use.
- I also added an extra array element on the bucket list item string for the user name. When I originally created TGIMBA a few years ago, I thought about going with a domain object. But sharing it with the JQuery front end was not as easy as I thought. This is why I used a string array. I am extending that use here because of time. If this client gets use, I will replace the string inside the WPF client with a domain object and change it to a string array for transmission via the Application Program Interface (API) back end.
To see in action:
- Follow the previous instructions to login and go to the bucket list view (or search results view), click on a bucket list item and the edit view will open.
- Make a change and click ‘Submit’.
- When you are back on the bucket list view, review your selected item and see the update.
The next post will be the final in this series and I will create an API client so the WPF client can be installed on a machine and not rely on the copy of the API interface code I am using now.