Click here to Skip to main content
15,885,196 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jon McKee25-Sep-23 10:26
professionalJon McKee25-Sep-23 10:26 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
raddevus25-Sep-23 10:36
mvaraddevus25-Sep-23 10:36 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jeremy Falcon25-Sep-23 12:33
professionalJeremy Falcon25-Sep-23 12:33 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jon McKee26-Sep-23 9:53
professionalJon McKee26-Sep-23 9:53 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jeremy Falcon25-Sep-23 12:33
professionalJeremy Falcon25-Sep-23 12:33 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jon McKee26-Sep-23 9:51
professionalJon McKee26-Sep-23 9:51 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jeremy Falcon27-Sep-23 2:36
professionalJeremy Falcon27-Sep-23 2:36 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jon McKee28-Sep-23 14:17
professionalJon McKee28-Sep-23 14:17 
Jeremy Falcon wrote:
Btw, thanks for knowing what you're talking about. Makes these conversations much better.

Haha, thanks, but I don't think I deserve that quite yet. I'm still learning from people like Bartosz Milewski and Mark Seemann.

Jeremy Falcon wrote:
That one I gotta look into man. My understanding of pure functions is that all inputs are deterministic. So, not following how shifting parameter order changes that, since non-deterministic input is still going into the routine. Will check out the link though.

This is an interesting topic that really broke my brain when I first ran into it. So, functions of more than one input have a lot of equivalent representations. For example, string -> int -> string can be seen as a function taking a string and returning a function of int -> string, or as a function of two inputs (the tuple (string, int)) that returns a string. The important part with regards to purity is binding order, or in other words "what is provided when". You can only act upon what is provided, so if arguments that are (potentially) impure are not provided yet, the function is still pure. For example:
C#
public bool saveToDatabase(Database db) => val => { db.save(val) };
public bool saveToDatabase(Value val) => db => { db.save(val) };
The first function is impure, the second function is pure. Why? They both take a Database and Value and return a Bool. Both are lazy (i.e. they only evaluate when all arguments are supplied). Well, because purity is a logical result of inputs and outputs. In the first example, if I apply the Database parameter, get the result function, then drop the database tables, then apply the Value, the operation fails. The partially applied function is impure. The database object that was already bound (partially-applied) was side-effected by the tables dropping. In the second example, no matter what I do after applying the Value, I can't create a situation where the Database is invalid AFTER applying it. The returned function itself is impure since we're side-effecting a database, but the original function is not, because there is no way to change the Database -> Bool that's returned.

I might be off on some stuff, always learning, but that's my understanding of it.
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Richard Deeming25-Sep-23 22:02
mveRichard Deeming25-Sep-23 22:02 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
trønderen26-Sep-23 9:31
trønderen26-Sep-23 9:31 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jeremy Falcon27-Sep-23 3:17
professionalJeremy Falcon27-Sep-23 3:17 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
RainHat26-Sep-23 0:02
RainHat26-Sep-23 0:02 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
charlieg26-Sep-23 7:42
charlieg26-Sep-23 7:42 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
trønderen26-Sep-23 9:47
trønderen26-Sep-23 9:47 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Nelek27-Sep-23 9:12
protectorNelek27-Sep-23 9:12 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
haughtonomous26-Sep-23 21:11
haughtonomous26-Sep-23 21:11 
PraiseRe: The changing landscape of OOP (from class to struct) Pin
Jeremy Falcon27-Sep-23 4:17
professionalJeremy Falcon27-Sep-23 4:17 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Peter Adam26-Sep-23 22:20
professionalPeter Adam26-Sep-23 22:20 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Richard Deeming26-Sep-23 23:13
mveRichard Deeming26-Sep-23 23:13 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
haughtonomous3-Oct-23 21:33
haughtonomous3-Oct-23 21:33 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Steve Naidamast27-Sep-23 4:19
professionalSteve Naidamast27-Sep-23 4:19 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
raddevus27-Sep-23 8:51
mvaraddevus27-Sep-23 8:51 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
haughtonomous3-Oct-23 21:40
haughtonomous3-Oct-23 21:40 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
John Chadwell27-Sep-23 4:40
John Chadwell27-Sep-23 4:40 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
raddevus27-Sep-23 8:54
mvaraddevus27-Sep-23 8:54 

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.