Click here to Skip to main content
15,913,919 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
AnswerRe: Why would you ever want to do this? Pin
CodeWraith23-Oct-18 4:42
CodeWraith23-Oct-18 4:42 
GeneralRe: Why would you ever want to do this? Pin
Eytukan24-Oct-18 1:27
Eytukan24-Oct-18 1:27 
AnswerRe: Why would you ever want to do this? Pin
F-ES Sitecore23-Oct-18 5:05
professionalF-ES Sitecore23-Oct-18 5:05 
GeneralRe: Why would you ever want to do this? Pin
dandy7223-Oct-18 7:17
dandy7223-Oct-18 7:17 
AnswerRe: Why would you ever want to do this? Pin
kalberts23-Oct-18 7:54
kalberts23-Oct-18 7:54 
AnswerRe: Why would you ever want to do this? Pin
kalberts23-Oct-18 8:23
kalberts23-Oct-18 8:23 
AnswerRe: Why would you ever want to do this? Pin
Daniel Pfeffer23-Oct-18 19:05
professionalDaniel Pfeffer23-Oct-18 19:05 
AnswerRe: Why would you ever want to do this? Pin
Jimmytehbanana24-Oct-18 1:53
Jimmytehbanana24-Oct-18 1:53 
Maybe not this specific example, but you could use it in testing (similar to monkey patching functions for unit tests in other languages).

I’d never recommend using monkey patching in production code. It is helpful in unit testing though to patch functions outside the unit or to patch database access functions during unit testing. This is, of course, provided you unpatch the function at the end of the test.

Not too sure if PHP has a defer mechanism for unpatching when the function is no longer in scope, but that is one way to test a single unit and have predictable interactions with external code (an external call to the unit fails, returns weird data, returns expected data, etc).
Sr. Software Engineer
Go, Java, Python, Bash, Docker
https://c2technology.net

AnswerRe: Why would you ever want to do this? Pin
hpcoder228-Oct-18 10:48
hpcoder228-Oct-18 10:48 
GeneralWin10 Fluent Design: All the cool kids Pin
raddevus23-Oct-18 2:07
mvaraddevus23-Oct-18 2:07 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
Jason Gleim23-Oct-18 2:27
professionalJason Gleim23-Oct-18 2:27 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
raddevus23-Oct-18 2:42
mvaraddevus23-Oct-18 2:42 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
Marc Clifton23-Oct-18 3:58
mvaMarc Clifton23-Oct-18 3:58 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
Jason Gleim23-Oct-18 4:24
professionalJason Gleim23-Oct-18 4:24 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
dandy7223-Oct-18 7:00
dandy7223-Oct-18 7:00 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
lopatir23-Oct-18 2:28
lopatir23-Oct-18 2:28 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
raddevus23-Oct-18 2:44
mvaraddevus23-Oct-18 2:44 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
Eric Lynch23-Oct-18 2:50
Eric Lynch23-Oct-18 2:50 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
musefan23-Oct-18 2:37
musefan23-Oct-18 2:37 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
raddevus23-Oct-18 2:46
mvaraddevus23-Oct-18 2:46 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
musefan23-Oct-18 2:56
musefan23-Oct-18 2:56 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
raddevus23-Oct-18 4:02
mvaraddevus23-Oct-18 4:02 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
Dan Neely23-Oct-18 2:48
Dan Neely23-Oct-18 2:48 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
raddevus23-Oct-18 2:51
mvaraddevus23-Oct-18 2:51 
GeneralRe: Win10 Fluent Design: All the cool kids Pin
Dan Neely23-Oct-18 3:08
Dan Neely23-Oct-18 3:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.