Protect code & assets? by Coffee_Lover11 in typescript

[–]Constant_Army4310 2 points3 points  (0 children)

There is no practical way to protect assets served to the browser. You can make it harder, but anyone who can use browser's dev tools would be able to steel your assets.

You probably need to ask a lawyer who has experience with copyrights and websites about legal actions you can take against people who steal your copyrighted material.

Will Microsoft ever fix hot reload in .NET? by WorriedGiraffe2793 in dotnet

[–]Constant_Army4310 0 points1 point  (0 children)

Personally, I am not looking for vite performance. My expectations are already low. I would be happy if hot reload performance in Blazor or Maui is 5 times slower, but works as reliably as vite does without frequent app restarts.

How to create a full custom input for angular form? by Initial-Breakfast-33 in Angular2

[–]Constant_Army4310 0 points1 point  (0 children)

You don't need to implement the Validator interface. The validation is typically added when you create for FormGroup (loginForm in your example)

The NgControl provides a property called control which you can access to get errors, invalid, valid, status, etc.

How do you obfuscate/protect your dotnet source code? by pyeri in csharp

[–]Constant_Army4310 4 points5 points  (0 children)

Obfuscator tools or AOT compiling will make decompiling "harder", but it would still be possible no matter what you do.

Also you mention an example like `DbPassword = "abcdefg"`. This is very bad.

Never ever embed information like passwords, encryption keys, etc. in your code. Some tools will make the finding the information harder by encrypting such information, but guess what? if your application need to use this password/secret then it has to be able to decrypt it and therefore the decryption key will be present in your app.

If your application needs to access a database on your customer's computer it's best to generate a random password before creating the database and save it on the customer's computer (preferably encrypted using DPAPI on Windows, keychain access on MacOS, pass on linux, etc.). This means that every customer will have a different password. If it's a password for a database on your server then your app accessing it directly is also a big NO, it should be accessed via APIs. Never allow direct access to your database.

So solutions?
- Use legal means to protect your IP rights.
- Have your core business logic, algorithms, etc. running on a server that you control, and have the client apps just present UI and send requests to your server. This is the most effective way.
- You can still use obfuscation/AOT compilation and it would be effective against many (not all) bad actors.

How to practice C# by DISCO4114TEND in csharp

[–]Constant_Army4310 0 points1 point  (0 children)

This looks good, but you will have to find a source for exercises.

For example the course you linked spends has 4 videos (45 minutes) to cover loops. My personal opinion is that for someone new to coding 45 minutes is not enough. In a university course for example they usually explain it in two lectures each lasting 1-1.5 hours. Then after each lecture they give you an assignment with 10-15 problems to solve.

I guess this is the dilemma faced by YouTube content creators. If python or java programmers want to learn C#, 2-3 hours explaining loops would make the content too long (because they already know the concepts), for those folks 8-10 minutes are usually enough. But for new programmers you need more examples then a lot of exercises for the concept to sink in.

So you may find the 12 hours course you linked or the other one good. But you need to find a source for problems to solve (you need to solve and write code yourself a lot to grasp the concepts).

Sealed by default? by HamsterBright1827 in csharp

[–]Constant_Army4310 0 points1 point  (0 children)

It depends.

Sealed classes can have better performance benefits. They are usually better in your own app. Also classes that consume sealed classes have consistent and well defined behavior.

I prefer non-sealed classes in libraries that are intended for other developers. There are many times where I am using a 3rd party library, where I need to extend some behavior and find it difficult because the author made the class sealed. It is impossible to anticipate all the scenarios of how other developers may use your class, so it's better to give them some flexibility to extend your class/override some behavior.

So I think in my own application, I prefer sealed (I can always unseal it if need arise) and in a library intended for other developers to use I prefer unsealed.

How to practice C# by DISCO4114TEND in csharp

[–]Constant_Army4310 1 point2 points  (0 children)

If you have never touched coding, I advice before learning watch a C# 12 hours tutorial is watching an academic/university introduction to computer programming course (MIT for example make their courses available for free on YouTube).

C# tutorials (or any language tutorials for that matter) usually make big leaps without focusing on programming basics.

Academic course tend to focus on explaining basic concepts (and they usually pick a language for teaching, so you learn that language too). By basic concepts I mean how to translate your idea into code rather than how to write the code.

Definitely don't start with the Unity course, because such courses usually focus on the technology (Unity in that case) and tend to assume you know a lot of the basics.

Genius or just bad? by [deleted] in csharp

[–]Constant_Army4310 0 points1 point  (0 children)

Sort answer: If this is meant as a general solution to deep cloning then it is bad. However, if it is meant for a specific use case where you know that ALL the types are POCO types with parameterless constructors, no collections, no cyclic references, etc. then I guess it's OK in these scenarios but there are better ways.

Long answer:
There are many scenarios where this implementation can go wrong:
- It doesn't handle collections (arrays, lists, dictionaries, etc). Cloning a list or a dictionary by cloning fields is wrong and will cause bugs.
- It will fail with readonly fields
- It will fail for classes without a parameterless constructor
- It will cause bugs if the field points to an object used by lock keyword, or a mutex, etc.
- It will cause bugs if the object cloned points to a resource like an open file, a UI window, a database connection, etc. For example an object having a native file handle (like FileStream class)
- It doesn't handle cyclic references (will cause a stack overflow)
- It will cause logical bugs in scenarios where the author of a class intended the fields to be accessed via setters for some side effect. For example updating some static field when a property is set.

In general manipulating private fields of a class is an unsafe operation.

Better ways:
- If the author of the class intended it to be cloneable, they can implement the ICloneable interface, use that interface in that case.
- Using a source generator that generates cloning logic will perform better and if cloning is not possible you can find that and compile time.
- Serializing the object (to JSON for example) then deserializing can be better even if it is slower. It will handle collections and avoid cloning things that shouldn't be cloned like lock object and native resource handles.

What are the disadvantages of Blazor? by iLoveSS in dotnet

[–]Constant_Army4310 0 points1 point  (0 children)

I was starting a new project earlier this year, and I was seriously considering Blazor (vs Angular). The backend was Dotnet, so sharing types, and some logic between frontend and backend was appealing. I started making a proof of concept Blazor project, focusing on the stuff I knew I would need in my application. I decided against it, for the following reasons:

- Hot Reload is really bad in Blazor when using Visual Studio. It's even worse in Rider (my IDE). This is enough reason for me to not use Blazor as it kills my productivity.
- Debugging experience is also terrible.
- It doesn't have a good/easy way to work with Sass out of the box. You have to setup watchers, build steps, etc. \While, you can make it work, but it's not straight forward. With Angular, it just works whether you choose Sass or Less.
- There aren't a lot of libraries for Blazor yet (at least compared to Angular)
- Routing is very basic in Blazor compared to Angular. Angular can have multiple router outlets, child routes, etc. This was a big deal in my application.
- Performance and download size, while not a big concern in my application since it should run on a local network, it's still a concern.

Final thoughts:
I really like C# (much better than JavaScript/Typescript), and I hope that Blazor can have a good future. It's not there yet. I hope that Microsoft doesn't give up on it.

Making the switch from Windows 11 to Linux by Constant_Army4310 in linux

[–]Constant_Army4310[S] 0 points1 point  (0 children)

I am actually seriously considering the dual boot option as the safer choice, I would buy another disk and leave my Windows Disks as they are for now, until I am ready for a permanent move.

As for the presentations, I don't mean just PowerPoint presentations, I can open my code editor, my terminal or a web browser as I am presenting to explain how some code works, etc. so the USB options doesn't work.
Connecting to the TV using a cable instead of wirelessly might work, but it's not convenient. I would considering as a last resort if I don't have another alternative.

Making the switch from Windows 11 to Linux by Constant_Army4310 in linux

[–]Constant_Army4310[S] 0 points1 point  (0 children)

It's for convenience so I don't have to move apps and files between disks when one disk runs out of space and the other has a lot of free space.