Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Code Reviews

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

66%
+2 −0
Code Reviews C# MVVM Login Project

Things you might consider to improve your code: Use nameof instead of magic strings. Example: OnPropertyChanged("User"); can be replaced with OnPropertyChanged(nameof(User));. This allows for ...

posted 3y ago by Alexei‭

Answer
#1: Initial revision by user avatar Alexei‭ · 2021-01-20T07:27:32Z (about 3 years ago)
Things you might consider to improve your code:

1. Use `nameof` instead of magic strings. Example: `OnPropertyChanged("User");` can be replaced with `OnPropertyChanged(nameof(User));`. This allows for renaming to properly work.

2. Consider using on ORM such as [Entity Framework Core](https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework-core.html) instead of explicitly writing the queries. This is particularly useful for CRUD operations where EF does the tracking of changes to be persisted. 

3. Not sure, but the little image suggests that the MySql queries are placed inside the ViewModel. It is a good idea to have a clear separation between the data persistence layer and the view. You can create another project (class library?) to include all data access related functionality.

4. Consider [replacing MD5](https://security.stackexchange.com/questions/19906/is-md5-considered-insecure) with [SHA256](https://stackoverflow.com/a/34712689/2780791) or similar.