Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Kyu961700278dWhat IDE is this? I like the editor color scheme. Can you share that :D?
julkali2398278dEven if it's not user input data, please never write your sql statements using string interpolation
lotd8419278dCould extract the logic into objects that expose some methods like
supports($prediction, $actual): bool
Then in a loop return the first supported result()
TheLazyDev266278d"switch(true)" yeah, fuck this
@Bitwise first case is checking if prediction and actual result is the same:
actualHome = predictedHome.
Then ifs below are checking which team was the winner:
predictedHome > predictedAway
actualHome > actualAway
@AlexDeLarge something I can agree with, but language after all is just a tool
@Bitwise oh, come on:
aH = 3 | aA = 5
pH = 3 | pA = 5
If aH == pH && aA == pA: # true
if aH > aA: 6 # false
elseif aH < aA: 6 # true
PS: u figured it out already I see, well its devrant ing compression not much I can do.
Yes, switch was for readability and also for easier reasoning compared to SQL.
Abstraction is needed, though, to separate SQL and PHP implementations and reduce duplication for easier future maintenance
joas1524278dWhat exactly do you mean by abstracting a SQL and a PHP script?
One abstraction for a script is a function. Just wrap it in a function and it's abstracted to one function from multiple lines of code.
That wasn't probably what you meant.
gintko3082277d@joas @Bitwise what I meant, was refactoring code so it can comply with solid and dry, which in this case can be only approached by abstracting the code or in other words, splitting code into higher level class(-es) which then can be reused to implement actual logic.
Anyway, I kind of solved it in the not the best way by defining template methods for specific instructions, that really does nothing besides documenting the code. I can post link here on tuesday if someone is interested.
I figured, that probably the best way to achieve reusability here, is to implement builder pattern which abstracts both SQL and PHP DSLs, sth like following:
Anyway, thats overengineering for my case.
Your Job Suck?
Take a quick quiz from Triplebyte to skip the job search hassles and jump to final interviews at hot tech firms
Get a Better Job
Cyborg18A guy and a girl are in a Java seminar. Afterward, the guy approaches the girl and asks, "Hey gurrl, can I ge...
yansch10Manager: "we need an SQL database" Dev: dude does he even know what he's talking about Dev: "so which color?" ...
Korvax20Italian chef: We have the best spaghetti in the world PHP developer: I doubt that