https://kitfucoda.medium.com/the-versatility-of-call-a-python-developers-secret-weapon-a6bff776971a
Python's __call__ dunder offers a closure alternative. It manages state in a class, callable like a function, opening new code structuring possibilities.
In complex scenarios, __call__ enhances readability and maintainability. Encapsulating logic and data promotes cleaner code, improving clarity and debugging.
For pre-filling arguments, consider __call__ over functools.partial, especially with methods needing internal state. It creates a state-holding object for robust operations.
This is beneficial in large projects with complex logic. Using __call__ improves organization and maintainability, leading to efficient development.
"The mix-in revolution: How an ice cream innovator in Somerville influenced Lisp pioneers at the MIT AI Lab—and made a lasting mark on programming."
https://www.technologyreview.com/2025/02/25/1111238/the-mix-in-revolution/
I hope everyone's having a good day or night. It's after 2:00 AM here, but I have no sleep schedule because #sleepDisorders. I'm sitting at my desk munching on apple slices and fruit dip, listening to music, and studying and playing #incremental #games on my computer. I'm working on lesson 9 of the Literary #Braille #Proofreading course from #NLS and #NFB and studying object oriented #programming with #JavaScript on #freeCodeCamp. What's everyone else up to?
#BrailleProofreading #technology #tech #coding #learnToCode #learningToCode #objectOrientedProgramming #incrementalGames #idleGames #gaming
Object.freeze() and Object.seal() in JavaScript
This article explains the differences between `Object.freeze()` and `Object.seal()`.
`Object.freeze()` makes an object completely immutable, preventing any changes to its properties
`Object.seal()` allows modifications to existing properties but prevents adding or removing properties
Examples and use cases are provided for both methods too.
#JavaScript Programming #OOP #ObjectOrientedProgramming
https://jsdev.space/howto/freeze-seal-js/
David A. Moon was one of the founders of Symbolics and one of the chief architects of its Lisp machines. In 1991, after he left Symbolics and joined Apple, he wrote this retrospective of Genera, "the world's first commercial object-oriented operating system": https://archive.org/details/genera-retrospective-1991
One of my favourite technologists, #AlanKay, who invented #OOP #ObjectOrientedProgramming #Smalltalk #TabletComputers, amongst other things, said:
"The best way to predict the future is to invent it"
I always found that quite inspiring.
(I know there are similar quotes attributed to others, but I'm pretty sure he used this wording).
Found an interesting article through Manuel Simoni: https://www.w3.org/People/Connolly/9703-web-apps-essay.html
"HTTP was design[ed] as a distributed realization of the Objective C (originally Smalltalk) message passing infrastructure [...]
Uniform Resource Locator is just the result of squeezing the term _object reference_ through the IETF standardization process."
This Thursday I organized the monthly meetup of Lisp Ireland and finished my talk "A Tour of Common Lisp". Thanks to https://techmeetup.space for hosting us.
You can watch the livestream's recording here: https://www.youtube.com/watch?v=J53P49SLgew
A great paper from 2004 by Richard P. Gabriel (Lucid, Inc.), Jon L White (ditto), Daniel G. Bobrow (Xerox PARC) that explains how Common Lisp Object System integrates functional and object-oriented programming: https://dreamsongs.com/Files/clos-cacm.pdf
Java will be getting value classes https://openjdk.org/jeps/8277163 in short it’s classes where instances don‘t have a unique identity. In other words == and equals() will behave the same way. It took me so long to understand the difference for traditional classes. In wonder whether this will make things more confusing because now you need to look up a class definition when you see == somewhere. Also records can be value classes…
#java #jep #confused #oop #objectorientedprogramming
It's still relevant today, you can say that the "bricks" progressed from static object systems to type systems: https://dreamsongs.com/ObjectsHaveFailedNarrative.html
Were there ever any attempts to somehow add multimethods (multiple dispatch) to Smalltalk?
A little bit about #objectorientedprogramming.
So I’m pretty cool on OOP these days, and the main reason is that I’m pretty hot on writing code that’s easy to change in the future. The main advantage to OOP is that one couples the data to the methods that can manipulate the data. This is great, and makes intuitive sense.
The main disadvantage, I’ve decided, is that for just about all OOP languages I’m familiar with, this divides the world into two sorts of functions per object class:
The methods the class knows about
Everything else
… and I’ve come around to thinking that drawing that line is prognostication. Especially since basically all systems I deal with don’t let you “open up” an object definition and add new methods. So you end up with foo.something()
methods, but also manipulate(foo)
methods living in some other library, and don’t even get me started on whether methods that involve manipulating two objects should be foo.do(bar)
or bar.do(foo)
or both or neither. All of that is just noise. These days, I prefer to keep the set of “methods the class knows about” as close to zero as possible.
So what’s replaced OOP for me? Usually, I’m nowadays working with interfaces, composition, functions, and generics. I find those work great, and the situations where I really want OOP are vanishingly small. If I want to find the “methods” of a data type, I just search the codebase for functions that take that data as an argument (trivial with modern IDEs and modern languages)… and hey, bonus, it finds me the additional functionality that someone else wrote in their module because they couldn’t re-open an object to add behavior and they weren’t in control of the module that defined the object!
@sullybiker #Perl is also going another phase of exciting improvements lately. Experimental features like subroutine signatures and postfix dereferencing are finally stable and misfeatures are being deprecated or forbidden. And there are entirely new experimental features being worked on, including a modern #ObjectOrientedProgramming syntax and paradigm being built into the core language.
Make Use Of: How to Implement Object-Oriented Programming Concepts in Rust https://www.makeuseof.com/rust-object-oriented-programming-concepts-how-to-implement/ #Tech #MakeUseOf #TechNews #IT via @morganeogerbc #ObjectOrientedProgramming #Programming
In Java, if I want to delegate the foo and bar methods to my component a, I have to say something like:
public int foo(int x) {
return a.foo(x);
}
public void bar() {
a.bar();
}
Is there a programming language that natively supports delegation? I'm imagining something like:
delegate a: foo, bar;
This would make it much easier to choose composition over inheritance.
I'm using https://refactoring.guru/design-patterns in my software development course. It's pretty good and, in the words of the late Portland TV pitchman Tom Peterson, "free is a very good price".
I have two concerns:
Rather than just working through the original Gang of Four list, would it be more meaningful to talk about ideas that come up in several of these patterns, like interfaces, delegation, and composition?
How do design patterns change when working in a language like Python rather than C++ or Java? There might be better solutions to some of these problems in a world with duck typing, higher-order functions, optional named arguments, etc.
So, this battle between FP and OOP ends in a truce
The two battling sides realise that there's nothing to fight about, after all, as they're really on the same side!
But beware, not everyone will observe this truce. Some will keep waging this war…
#Programming #Coding #ObjectOrientedProgramming #functionalprogramming
/12