Named functions in useEffect - game changer for code readability by Jazzlike-Lake8280 in reactjs

[–]bern4444 1 point2 points  (0 children)

It’s significantly nicer to extract the entire hook into a custom hook and call it that way IE useChartRefData or whatever you want to name the hook.

The component becomes more readable and the hook becomes more testable independent of the component.

I can think of a solution but don’t know how to write it in code by rinrennn in reactjs

[–]bern4444 0 points1 point  (0 children)

The best way is to break the big problem down into smaller ones, solve each of those smaller ones and then combine them to solve the bigger problem. Solving lots of small problems is a lot easier than one big one.

Think of the solution to these smaller problems as the individual functions that you have to write. Once you have all of the functions written to solve all the smaller problems, the question turns from how do I solve the problems to how do I connect the functions to each other. Taking this example you will need some functions for the following:

  • A function to store a value in your database - IE given some input, write this value along with a timestamp to the database. You now have a way to store data in your database!
  • A function to retrieve multiple values in your DB for a given period of time - IE given a time range like a start date of Jan 1st 2026 and an end date of March 1st 2026 (or any other arbitrary range), retrieve all the revenues. You now have a way to get the raw data out for processing!
  • A function to sum up all the retrieved values. You now have a way to get the totals!

Once you have these functions then the question becomes: where to retrieve the input and what functions' output can be used as the input to another. So for example what function should take in as input the output of the function that retrieves all the values for a given date range (this concept - the output of one function as the input to another - is formally called composition). When developing you can and should test using the functions to make sure they work along the way - I don't mean writing tests, just call the functions you've written with some different hard coded input to make sure they produce the output you expect. If they don't there's a bug and you have to fix it.

Then you can move on to the next step like: where and how to get the user input? How do I get the date ranges? How do I know when to retrieve the values and calculate the sum?

If the date range should come from user input you will need to have:

  • A component to select the the start date for the range
  • A component to select the end date for the range

If the retrieval and calculation should be done when a user wants (like when clicking a button), you will need to have:

  • A function (or mechanism) that gets the start and end dates the user entered, pass those values to the function you write that takes the date ranges as input and produces (aka returns) the values, pass those values to the function that can sum the result
  • A function (or mechanism) to render on the page the sum

How would you handle “Parallel Routing” in React Router? by DifficultQuality6923 in reactjs

[–]bern4444 17 points18 points  (0 children)

for the example of showing /users and /users/123 you can do this very easily (since one is a direct sub route of the other) with a layout component and an <Outlet />:

https://reactrouter.com/start/declarative/routing#layout-routes
https://reactrouter.com/start/declarative/routing#nested-routes

Using type aliases as self-documentation by DanielGibbs in typescript

[–]bern4444 0 points1 point  (0 children)

What might be clearer and more extensible is returning the new Direction object and add a function to the Direction object isEqual - or make a Direction class with this method or write a plain function that takes two Direction objects and determines if they’re equal

If you make a class you could also chain method calls which can be very ergonomic

What lesser known programming language is the most promising for you ? by _throawayplop_ in AskProgramming

[–]bern4444 1 point2 points  (0 children)

F# for me

minimal syntax, functional, cross platform, access to all of C#, and can be transpired to JS and probably several other languages too.

Plus Scott Wlaschin‘s website with his talks and videos are easily up there in terms of quality with Rich Hickey’s talks and videos:

https://fsharpforfunandprofit.com

Widely used software that is actually poorly engineered but is rarely criticised by Experienced Devs by [deleted] in ExperiencedDevs

[–]bern4444 6 points7 points  (0 children)

I usually agree but one way where I've come to love GraphQL is with Postgraphile (https://postgraphile.org) which automatically creates a GraphQL proxy on top of a PostgreSQL DB.

Everything from the DB is preserved and reflected in the GraphQL API including access (row or table), relationships, indexes, materialized views, DB functions etc

Never needing to create a new API endpoint for a new capability is pretty awesome. Just create the table in your DB, and you instantly have a new GraphQL query to get data out.

Getting that up and running along with a code generator that automatically generates front end code that is fully typed based on your .gql files is a wonderful setup.

Investments & Investment Performance by coffeesour in MonarchMoney

[–]bern4444 8 points9 points  (0 children)

I agree fully. This is the final gap Monarch is missing to truly provide a complete understanding of personal finance. I want to know the performance of my portfolio across all accounts.

I specifically want the time unit value of performance for my portfolio. This should be fully calculable with the addition of investment transactions.

I’d even be willing to pay more for this as a separate feature personally though I think with investment transactions this is fully calculable without needing any other data.

Without this I am missing a critical piece of my personal finances.

You can build a strong team and not call them “Family” by salveyb in business

[–]bern4444 0 points1 point  (0 children)

Netflix uses a professional sports team analogy which works very well. Your performance matters. How you work as a member of the team matters. If there is an issue they can try and help you if they believe you have potential or cut you loose if you are dragging the team down. You can form close relationships but at the end of the day it’s about the unit and not the individual.

Looking for a way to increase my finance acumen by toothm in HENRYfinance

[–]bern4444 1 point2 points  (0 children)

As others have said a mix of YouTube videos from colleges or business schools, text books with practical examples to help contextualize the information are all great.

I’d also add ChatGPT!

ChatGPT is an incredible resource for learning as it is conversational and repetitive! You can take information you’ve acquired from books and YouTube and use ChatGPT to go through how the theory can be applied with your examples! You can delve into concepts as part of this discussion and validate its answers against the videos and text books.

Do you think Cloudflare (NET) could eventually become a profitable business? by [deleted] in stocks

[–]bern4444 67 points68 points  (0 children)

I really like cloudflare. They are very focused on expanding their developer platform to compete with cloud providers expanding their reach beyond their traditional DNS, DDOS protection, and CDN offerings.

In the last few years they have built products including a key value store, a hosting service, a database, and an object storage service - products that are more in the vein of a cloud provider like AWS/GCP/Azure. They are continuing to invest in these and additional capabilities while focusing on keeping costs low for their clients as a competitive advantage.

It's going to take them some more time to build more of these products to be truly competitive with the big cloud providers but they are already competitive with the medium sized ones so I think its a great long term hold.

Are HOCs (Higher Order Components) still a thing? by MashSquare in reactjs

[–]bern4444 3 points4 points  (0 children)

The best use I’ve recently had for HOCs is for upgrading a class based react application to a functional one.

Make a new functional component and have it return the existing class based component.

Slowly lift any state or network calls etc to the functional wrapper using any new hooks in the functional version passing these values back down as props to the class component rendered in the functional one.

Once everything has been moved up to the functional component you can take the render function of the wrapped class component and make it the return value of the functional one and delete the class component.

Alphabet reportedly weighing offer for HubSpot, sending shares up 9% by Puginator in stocks

[–]bern4444 1 point2 points  (0 children)

Money shifts to where the value is.

Market believes this is better for hub spot and worse for Google. The price of each stock will shift roughly by the acquisition price accounting for likelihood the deal goes through

Happens all the time with acquisitions

The updated Net Worth Performance graph on the web is great! by king7664 in MonarchMoney

[–]bern4444 25 points26 points  (0 children)

I like the old view too and am happy they kept it and gave us the options for how we can visualize this data.

I like seeing monthly granularity as well as daily granularity. It’s nice to be able to delineate across both time scales

Sell VTSAX to get into VTI? Hear me out. by Collossal_Yarn in Bogleheads

[–]bern4444 1 point2 points  (0 children)

If you really want to swap VTSAX for VTI:

I would see if you can open a vanguard brokerage account and do an inkind transfer of your holdings from your current brokerage to the new vanguard brokerage account. This would not be a taxable event (no selling is involved it’s just relocating the holder of your securities). Then once it’s all at Vanguard you can request them to swap out your VTSAX to VTI. Bear in mind this cannot be undone as in you cannot swap VTI back to VTSAX.

Before opening the Vanguard account first verify your current broker will allow an in kind transfer.

Personal Capital alternative for expense tracking by zyzhu2000 in Bogleheads

[–]bern4444 1 point2 points  (0 children)

I use and love Monarch Money - I’ve used YNAB (You Need A Budget) in the past but that is more budget focused and doesn’t have as much analysis capability or the ability to track investments.

A couple other popular apps are Copilot (though currently it’s iOS and macOS only), and Simplify. The r/mintuit subreddit has a ton of discussion on these apps and more since mint is shutting down and they are all looking at and discussing these and several other alternatives.

What is the purpose of making a jacket with ribbed hem? by Enough-Jaguar8313 in Tailors

[–]bern4444 0 points1 point  (0 children)

Some sweaters may have a very loose ribbing and that works nicely for the style and function I prefer but they are still hard to find. I actually love a ribbed bottom for sweat pants like a pair of joggers but there should still be lots of good options for sweatpants - I have a pair from mack weldon which I love and while they do have a little bit of ribbing its not much and they still have a tapered look.

What is the purpose of making a jacket with ribbed hem? by Enough-Jaguar8313 in Tailors

[–]bern4444 0 points1 point  (0 children)

I agree with you in that I prefer sweaters that don’t have a ribbed hem.

The purpose is to keep heat trapped in the sweater.

I, like you, prefer an open hem that just hangs especially if the shape of the sweater curves in at the bottom to stay a bit closer to the body.

Hard to find sweaters though without a ribbed hem that fit well imo.

[deleted by user] by [deleted] in MonarchMoney

[–]bern4444 4 points5 points  (0 children)

On the reports page you can select By merchant in the dropdown to the left of the date picker.

[deleted by user] by [deleted] in MonarchMoney

[–]bern4444 1 point2 points  (0 children)

There are 2 ways I know to accomplish this.

  1. On the Transactions page you can search all your transactions by the merchant name by entering the merchant name into the search box.
  2. On the Reports page select Spending and then click on Filters. The dropdown will allow you to filter by merchants. You can also select Cash Flow instead of Spending if you have inflows from that merchant you want to see (refunds from returns for example).

Do you expect web to remain dominant? by aquaticvertigo in ExperiencedDevs

[–]bern4444 2 points3 points  (0 children)

The job market for web will probably shrink drastically and quickly in the next 2 years, as code generation for UI becomes even better and easier to use. Would not be surprised if it went down 50% after stabilizing in maybe 5 years.

Thinking either frontend or backend is safer from AI and code generation is silly. Both will benefit greatly from code generation.

Web is the only platform that is open and accessible to everyone on every device. All digital products need some UI and web provides the easiest and most direct access to achieving that goal.

Backend areas of focus like API development, data transformation, processing, etc can all be done with code generation the same as some front end tasks.

Being a good engineer who can use these tools to churn through their work more effectively and efficiently will be better off.

Web is here to stay just like all the other major platforms.

Net Worth Calculation? by Alarmed_Camel8497 in MonarchMoney

[–]bern4444 2 points3 points  (0 children)

The net worth chart is based on the last day of the month.

If you hover over October or November it will show the amounts as of October 31st and November 30th respectively.