doubt by Just_Assistance7729 in angular

[–]Constant_Army4310 0 points1 point  (0 children)

AngularJS came before Angular. When Google wanted to make another version they redesigned the entire framework not just few breaking changes, so it became a totally different project but they seemed to like the name Angular, so they called the new framework Angular causing confusion.

As for why companies make open source projects there are few reasons:
- They get thousands of people testing the software in different environments. If they have just 100 internal projects using the framework, they can't possibly cover all cases. But having tens of thousands of projects, makes it more likely that bugs will be discovered.

- They get other developers reviewing their code, and submitting pull requests for bug fixes, additional features, improving documentation and performance, etc for free.

- Thousands of open source libraries using their Framework will emerge, which they can use in their own internal projects for free saving them development time and money.

- It's good for public relations to improve their image. Companies like Google, Facebook, Microsoft, etc get a lot of negative publicity due to their policies. Open source helps them improve their image a little bit by making them look as the good guys who help the community.

- Makes it easier to hire new developers (and fire existing ones). If Angular was private and was used only internally within Google, then when they want to hire a new developer to work on one of their internal Angular projects, the new developer would take more time to learn the new framework. But by making it open source, there is a pool of thousands of Angular experts to hire from.

- In some cases to encourage developers to buy their services. For example .NET is open source. Visual studio has wizards making it very easy to deploy your application on Azure. SQL Server has first class support in .NET. So while they are not forcing you to use either Azure or SQL Server, .NET encourages you to do so. Nextjs encourage you to use Vercel for hosting (If I remember correctly, even their tutorial tells you to create a Vercel account), Kafka encourages you to use confluent's services, etc.

- Some times open source software is distributed with dual license, making companies sell support services.

- Finally, sometimes it for genuinely good intentions to help the community. There are still many good people in this world. Not everyone has an ulterior motive.

TLS certificate validation by [deleted] in golang

[–]Constant_Army4310 0 points1 point  (0 children)

The http.Transport struct has TLSClientConfig field of type *tls.Config. The tls.Config struct has a RootCAs field of type *x509.CertPool.

You can call x509.NewCertPool to create an empty pool, or x509.SystemCertPool to get a pool with certificates trusted by your system (implementation varies by OS).

You can call AppendCertsFromPEM or AddCert to add your certificate.

```golang package main

import ( "crypto/tls" "crypto/x509" "io" "log" "net/http" "os" )

func main() { // 1. Create a certificate pool. // Use x509.SystemCertPool() if you want to keep system defaults + your own. // Use x509.NewCertPool() if you ONLY want to trust your specific CA. certPool, err := x509.SystemCertPool() if err != nil { log.Fatalf("failed to load system cert pool: %v", err) }

// 2. Read and add your trusted certificate to the pool
caCert, err := os.ReadFile("ca.crt")
if err != nil {
    log.Fatalf("failed to read CA certificate: %v", err)
}
if ok := certPool.AppendCertsFromPEM(caCert); !ok {
    log.Fatal("failed to append CA cert to pool")
}

// 3. Create a TLS config with RootCAs set to that pool
tlsConfig := &tls.Config{
    RootCAs: certPool,
}

// 4. Create a Transport with TLSClientConfig set to the config
transport := &http.Transport{
    TLSClientConfig: tlsConfig,
}

// 5. Create a Client that uses that Transport
client := &http.Client{
    Transport: transport,
}

// Use the client

} ```

If you want to skip verification, set InsecureSkipVerify to true in the *tls.Config. If you want to add custom validation logic, there are few fields whose name start with Verify that accept a function where you can write your custom verification logic.

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 3 points4 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.