nesfit / ics Goto Github PK
View Code? Open in Web Editor NEWLectures and computer labs storage for ICS course at FIT BUT.
License: GNU General Public License v3.0
Lectures and computer labs storage for ICS course at FIT BUT.
License: GNU General Public License v3.0
Let's say we want to extend CookBook
with ingredient types and we want our user to input that ingredient type.
public record IngredientEntity : IEntity {
public required string Name { get; set; }
public required string Description { get; set; }
// Add this
public required IngridientTypeEntity Type { get; set; }
public string? ImageUrl { get; set; }
public required Guid Id { get; set; }
}
However, current implementation of IModelMapper
and ModelMapperBase
won't allow this kind of implementation:
public interface IModelMapper<TEntity, out TListModel, TDetailModel>;
So, in any case we are required to make a model even for the simplest of things that could just be solved with a list, text box and two buttons.
One of the workarounds would be creating dummy classes that just won't be used and changing ModelMapperBase.MapToEntity
function signature to make it virtual and adding an overload that would allow mapping from TListModel
. Or just using TListModel
for TDetailModel
.
Was this intentional or did anyone just not consider the possibility of using something other than enum/string
for this kind of problem?
The name of the test suggests that it is not supposed to throw any exceptions. However, you then assert that it does.
Link to test:
For a long time now, it was preferable to use int.Parse(string)
over Convert.ToInt32(string)
. If you look at the implementation of ToInt32, you can see that it internally calls int.Parse(string)
, BUT returns 0
when input is null
. This behaviour is rarely desirable. Even better than Parse
is TryParse
, since it is cleaner and performs better than handling exceptions with try
catch
. Parse
is of course better when it comes to writing a simple code snippet for a lecture.
In modern .NET (version 7+) there is IParsable<TSelf>
interface that reinforces the suggested pattern even further.
My suggested changes are to reflect these facts in lecture notes (and in related code examples).
The only relevant code example I could find with VS search was in CodeDemonstrations.cs
:
Console.WriteLine("Waiting for input (number)...");
int input = Convert.ToInt32(Console.ReadLine());
Console.WriteLine($"Input: {input}");
So that's not too bad, but the lack of it in lecture notes is worse.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.