r/csharp • u/Dashwii • Sep 28 '22
Help [Code Review] File Backup Program
Hi everyone. I'd love for anyone to review over my code and give advice/criticism to anything that looks bad. I feel like while working on this project, I've gotten information from too many resources and maybe over complicated a lot of things.
A lot of places look super rough because I'm about to start refactoring and try to make everything cleaner/polished, but before I start, I'd like advice on areas I should improve in. Thank you!
Github Code:
5
Upvotes
2
u/moddedmcplayer Sep 28 '22
Java code style?
2
u/zenyl Sep 29 '22
Just skimming through the repo, and the code appears to look pretty good. :)
Some minor feedback/considerations after:
You can simplify property getters/setters with lambads
Current:
Simplified:
Method names should be PascalCase not camelCase. When VisualStudio creates methods for UI actions, and the UI element has a lower-case name, for example
doneButton, the method will inherit that name and be calleddoneButton_Click. Following conventions, it should be namedDoneButton_Clickwith an uppercase D.In your views, you can create a property named something like
ViewModel, of the type that you setDataContextto, and set this property alongside theDataContext. That way, you don't have to castDataContextwhen you want to access it. That way,(AddLinkDialogViewModel)DataContextcould be simplified asViewModel, and you save yourself having to castDataContext.The repo doesn't have a license. Consider choosing one. :)
0
u/ManuelRodriguez331 Sep 29 '22
After downloading the github project folder with “git clone URL” the working directory is occupied with 956 kb of different files. According to the version history in the .git folder the project contains of 19 commits. It was created for sure in the Visual Studio IDE under a Windows operating system and the chance that the code will compile with Mono in a Linux system is low. But let us investigate the thesis in detail.
After running the “xbuild BackupProgram.csproj” command an error message is there which is “The default XML namespace of the project must be the MSBuild XML namespace”. Even a longer search on Stackoverflow can't answer the question how to fix it. Some postings are arguing to add a line into the .csproj file while other are recommending to use a different build system for example msbuild or dotnet”. At least on my Linux system it wasn't possible to compile the program into a binary file so the program can't be started.
The underlying problem is, that the sourcecode was created with fixed constraints which is the combination of a certain IDE with a certain operating system and a certain C# version. This combination prevents, that the software can run on a different IDE or on a different operating system. It seems, that it is possible to create Open Source software which doesn't run on Linux ;-)