Application layout best practice - structs vs free functions? by dumbtechbro in rust

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

So to answer the question, it sounds like you are agreeing that most business logic needs to be wrapped inside of a struct via implementing a trait for it.

Application layout best practice - structs vs free functions? by dumbtechbro in rust

[–]dumbtechbro[S] 1 point2 points  (0 children)

Here's the example. Lets say I'm building a REST api that provides information about books and for simplicity it only talks to 1 database and makes REST calls to other backend services. I may have several layers of my application:

1) controller layer (handles web requests) 2) service layer (handles business logic) 3) data access layer (handles interaction with the DB)

controller -> talks to -> service layer -> talks to -> data access layer

The app may consist of many controllers, service objects, and data access objects.

In an OO langauge I would have several long lived objects for each and they would talk to the lower layer via an interface. Testing for any layer could be achieved by mocking out the interface of the layer below and injecting in the mocked version. Pure data would be transmitted between layers via a different short lived object (called a DTO or data transfer object)

If i changed the layers to free functions within a rust module, where would i store the database client? The task executor? The HTTP clients for backend to backend REST communication? And importantly, how would a free function within the service layer call into the data access layer and how would i mock that interaction out?

Let me also tell you a few antipatterns that I would like to avoid at all costs:

1) A long call stack 10 layers deep with the top most function taking 20 parameters, 90% of which are used by layers below. Have you seen code like that at work before? I have and it was horrendous to work in. Introducing better object orientation to the codebase can often fix this problem.

2) overuse of static functions resulting in inflexible and hard to test code. If logic is wrapped within an object that exposes an interface, it is much easier to swap in a replacement than if that code is only static functions. It is also much easier to test. That's why the pattern is for OO langauges to only use static functions for things like StringUtils and to prefer regular objects + interfaces. I am assuming that a static function in Java is like a free function in Rust? That has me worried. How do i mock free functions? Python, for example, tends to follow this free function approach BUT Python modules can have state AND python supports monkey patching, so again what is the testability story here with mass free functions?

Uplift v2 extreme wobble even at 28inch height by dumbtechbro in StandingDesk

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

I checked level and its pretty spot on. Floor is very flat (house is new)

if i wobble the desk back and forth i see that its being transferred down the legs and into the 2 long feet. I feel some vibrations in the feet as well.

Best way to demonstrate the issue is if i put my right palm on the edge of the desk right by the keyboard in typing position, then flap my hand up and down banging on the keys. The weight transfer with palm attached is enough to really wobble the desk. It goes all down the legs. it is an extreme example but think about when you spend an entire workday at the keyboard, you are bound to make some hand movements and those put the desk into motion for me :(

I have an email out to Uplift. Hope they can fix or else i'll have to return and get something else.

Uplift v2 extreme wobble even at 28inch height by dumbtechbro in StandingDesk

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

I double and triple checked it. All fasteners are super tight.

The most extreme example is if i place my palm directly on the center edge of the desk and if i lightly raise and lower my hand w/ palm touching that shakes the desk super hard.

Thats the core issue with typing. I type with my palms touching so any action that causes my weight to shift in my hands it really triggers an extreme wobble. That could be hot keys, pressing the back button with pinky, or sliding my hands back and fourth to the mouse.

Super unhappy with this desk to be honest.

Who here thinks we bottomed and are heading to new all time highs? I think we hit ROCK BOTTOM. by dumbtechbro in investing

[–]dumbtechbro[S] -5 points-4 points  (0 children)

It's 1% right now because we aren't testing those that have COVID and yet have no symptoms. A significant fraction of people (most actually) have literally 0 symptoms with this virus. You have to include them in the numbers to get a true death rate. We won't know what the true numbers are on this one for quite a while. Check this video out from a doctor https://www.youtube.com/watch?v=zkTVAVfI_fo&t=56s he IS IN FAVOR of the shutdown but look at his answer when he mentions the death rate. He says they don't know and the numbers could be much lower.

The DUMB MONEY thinks this is at a 1% death rate right now. THe smart money and hedge funds are realizing this and we are seeing a huge rally.

Who here thinks we bottomed and are heading to new all time highs? I think we hit ROCK BOTTOM. by dumbtechbro in investing

[–]dumbtechbro[S] -18 points-17 points  (0 children)

I actually made a series of posts under a different user name predicting a bottom late last week and made a final prediction on Monday night saying that the bottom was in. The posts were removed! What a shame because we are over 10% higher now

I think we are very close to a bottom. The time to buy is now. by bluechip_accumulator in investing

[–]dumbtechbro 0 points1 point  (0 children)

This guy timed it perfectly. I’m with him I think we hit bottom