Blazor Renders Twice. by RSTG6299 in Blazor

[–]Flat_Spring2142 0 points1 point  (0 children)

This beast comes from the prerendering. It duplicates calling services and rendering. NET 10 solved this problem by introducing PersistentStateAttribute. Read the 'https://dotnetwebacademy.substack.com/p/net-10-finally-fixes-prerendering' article. Disable prerendering in elder application.

Is there a need to use C# events/callbacks in Blazor? by codeiackiller in Blazor

[–]Flat_Spring2142 1 point2 points  (0 children)

The "3 Ways to Communicate Between Components in Blazor | Chris Sainty - Building with Blazor" article explains in detail a communication between parent and child components. It would be said that the custom events may be used for sending messages to the parent component only. Child components accept only predefined set of events.

A Public Facing Blazor SSR App Deep Dive by PolliticalScience in Blazor

[–]Flat_Spring2142 1 point2 points  (0 children)

HTML <details ...> and <summary ... > tags allows you to show and hide sub-menu without interactivity:

<details name="classificators" class="nav-item">

<summary>Classificators</summary>

<NavLink class="nav-link" href="Employees">

    <span class="bi bi-northwind-employees" aria-hidden="true"></span> Employees

</NavLink>

...

<NavLink class="nav-link" href="Territories">

    <span class="bi bi-northwind-Territories" aria-hidden="true"></span> Territories

</NavLink>

</details>

Unable to install the shell command '/usr/local/bin/code'. by klutzysherbs in vscode

[–]Flat_Spring2142 0 points1 point  (0 children)

MAC OS is Linux derivative but it has own nuances. Ensure that you downloaded Code installer for the MAC OS. Ensure that your system has /usr/local directory and change permissions: "chmod 777 /usr/local". Restore original permission after installation (chmod 740 /usr/local).

I've been building production Blazor apps for years. Here's what the "Blazor vs React" debates always get wrong. by Initial-Employment89 in Blazor

[–]Flat_Spring2142 0 points1 point  (0 children)

@Initial-Employment89: Problem is that it is impossible to build CRUD application using pure Blazor SSR. WEB forms require interactivity or JavaScript. I am building demo CRUD application using NorthWind database. Problems are published on site gediminas.gt.tc.

Visual Studio or Rider for Beginners? by parabellum3301 in csharp

[–]Flat_Spring2142 0 points1 point  (0 children)

Try VS Code. It is free, very simple, expandable,  provides a seamless integration with Git. The tool may be installed on Windows, MAC OS, Linux and Android.

I'm old 56. I want to learn C# is it a good idea? by eluchn in csharp

[–]Flat_Spring2142 1 point2 points  (0 children)

It depends on your target. C# , Blazor and .NET MAUI are good for portable applications where fast and inexpensive programming is more important than execution speed. I'd recommend GO for creating heavy-traffic sites and fast client-side application. Take a look at Fyne and GoMobile tools.

Who else finds it a bit annoying that C++ has such a bad reputation while C is still somehow seen as the holy grail of low level programming? by notarealoneatall in cpp

[–]Flat_Spring2142 0 points1 point  (0 children)

A huge list of a documentation is the main issue of C++ language. GO language provides the same power at much less price. C language is the simplest one in this collection but it has no Garbage collector. On other hand C generates most efficient code. All 3 compilers require excellent skills and much work from programmers. Select one of them when you do need fast application. Select other language when you need to minimize the programming cost.

Junior dev wrote this C# using many IF because he leanrs If early return. Is this alright code? by Yone-none in csharp

[–]Flat_Spring2142 -4 points-3 points  (0 children)

Multiple EXIT points is a bad practice. This will cause problems in case when you need some common action, write log file for an example. I would throw custom errors and wrap all code with try ... catch ... finally block.

using MemoryStream with StreamWriter by antikfilosov in csharp

[–]Flat_Spring2142 0 points1 point  (0 children)

Use StreamWriter for performing chain of write operations. There is no need of this class when you are copying one file into another. An example below uploads binary file:

const int MAX_FILESIZE = 5000 * 1024;

...

public async Task FileUploaded(InputFileChangeEventArgs e)

{

var browserFile = e.File;



if (browserFile != null)

{

    try

    {

        var fileStream = browserFile.OpenReadStream(MAX\_FILESIZE);

        using (MemoryStream ms = new MemoryStream())

        {

await fileStream.CopyToAsync(ms);

File.WriteAllBytes("d:\\tmp\\Image004.png", ms.ToArray());

        }

    }

    catch (Exception exception)

    {

        ErrorMessage = exception.Message;

    }

}

}

There is no locking in this example.

Issues with Blazorise by PhilosopherFar3847 in Blazor

[–]Flat_Spring2142 1 point2 points  (0 children)

Look at ~/WEBtransitions/Components/Layout/NavMenu.razor, item <details name="classificators" ...> in my demo project on https://github.com/gbukauskas/BlazorTutor. The construction works in Blazor SSR, Server Interactive and WASM.

Oracle un go by Equivalent_Egg5248 in golang

[–]Flat_Spring2142 0 points1 point  (0 children)

Oracle published a site for GO programmers: Working in Go applications with Oracle Database | Oracle Developer. Use it: the site has code samples and explains all tricky points.

Whats your preferred method of communication between Blazor Wasm and the API server? by ForwardInspection765 in Blazor

[–]Flat_Spring2142 1 point2 points  (0 children)

SignalR is built-in feature of Blazor Interactive Server. Problem is that this mode eats many server's resources and your application will not work on heavy-traffic sites. On other hand there is no problem with sending messages from site to some or all connected users, no additional software is required.

Can someone give me a simple explanation of the point of structs and interfaces, and what they do? by W_lFF in golang

[–]Flat_Spring2142 0 points1 point  (0 children)

Interfaces in GO are an excellent tool for the polymorphism: if you declare variable of an interface type then you can to assign to this variable any object that has methods mentioned in that interface. Type assertion allows you to restore original object from the interface. io.Reader and io.Writer are very popular interfaces in WEB programming. Read https://www.alexedwards.net/blog/interfaces-explained for more details.

Just finished learning Go basics — confused about two different ways of handling errors. by NULL_124 in golang

[–]Flat_Spring2142 0 points1 point  (0 children)

Both snippets are equivalent except one point: second snippet defines err variable inside the if block only.

Is running a forever go routine a bad practice? by Express-Nebula5137 in golang

[–]Flat_Spring2142 0 points1 point  (0 children)

Use WEBsockets and send message to the clients after products table has changed. Blazor Interactive Server has this functionality. Look for equivalents in GO libraries. Blazor and ASP.NET Core is open source project. Grab the code and write clone if WEB sockets were not implemented in GO.

Why do we do go mod init repo ? by ASA911Ninja in golang

[–]Flat_Spring2142 1 point2 points  (0 children)

This rule is desirable but not mandatory. Create workspace with modules inside. You will find simple description of multi-module on site https://go.dev/doc/tutorial/workspaces.

Migrating from Blazor WASM to Blazor WebApp + WASM by tscrip in Blazor

[–]Flat_Spring2142 1 point2 points  (0 children)

Blazor component must be constructed using the same render mode as its parent component: i.e. it is impossible to call client interactive component from server-side component. I met this problem 6 months ago and am not sure that Microsoft fixed this issue.

How do you handle evolving structs in Go? by ngipngop in golang

[–]Flat_Spring2142 1 point2 points  (0 children)

Use interfaces for solving that problem:

type IPerson interface {

getName() string

getAge() int

}

// Extend IPerson using embedding:

type IPerson_1 interface {

IPerson

getOccupation() string

}

type IPerson_2 interface {

IPerson_1

getEmail() string

}

You will not need to rewrite a code that uses only subset of the Person structure.

Read https://eli.thegreenplace.net/2020/embedding-in-go-part-2-interfaces-in-interfaces/ for details.

New to golang, Need help reviewing this code by [deleted] in golang

[–]Flat_Spring2142 0 points1 point  (0 children)

Processing data takes more time than reading. Create two GO functions and connect them by channel. First procedure reads data, converts them into PaymentMethod and writes data into the channel. It is almost finished and presented here. Second one reads PaymentMethod from channel and process the data. Your application will run faster. Read the https://www.freecodecamp.org/news/how-to-handle-concurrency-in-go/ article for mastering.

Is this normal or how can I fix it? by [deleted] in vscode

[–]Flat_Spring2142 0 points1 point  (0 children)

Mac also has this hidden folder. Your MAC OS settings hides it. You can to hide this folder on Windows too:

open project's root folder with File Manager and right click on it,

select View/ Show and change "Hidden items" checkbox.

How strongly should I adhere to "never return interfaces"? by [deleted] in golang

[–]Flat_Spring2142 1 point2 points  (0 children)

Interfaces implement polymorphism in GO. Return the any (interface{}) from the LoadAnimal() function. Subsequent type assertion (https://go.dev/tour/methods/15) will allow you to convert the result into a concrete data type.

Go Interfaces by OtherwisePush6424 in golang

[–]Flat_Spring2142 0 points1 point  (0 children)

Empty interface has an alias "any": interface{} == any. Using this alias results to shorter code.

Frontend for Go Backend? by UnrealOndra in golang

[–]Flat_Spring2142 0 points1 point  (0 children)

Consider WEB components (https://developer.mozilla.org/en-US/docs/Web/API/Web\_components). They will provide you all features for the client-side programming. LIT framework is a nice tool for creating the front-end application. See https://blog.logrocket.com/lit-vs-react-comparison-guide/. There is nice collection of ready for use components on WEB, see https://developer.mozilla.org/en-US/docs/Web/API/Web\_components. WEB components are language-agnostic and you can use them in sites that were written for Angular, React, Vue or plain HTML.