algodritmo 1 Posted December 19, 2021 Hi, I was wondering if I could get some honest opinion about some Delphi code. We're presented with the option of selling a Windows app, Delphi code. I'm attaching the main 2 Pas files. It's for a simulation model of cow digestion, but it doesn't have any documentation at all, of the model or the code or anything. We just know that the results are good. If someone could have a really quick glance at the code I'd love to know how long do you think it would take an experienced programmer to be able to understand it, reverse document it, eventually even extract parts of the model to some other software, or modify the current software, etc. Apart from the code logic itself, would it be possible to infer the logic of the cow model behind it? How much work all of that would be? Thank you soooo much! https://pastebin.com/nuPJHrKd https://pastebin.com/uy1kByAk Share this post Link to post
Stano 143 Posted December 19, 2021 (edited) I don't have to judge it. Out of curiosity, I looked at it. So fast. Nobody will go with your text formatting. It can't be read😤 Declaring variables, given their huge number, I would put in a separate unit (Classes?) You are initializing variables. It should be a separate function. In your case, in a separate unit. You must clear that code first. Edited December 19, 2021 by Stano Share this post Link to post
algodritmo 1 Posted December 19, 2021 11 minutes ago, Stano said: I don't have to judge it. Out of curiosity, I looked at it. So fast. Nobody will go with your text formatting. It can't be read😤 Declaring variables, given their huge number, I would put in a separate unit (Classes?) You are initializing variables. It should be a separate function. In your case, in a separate unit. You must clear that code first. Well I understand you, but that was the idea of the question in fact... trying to guess how much work would it be to go from "it can't be read", to "well now we understand it", "we can present some high level documentation (related to the cow model, not to the code itself)", etc. Share this post Link to post
algodritmo 1 Posted December 19, 2021 (edited) BTW, I have some coding skills, and for me that's looks like a months long task, if at all possible. But the developer of that code says that it would be simple for an experienced Delphi programmer, so we're tying to find more opinions 🙂 Those are just 2 of the files of course. It's a GUI project, with local and remote DB access, charts, etc. But those are the main ones. Edited December 19, 2021 by algodritmo Share this post Link to post
Stano 143 Posted December 19, 2021 I think that the actual modification of the code into a readable form is max for one day. Share this post Link to post
Guest Posted December 19, 2021 Me,too. Scrolled about for some minutes. First off; what are the use cases, how many clients / what revenue. Is it a project where i get payed per hour or do i have to wait for revenue (comission). No... no no no, i do not see a good path, paying someone 20-40 hours. For UNDERSTANDING IMHO you should "engage" someone that feel comfortable both with the legacy code and the "future plans". My client sometimes engage other when they feel i change to much, they often have to come back to me (for a higher price) after those "cheap excursions" int "cheaper". My take: evaluate seriously whet this project might give back and ditch it if someone with insight would be "too expensive". IMHO Share this post Link to post
Guest Posted December 19, 2021 @Stano, the OP wrote that the presented files are "just two but the main part". If you read code like you read posts, then i would not give you the job. Do you really feel you know at this momen what the other (non presented parts) entail? This is not a one-off, this is a process. Share this post Link to post
Guest Posted December 19, 2021 @algodritmo, after a meeting of around two hours, i could probably state the prerequisites for putting my head into this. But no guarantees at all. and i would not be able to start before april IF i deem you budget sufficient and IF my current clients do not fuck up before that (they usually do). Share this post Link to post
Stano 143 Posted December 19, 2021 Quote @Stano, the OP wrote that the presented files are "just two but the main part". If you read code like you read posts, then i would not give you the job. Do you really feel you know at this momen what the other (non presented parts) entail? This is not a one-off, this is a process. But that was after my answer I already mentioned here that I am not a programmer. I'm just playing with him 1 Share this post Link to post
Stano 143 Posted December 19, 2021 Such a small insignificant thing. Typical for me. I only meant formatting/refactoring published files. Share this post Link to post
Pat Foley 51 Posted December 19, 2021 (edited) The source needs documented as to the sources used for model. If source is based on work of researchers at Public Universities or use reverse engineered patented technology. The documentation helps when other company patents similar technology and puts first company out of business with a Patent suite. The value of program like this could be extended by including ear tag information on each cow which allow better documentation of the pharma given to each animal. Some farmers like the tag program but the packing houses do not. Hopefully a program like this could be used for public good and allow inspection of data by researchers. One example of good technology on dairy cows. The modern milker machine senses exactly when the cow milked out--over milking makes for an unhappy cow. When milk production decreased in an area, researchers found that a modern milker when powered by poorly grounded mains supply would shock the cow. Edited December 19, 2021 by Pat Foley add line. Share this post Link to post
haentschman 92 Posted December 20, 2021 Please at the next Thread: Quote Drag files here to attach, or choose files... Attach files HERE...not at a external server ZIP, PAS, PNG ... thats all what you want. Share this post Link to post
algodritmo 1 Posted December 20, 2021 Done haentschman! Thanks! MasterForm.pas RumenGut.pas Share this post Link to post
haentschman 92 Posted December 20, 2021 👍 Remember: sometimes it is required to load the complete project, including DPR, DFM...then the ZIP format is your choice. Background: if the external server is closed, the thread here is incomplete. Share this post Link to post
Fr0sT.Brutal 900 Posted December 20, 2021 (edited) 1 hour ago, haentschman said: Attach files HERE...not at a external server I like online more so that I don't have to download stuff which then needs to be deleted... too much excess actions. These files are for evaluation purposes anyway. As for the code: it's quite poor. Not the most awful one I've seen but something like I wrote when I was student. IMHO it first needs careful refactoring (no serious skills really, just accuracy and some knowledge of what's right and wrong). Edited December 20, 2021 by Fr0sT.Brutal Share this post Link to post
Stano 143 Posted December 21, 2021 I can't move on with my problem. So I adjusted one unit as part of the relaxation. I used automatic text formatting I inserted blank lines to increase readability I did not deal with unnecessary and missing begin-end pairs I personally use a 120-character line. I didn't apply it here. In Word, it fits on one side. The number of rows has increased, which I do not consider to be a mistake. rumengut.pas Share this post Link to post
Pat Foley 51 Posted December 22, 2021 procedure TEventBoss.moveMouse(AC: Tcontrol); const gravity =-9.8;//gravity wind = 17; //West wind derecho force buoyancy = 62; //lbs floated in firken of displaced snowmelt buoyancySteamAir = 18/28; //MW of water/Mw of Air assume water returns as hailStones; //:( XYtolerance = 6; var eX, //MouseXError eY, X, Y: integer;// nativeInt; vtX, vtY: integer;//terminal velocity newMousePT: TPoint; MainF : TControl; begin X := AC.CLientOrigin.X + AC.Width div 2; Y := AC.CLientOrigin.Y + AC.Height div 2; eX := round(0.4 * (x - mouse.CursorPos.X + wind)); eY := round(0.4 * (y - mouse.cursorPos.y - gravity)); vtX := 12 + sign(eX) * wind div 2; vtY := 8 + sign(eY) * trunc(-Gravity) div 2; eX := Min (abs (eX),vtX) * sign(eX); eY := Min (abs (eY),vtY) * sign(eY); newMousePT.X := mouse.CursorPos.x + eX; newMousePT.Y := Mouse.CursorPos.y + eY; mouse.CursorPos := newMousePT; If (abs(eX) + abs(eY)) < XYtolerance then // MN for XYtolerance; moveMousetoInstance := nil; if AC.parent = nil then MainF := AC else if AC.Parent.Parent = nil then MainF := AC.Parent else MainF := AC.Parent.Parent; // following adjusts for the ocean domain // form floats up after "submerging" into water if newMousePT.Y > Screen.Height - buoyancy * 3 then MainF.top := MainF.Top - abs(eY); // following adjusts for the troposphere domain // form floats on denser air if newMousePT.Y < Screen.DesktopTop + round(buoyancySteamAir * 350) then MainF.top := MainF.Top + abs(eY); // form in left ditch pull it out a little each timer event. if newMousePT.X < 0 then MainF.Left := MainF.Left + abs(eX); if newMousePT.X > screen.width then MainF.Left := MainF.Left - abs(eX); end; This code example shows code that moves the mouse to a component on a form when it is opened. When Y is small the form floats in air domain. When Y is big form floats in water domain The example shows how the errors eX and wY, caused by the influence of wind and gravity*, is solved by integrating the error correction over time into mouse path as it moves towards the control. When movemousetoInstance is nil the timer skips the call to movemouse in the timer routine. Chemical tensions could be modeled in your rumen domain. Further setting initial conditions and saved model state would be good allowing the model converge quickly. I thinking about the cruft, would the pH be locally lower with carbonic acid working on what's floating or is it floated by CO2 offgas? * Imaginary use of green energy to power the mouse. Share this post Link to post
Lars Fosdal 1793 Posted December 22, 2021 For algorithms to be maintainable and testable, they need to be separated from the UI. The UI can deliver inputs, but the math/logic needs to be black boxed seen from a UI perspective. 1 Share this post Link to post
Pat Foley 51 Posted December 22, 2021 6 hours ago, Lars Fosdal said: For algorithms to be maintainable and testable, they need to be separated from the UI. The UI can deliver inputs, but the math/logic needs to be black boxed seen from a UI perspective. The difference between a mathematician and an engineer is the engineer uses pictures. We use some very abstract concepts to solve efforts and flows using first principles and plot to chart when needed. Process control scheme for brewery or a sewage plant might be source of model to use. The rumen reticulated* could be reduced to flash tank, holding tank, settling tank with vents and reflux. The process variables are moved between tanks and then computed. The variables are made persistent by list of pointers loaded at runtime to use with procedures and save state and used in UI. The ash or minerals passing through helps decide if the stool is sinker or floater. *networked Share this post Link to post