3
0

coding thread


 invite response                
2022 Oct 18, 8:27pm   8,078 views  95 comments

by richwicks   ➕follow (2)   💰tip   ignore  

Since there are a significant number of nerds here, I wanted to start a thread for projects.

People seem to INSIST on using cloud storage, which removes your ability of privacy, so I'm going to write a strong encryption program using the NaCL librarary;

https://nacl.cr.yp.to/

The goal here is that the resulting encrypted data is impossible to recover without getting the original key. Keys are changed regularly, and being able to brute force one block will give the attacker no advantage in cracking the next block.

Also, it will be computationally expensive to attempt to crack even with specialized hardware. This increases energy consumption and slows down the encryption and decryption, but also will make brute force attacks 1000's of times slower.

Comments 1 - 40 of 95       Last »     Search these comments

1   GNL   2022 Oct 18, 9:48pm  

Will you be able to monetize this?
2   richwicks   2022 Oct 18, 10:04pm  

GNL says


Will you be able to monetize this?


Maybe a marketer can, I doubt I can. I HIGHLY doubt I can..

It's not hard to do, but it's EASY to fuck up. Security is hard. Very hard. My favorite example is BluRay, they spent YEARS working on the encryption so it was extremely difficult to read and the algorithm was much more involved than DVD was. TONS of research put into it. The day the first Blu Ray player/disc was out, a BluRay film was online the next day. What somebody did was take the disc, played it back on Windows, setup a script to pause every frame, take a screen capture, and go through the entire film that way. They then took all the images, and turned it back into a film, and used SPDIF to capture 5.1 audio from digital.

Nobody in the development saw it, or if they did, they didn't care. Security for physical devices is IMPOSSIBLE. You can only secure something if you have something memorized in your mind.

Even if you have DRM going through your DVI cable (you can do this), you have to decode it at some point. Even with video game consoles. you just do mod chips, it's impossible. The reason MS wanted to move to digital online ONLY (no physical discs) was to make piracy more difficult, BUT, here's the next problem, you have 100's of THOUSANDS of video games you can easily get if you want them. Sure, you're not playing the "latest and greatest" which really isn't different than something made 20 years ago. We're starting to end up with "classic video" games now too, like "classic films" - but only the ones that can be preserved will hit this status, the rest will end up in a virtual landfill.
3   HeadSet   2022 Oct 19, 11:33am  

richwicks says

Security is hard.

So perhaps decrypting ransomware is doable in practice?
4   richwicks   2022 Nov 17, 2:32pm  

HeadSet says


richwicks says


Security is hard.

So perhaps decrypting ransomware is doable in practice?



Often it is.

Sometimes, when such malware / ransomware gets out, there are people posting fixes to it. They aren't trying hard for security just to make a mess, and then extort money out of people.

In my opinion, the problem is really with the operating systems and the chip. It's quite easy to make a chip that requires that, in order to run software on it, it has to be signed and verified. This is what is done on video game systems, the systems are (initially) sold BELOW COST, and are mighty powerful systems, so to prevent piracy (and from people turning them into cheap server farms), parts of the software have to be signed in order to execute.

No signature and it won't run. There's no reason this can't be done with EVERY program.

There's a reason that computers aren't secured, and it has to do with government, not technology.

BTW - there's a widespread rumor that the Equation Group, is really a group of criminals in the NSA. Who knows?
5   mell   2023 Jan 30, 2:02pm  

@richwicks have you seen this: https://freenet.org/ (locutus)

Haven't checked it out yet, but it claims to be a decentralized internet
6   richwicks   2023 Jan 30, 5:03pm  

mell says

richwicks have you seen this: https://freenet.org/ (locutus)

Haven't checked it out yet, but it claims to be a decentralized internet

@mell, I'll take a look.

My main concern is security at this point. Traversing NAT turns out to be relatively simple, but it's totally undocumented.

For file transfers that are not time dependent, UDP I think should replace TCP.
7   FortwayeAsFuckJoeBiden   2023 Jan 30, 5:11pm  

all that cloud shit is stupid. marketing term for “rent a server”. vendor lockin, cancel culture, they have your data.

i can’t believe its as popular as it got. its as if people collectively got stupid.
8   richwicks   2023 Jan 30, 5:29pm  

FortwayeAsFuckJoeBiden says

all that cloud shit is stupid. marketing term for “rent a server”. vendor lockin, cancel culture, they have your data.

i can’t believe its as popular as it got. its as if people collectively got stupid.


What's particularly dumb about "duh cloud" is that an equivalent to a year 2000 rack server is under $100. Why would anybody offload this to a 3rd party that will steal all your data if they consider this to their advantage?

Mainframes went out in the 1980's, and that's all "duh cloud" is, another dumb mainframe solution for something you can run on a TOY computer.
9   richwicks   2023 Jun 13, 12:07am  

OK, I blew an interview today - here's the problem I was given:

* You have M number of CPUs, they are placed one after the other in a line
* You have N number of JOBS, to be run on each CPU, JOBs is ALWAYS >= CPUs. I.E. N>=M
* Every CPU has at least 1 job running on it (there are always more JOBS than CPUs), NO CPU can have 0 JOBs.
* No CPU next to it can have 1 less or 1 more job running next to it.
* There is a special processor (best CPU) that is the Kth CPU, you want to have the MAXIMUM number of jobs running on it.
* The number of CPUs can be between 1 and 1x10^9 (this fits into an int, a 4 byte int anyhow)
* The number of JOBs can be between 1 and 1x10^9

Given an arbitrary number of CPUs (M), an arbitrary number of JOBs (N), and K being a given number (from 0 to CPUs-1), what is the maximum number of JOBs (the return value) that can run on the Kth CPU? Given the values of CPUs(M), JOBs(N) to run, and K(preferred/best CPU)?

I had one hour to solve this problem, and have spent the day solving it and I've not entirely solved it. There's an edge case where K=0 (first processor) and K=CPUs-1 (the last processor)

CAN YOU DO IT?

There are 3 edge cases I could identify
* K(best CPU) = 0 (far left)
* K(best CPU) = M-1 (i.e. CPUs-1)
* N(IE. JOBs) < 1/2 x 2M x 2M # This I'm not certain about. Remember, every CPU needs 1 job on it.

I've given you more information than I had, can you solve this in an hour?

My conclusion: they don't want to hire, period.
10   Tenpoundbass   2023 Jun 13, 6:55am  

richwicks says

My conclusion: they don't want to hire, period


A question made by some Indian ex-Intel engineer. Designed to disqualify anyone not of their caste.

But if you have 4 processors, and 24 jobs, and the answer isn't 6, then fuck them! It's a bunch of superfluous bullshit.
11   Tenpoundbass   2023 Jun 13, 7:08am  

A question like this is very subjective without machine specs and a business use case.
Some processes require semaphores and locks while others do not,. Aside from Crypto mining most cases wont need more than the internal load balancing of the server.
12   stfu   2023 Jun 13, 9:16am  

I don't understand "No CPU can have one more or one less job running next to it" - doesn't this mean that all CPU's have to be running the same number of jobs as every other CPU?; and that all additional verbiage is just to confuse the issue?

My answer would be the Kth CPU runs the same number of jobs as every other CPU.
13   Tenpoundbass   2023 Jun 13, 9:28am  

stfu says

My answer would be the Kth CPU runs the same number of jobs as every other CPU.

Tenpoundbass says

But if you have 4 processors, and 24 jobs, and the answer isn't 6, then fuck them! It's a bunch of superfluous bullshit.

Yup!
14   NuttBoxer   2023 Jun 13, 10:52am  

During that hour they wasted with a brain teaser, they could have asked you all kinds of specific devops or programming questions. My opinion, brain teasers are pointless. I care more about someone's ability to clearly communicate, technical prowess, and being open to new ways of doing things. I've been on a few interview panels at different companies.
15   NuttBoxer   2023 Jun 13, 10:55am  

richwicks says

People seem to INSIST on using cloud storage


Now there is cloud storage by some mega corp you should never trust, then there's a VPN into a server at your friends house. Both are technically cloud, but one you actually know the person, so trust makes more sense. But storage should always start at home, where you have quick physical access should something come up, and most importantly, internet goes down, your shit still works, because it's LAN. Start there before worrying about the only purpose cloud should ever serve, redundancy.
16   Peter1656   2023 Jun 13, 12:06pm  

richwicks says


I've given you more information than I had, can you solve this in an hour?

You need to join LeetCode.com . I've been having fun on that site answering questions for the last 6 years. I've finished nearly all the free ones. (over 2000 questions). This question (phrased differently) was given at least 2 years ago and was also given as a "question of the day" just 3 days ago!

The big insight (after finishing 2000+ questions!) is that you can binary-search the correct answer. Turn the question around: Put a bunch of jobs on the special CPU and see if the total number of jobs doesn't exceed the allowed when distributed across all the CPUs. Obviously, the most go on the special CPU and then each CPU to left or right is decreasing by 1. The little hiccup is that you can't go to zero--a much of CPUs might get 1 job. Binary search the number of jobs on the special one; for any guess that is lower than max, you'll be able to accomodate all the jobs (across all the CPUs); for any guess higher than the max and you'll see you can't accommodate all the jobs. The binary search finds the threshold between the two. On LeetCode, just using binary search isn't fast enough to pass muster; you also have to calculate the number of jobs used by the non-special CPUs quickly.

Can I solve this question in an hour? Yes. Actually, I have:
https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array/

Hmm... I marked the below as code, but it's not honoring the all-important indenting. I'll add some dots instead.

class Solution:
...def maxValue(self, n: int, index: int, maxSum: int) -> int:

......def calcRange(high,length):
.........if high > length:
............return (high + (high-length+1)) * length // 2
.........shortLength = high-1
.........leftover = length - shortLength
.........return calcRange(high,shortLength) + leftover*1

......def calc(m):
.........return m + calcRange(m-1, index) + calcRange(m-1, n-index-1)

......return binSearch(0,maxSum+1,lambda m: calc(m)>maxSum) - 1

def binSearch(low,high, lam):
...# returns lowest value between low and high for which lambda gives True
...while low < high:
......mid =(low + high) // 2
......if lam(mid):
.........high = mid
......else:
.........low = mid + 1
...return low
17   SunnyvaleCA   2023 Jun 13, 12:35pm  

Hm... Weird. I have no idea why I was mysteriously logged in as Peter1656 above. Sent email to Patrick.
18   SunnyvaleCA   2023 Jun 13, 12:38pm  

richwicks says

People seem to INSIST on using cloud storage

Are they merely using cloud storage? Most people are using cloud services, which includes storage, search, database, and now AI! If you're trying to encrypt the data stored in the cloud, then those other services will need to be able to decrypt in order to work on your data.
19   richwicks   2023 Jun 13, 1:41pm  

stfu says


I don't understand "No CPU can have one more or one less job running next to it" - doesn't this mean that all CPU's have to be running the same number of jobs as every other CPU?; and that all additional verbiage is just to confuse the issue?

My answer would be the Kth CPU runs the same number of jobs as every other CPU.


OK. Say this you have 5 CPUs and they look like this:



Each processor is labelled at the bottom, the preferred processor is "0" and there's a total number of 15 jobs on 5 processors

there are 5 then 4,3,2,1 JOBs running on each processor (X represents a "JOB"). CPU1 has 4 JOBS, but can't have 3, because CPU0 has 5 JOBs +1 more, and CPU2 has 3 JOBs

But what if processor 1 is the preferred CPU? Then it looks something like this:



I finally figured out how this works. I can see how you COULD do a binary search, but the solution is arithmetical, I believe. You have to know this:



If you don't, you can't solve it, and I couldn't remember it. Also the calculation of the area of an Isosceles right triangle is (i.e. right triangle width == height), and I didn't know that and it took me a while to figure it out:

A = (w+1)/2+(w*w/2)

This only works with integer math and it's true for all cases of w including 0.

I'm starting to wonder if the interviewer had the math right because as I delve into this, I had to remember the series function to square a number, and also figure out how to calculate exactly the area to make a Isosceles right triangle. Should I know this shit off the top of my head?

Anyhow, this has a solution that can be directly calculated given a total number of jobs and the preferred processor and number of processors. You don't need to do binary math, but the equations I'm just figuring out, and it's integer math which means I can't be off by 1, and I have to find out when I need to round down and round up to the nearest integer. So far, looks like everything is round down.
20   richwicks   2023 Jun 13, 1:57pm  

@Patrick - New Bug:



I'm just clicking "quote" on a post - can't do it.
21   richwicks   2023 Jun 13, 2:00pm  

Peter1656 says

Can I solve this question in an hour? Yes. Actually, I have:


In you solution, where is the preferred CPU listed? It DOES make a difference as I've shown here:

https://patrick.net/comment?comment_id=1960746

I don't think my interviewer realized that the CPU's position made a difference.
22   richwicks   2023 Jun 13, 2:04pm  

SunnyvaleCA says

richwicks says


People seem to INSIST on using cloud storage

Are they merely using cloud storage? Most people are using cloud services, which includes storage, search, database, and now AI! If you're trying to encrypt the data stored in the cloud, then those other services will need to be able to decrypt in order to work on your data.

The whole point of cloud "services" is to hand over your data to a corporation.

Because it's "convenient".

It's like using Alexa - it's "convenient". Got one? What is a pet you would NEVER EVER own? Well, pretend among your family you are about to get this new pet. Talk about it, make plans about it, in front of the Alexa - see how long it takes before you get advertisements for accessories for this pet.

It's a spy device, and it CONSTANTLY listens to you, not just when you prompt it. I can tell you this, just gave you a test to confirm it, it's continually listening to you. You'd think this would end people having Alexa devices - nope. People literally aren't bothered by having a machine CONTINUALLY listen to them 24 hours a day 7 days a week, and it's all recorded as well.
23   Patrick   2023 Jun 13, 4:44pm  

richwicks says


Patrick - New Bug:



I'm just clicking "quote" on a post - can't do it.


@richwicks, not a bug.

There needs to be a limit on quote size. Before, I was trying to abbreviate the middle of an excessively large quote, but that caused problems with html parsing.

So my new solution for a too-large quote is to ask the user to select something smaller.

If you click "quote" without selecting anything in your example, that's too large. So you should select a portion of the comment, and then click quote.

Let me know if I misunderstood you.
24   richwicks   2023 Jun 13, 5:16pm  

Patrick says

richwicks says



Patrick - New Bug:



I'm just clicking "quote" on a post - can't do it.


richwicks, not a bug.

There needs to be a limit on quote size. Before, I was trying to abbreviate the middle of an excessively large quote, but that caused problems with html parsing.

So my new solution for a too-large quote is to ask the user to select something smaller.

If you click "quote" without selecting anything in your example, that's too large. So you should select a portion of the comment, and then click quote.

Let me know if I misunderstood you.


Why limit quote size? You know how small characters are. 8 bits.

It's your site, but consider how small a quote is in terms of data storage.

Everything you have now, fits on a $11 SD Card. I believe you still think there are storage limitations, there aren't. You're still in the 1990's.
25   gabbar   2023 Jun 13, 5:19pm  

So, I have a sophomore student in Computer Science at OSU. Which programming languages should he learn? And how?
26   NuttBoxer   2023 Jun 13, 6:52pm  

Javascript and Java are always big ones, but Python seems to be gaining popularity. It kind of depends on if he knows what he wants to do. Front-end/UI, JS all the way. Security or devops, Python.

There are plenty of good free tutorials online, but from what I've heard those coding camps work really well.
27   richwicks   2023 Jun 13, 10:37pm  

gabbar says


So, I have a sophomore student in Computer Science at OSU. Which programming languages should he learn? And how?

Have them learn a very low level language like assembly (useless) to understand what the machine does.

And a very high level language to understand concepts.

And then fill in the inbetween. That's a good solid start. Assembly is essential to know what is going on, IF they want to know what is going on. High level languages are entirely abstractions, they are slow in comparison to lower level languages, but you have hashes, you have dictionaries, regular expressions, all this weird shit which would take forever to implement in a low level language.

BTW: C++ has improved VASTLY since I last used it. It no longer sucks!

I didn't really understand the concept of a pointer until I learned assembly, and then it was "oh, it's just a pointer to a memory location", because in assembly, there really aren't any variables, there are only memory locations. Once you learn assembly, it's TRIVIAL to understand how the CPU works. Nobody knows what a register is until they work in assembly. A register is a storage location for a value when you do this in C:

i += 1

What is happening really is in pseudo-assembly is something like:

load REGISTER1, MEMORY_LOCATION # load the value in memory_location into register1
set REGISTER2, 1 # set the value of register2 to 1
add REGISTER3, REGISTER1, REGISTER2 # add register 1 and 2 together and store the result in register3
store REGISTER3, MEMORY_LOCATION # store final result in memory_location

There's 4 steps to it, but it might be as little as 3, because adding 1 to a value is so common, it's often part of the chip.

Once they understand assembly, they understand the machine IF they want to understand it. Assembly was fascinating to me. Once I understood it, all other languages were just abstractions to it, but higher level languages gave me the ability to see and work with concepts which were FAR too complicated for me to ever implement in assembly.

You have to learn many high level languages, and a few lower level languages. You don't have to learn higher level languages well, it just introduces you to many concepts which you can implement elsewhere. The concept of a class in C++, brilliant idea, but it's trivial to implement that in C. You're just passing around a pointer to a C structure to every function. There, that is basically C++. C++ used to be nothing more than a preprocessor for C - it took in the C++ code, and through a bunch of macros and conversions, made a C file, and compiled that.
28   SunnyvaleCA   2023 Jun 13, 10:56pm  

richwicks says


In you solution, where is the preferred CPU listed? It DOES make a difference as I've shown here:

Yes, it's the input parameter index.

I think LeetCode practice is kind of standard in this competitive market. I first got into it for entertainment — I wanted to explore some dynamic programming problems. Later I used it to learn Python.
29   richwicks   2023 Jun 13, 10:59pm  

Peter1656 says


Hmm... I marked the below as code, but it's not honoring the all-important indenting. I'll add some dots instead.


I believe this solution can be made with a single calculation, with 3 edge cases:

preferred CPU = 0
preferred CPU = 1-total CPUs
JOBs < 1/2 x CPUs x CPUs

I can't use asterisk her, because it's taken as "bold"

Using a binary search I think is sloppy.

I was surprised by the question because I can see no relevancy in implementation. I have 30 years of coding under my belt, and have never seen a reason to do this, and I've done priority inversion on an operating system - that's non trivial. This is when a low level process has secured a resource, and a higher level resource wants this resource. The solution is to TEMPORARILY increase the priority of the low level resource so it can free it. But what if you have 7 processes requesting this resource?

The solution is, you increase the priority to the maximum process that wants it until it frees the resource. You only pay attention to the top one.

Useless knowledge at this point. People who still use processes are, in my opinion, morons. Everything should be a program not a thread, and use interprocess communication and event driven. It drastically reduces errors, and entirely eliminates race conditions. I wouldn't want to go back to the 1990's again.

No more semaphores, no mutexes - kill them all. These are obsolete ideas since protected memory came into play. Threads shouldn't exist at all today. I don't even know if there are chips that still don't have virtual memory at this point. I'm sure they still exist, but they shouldn't.
30   SunnyvaleCA   2023 Jun 13, 11:19pm  

richwicks says

I believe this solution can be made with a single calculation, with 3 edge cases

Perhaps your problem is different than the LeetCode one, but I don't think so.
Here's my understanding of a simplified version of the problem you had...
Suppose, for simplicity, the 0th CPU was the special one. If you give it 8 jobs then the whole set of CPUs get 8, 7, 6, 5, etc. jobs. The catch is that every CPU after the 7th needs to get 1 job (the minimum number of jobs) — not 0, -1, -2, -3, etc. So the distribution of jobs is non-linear and so the solution is not a polynomial. When the binary search "guesses" an answer, it can verify in constant time, so the algorithm runs in log(n) time. That might be "sloppy," but if the count of CPUs and count of jobs each fit in a 64-bit integer, logarithmic time will be nearly instantaneous on the worst possible input.
31   richwicks   2023 Jun 14, 1:33am  

SunnyvaleCA says


richwicks says


I believe this solution can be made with a single calculation, with 3 edge cases

Perhaps your problem is different than the LeetCode one, but I don't think so.
Here's my understanding of a simplified version of the problem you had...
Suppose, for simplicity, the 0th CPU was the special one. If you give it 8 jobs then the whole set of CPUs get 8, 7, 6, 5, etc. jobs. The catch is that every CPU after the 7th needs to get 1 job (the minimum number of jobs) — not 0, -1, -2, -3, etc. So the distribution of jobs is non-linear and so the solution is not a polynomial. When the binary search "guesses" an answer, it can verify in constant time, so the algorithm runs in log(n) time. That might be "sloppy," but if the count of CPUs and count of jobs each fit in a 64-bit integer, logarithmic time will be nearly instantaneous on the worst possible input.



OK, here's the solution, that doesn't quite work.

The problem is really you have an array (that's the CPUs) and every element in the array must contain at least "1". If you add up all the values of the array, you will have the value V.

No element in the array can be +/- 1 form an adjacent element in the array. The value next to to any adjacent element can't be more than 1 off, but the difference can be 0.

Find the maximum value you can place in the array with these constraints given that all values in the array need to add up to V

SO - here is what I did. I think of it as a volume. The value "V" is a volume

First, since V is really a volume, the minimum height can be calculated with:

V = W x H
H = V/W

We need 1/3rd of the volume to build the pyramid, so the max height is actually

2/3 V = W x H
H = (2/3 V) / W
H = 2 x V / W x 3

that's the height of the base, the rectangle.

Now, the area of a triangle is 1/2 x W x H. The volume of this is 1/3V

1/3V = 1/2 x W x h

h = 1/3V * 2 / W
h = 2/(3V x W)

Add H and h together, and you get the result.

BUT I'm ignoring a few constraints.

My mind is still baking on this problem. I think a binary search is a sloppy method to do it. I'm confident this can be done arithmetically with at most 3 constraints.

Fucking math. Give me a math problem, and I can't stop working on it until I solve it.

First, you subtract W (number of array elements) from the volume. then you calculate the rectangle, then produce the highest possible pyramid on top of that from the 1/3rd of that block. It's all integer math as well, so if you can't produce a block, you just have the remainder to work with, or if you can produce a block it's 1/3rd of the block PLUS the remainder. It's all complicated because of it being integer math, and I need to think more on it.

I bet this can be done with float math, and get within 1 of the true value, if not always being correct if you always round down.

But this neglects the edge cases where the top point is at the start of the array, or at the end of the array.
32   GNL   2023 Jun 14, 5:18am  

Can I take a poll with you all?
If you were starting from scratch, what would you use to create a commercial website?

What the site does: upload/download (domestic and overseas), payments, Google map and Google calendar to create schedules based on time/distance, overlays on photos until payment is made, cron jobs for deleting old files/images and emails, user rearranging/sorting images for slideshow displays, user registrations, api for transferring images and links to other websites and image mapping.

Also: when and/or what would make you recommend a client rewrite a company website?
33   NuttBoxer   2023 Jun 14, 8:09am  

richwicks says

Have them learn a very low level language like assembly (useless) to understand what the machine does.


Good callout. C or C++ are the still the preferred language for physical machines that have to do very high load operations. When I worked at Illumina, their DNA analysis SW was all C I believe.

Also forget to mention Python seems to be the language of choice for AI if you are interested in getting into that.
34   NuttBoxer   2023 Jun 14, 8:16am  

GNL says

If you were starting from scratch, what would you use to create a commercial website?


Before I left a former company, we were in the process of re-writing our travel site integration with EAN(Expedia) as a single page Python app. But I would guess most people would say Javascript, probably React?

Don't invest time in a re-write unless you will gain some significant improvements for your clients, increase your reach, something tangible that improves your bottom line. Worst case you have some massive security issues or you have spaghetti code you have to keep adding to that will make your site impossible to update, then you might have to consider it just for maintenance, but hopefully you've laid a better foundation than that.
35   Tenpoundbass   2023 Jun 14, 8:33am  

Do it in MVC

I once did a similar project for a Nautical Satellite company. I used Google Maps to place the ships coordinates and routes on Google maps.
I did it for a job interview for the company. I turned it around in about 4 days over a three day weekend, and the interviewer wasn't back on the fourth day.
The interviewer gave me an end point, that returned nothing but a bunch of numbers separated by a comma. I guessed that they were x and y coordinates. And ended up being right. Exploring the Help endpoint further I found the View, Details and Insert endpoints. When I emailed it back to them, the interviewer still wasn't back and was out for over two weeks. I ended up taking another job in the meantime. When the guy got back he was telling me that it was better than what they were expecting. No other candidate figured out what the end point was, or even returned the completed test project. All they wanted was someone to hit the end point, and realize what it was and anything beyond that would have been gravy. I was at the time, trying to really figure out MVC beyond using wizard and data connecters GUI's, that I found just so restricting and limited if you go by most common MVC documentation. That little project gave me insight on ways to use MVC that 90% of the people that use MVC don't believe is possible. They wanted me to start right away, but I already took the other job. So they asked me if they could use the test project I sent them as the foundation to build their software.

I still have a copy of that project if you are interested.
36   Tenpoundbass   2023 Jun 14, 8:41am  

NuttBoxer says

Don't invest time in a re-write unless you will gain some significant improvements for your clients, increase your reach, something tangible that improves your bottom line. Worst case you have some massive security issues or you have spaghetti code you have to keep adding to that will make your site impossible to update, then you might have to consider it just for maintenance, but hopefully you've laid a better foundation than that


Always do a rewrite. Normally by time you are called to bring a Customer's software to the next level. The previous developer had already coded the project into a hard corner. And the new business requirements would be impossible to factor in without creating a buggy broken system.
If the data model is good, and the enterprise is happy with it. Then the best and quickest way to do a rewrite is to use Code Generating SQL against the tables. I can stub out a whole Enterprise suite in under a week. Then only need to write the business logic layer and the client Scripts.

Examples below...
37   Tenpoundbass   2023 Jun 14, 8:42am  

declare @TableName sysname = 'TaxLine'
declare @result varchar(max) ='[DataObject(true)]
public class ' + @TableName + 'DB
{' + '
' + @TableName + 'Context DFctx = new ' + @TableName + 'Context();

public ' + @TableName + 'DB(){

}'

select @result = @result + CHAR(13)
+ ' [DataObjectMethod(DataObjectMethodType.Select)]
public List<' + @TableName + '> Select(int tableId, int _userid)
{
return DFctx.Get' + @TableName + 'singleton(tableId, _userid);
}
public ' + @TableName + 'Selects(int tableId, int _userid)
{
return DFctx.Get' + @TableName + '(tableId, _userid);
}
[DataObjectMethod(DataObjectMethodType.Select)]
public List<' + @TableName + '> Select(int _userid)
{
return DFctx.Get' + @TableName + '(_userid);
}
[DataObjectMethod(DataObjectMethodType.Insert)]
public void Insert(Dynamic' + @TableName + ' DTable, int _userid)
{
DFctx.Insert' + @TableName + '(DTable, _userid);
}

[DataObjectMethod(DataObjectMethodType.Update)]
public void Update(Dynamic' + @TableName + ' DTable, int _userid)
{
DFctx.Update' + @TableName + '(DTable, _userid);
}

[DataObjectMethod(DataObjectMethodType.Delete)]
public void Delete(' + @TableName + ' DTable, int _userid)
{
DFctx.Delete' + @TableName + '(DTable.' + @TableName + 'ID, _userid);
}
public int Get' + @TableName + 'Count(int _dyntbl)
{
return Get' + @TableName + 'Count(_dyntbl);
}
}'

print @result
38   Tenpoundbass   2023 Jun 14, 9:16am  

Tenpoundbass says

If the data model is good, and the enterprise is happy with it. Then the best and quickest way to do a rewrite is to use Code Generating SQL against the tables. I can stub out a whole Enterprise suite in under a week. Then only need to write the business logic layer and the client Scripts.


I would add, that I preferer to custom script out my own code generation per each project. I do not use Entity Frameworks because it adds way too much buggy sluggish overhead, it's hogs more resources than all of your project's code combined. All of my code generation is external and I plug it into the pages and classes I'm working on by hand. But I can script for any language and any model, for any purpose. Client HTML code, Object Classes, and Data Classes. EFF can not do that. Frameworks can generate cookie cutter code, but it's all the same code from project to project. You can't use Microsoft EFF to generate Python or Java code.
39   NuttBoxer   2023 Jun 14, 10:53am  

Tenpoundbass says


Always do a rewrite. Normally by time you are called to bring a Customer's software to the next level. The previous developer had already coded the project into a hard corner. And the new business requirements would be impossible to factor in without creating a buggy broken system.


I spent a month testing some API's for a guy who was monetizing a domain purchasing site. He hired an oversea's programmer who slapped a bunch of stuff together with no standardization, and some pretty big security gaps. I pointed it out to him, but due to the fact that he hadn't even launched yet, there wasn't much interest in doing anything beyond plugging the security gaps.

I work in software quality, so my first instinct is always to push for maintenance NOW, but it really does depend on where the business is at.
40   Tenpoundbass   2023 Jun 14, 1:57pm  

The hardest part for any Enterprise software, is getting it to the point to where it is now.
One of the biggest problem with rewrites is they come in thinking they are going to do a total data model redesign. These days they want to shoehorn software written for a unique business case in a unique industry with unique requirements. Into a one size fits all Cloud CRM and ERP. So they are forced to rewrite the whole business process logic and requirements. Any gaps not meeting previous requirements, they outsource to a third party service, lots of third party cloud services, to do what 90% of the companies should be home growing on their own. I try to understand the business reasons for the most fucked up head scratching code, and understand why the previous guy did it so ungracefully. There was always a reason, that even those cloud guys eventually run into. No matter how hard they try to ignore that complicated backwards, stupid way the previous guy was forced to do it. .
But if you take time to understand that you probably would have met the same trap, because you understood, what it was doing, how that process got added on after the fact. And you understand what it does and why it's important.. You can then figure how to gracefully make that process. You can make some of your most elegant impressive code you ever did. And in many ways, you owe it to the previous guy, and the problem he was faced with. That you then built on and made it work.

Most migrations and updated enterprise rewrite development lead, do not understand that process today.

Comments 1 - 40 of 95       Last »     Search these comments

Please register to comment:

api   best comments   contact   latest images   memes   one year ago   random   suggestions