mastodon.ie is one of the many independent Mastodon servers you can use to participate in the fediverse.
Irish Mastodon - run from Ireland, we welcome all who respect the community rules and members.

Administered by:

Server stats:

1.7K
active users

#objectorientedprogramming

0 posts0 participants0 posts today

kitfucoda.medium.com/the-versa

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.

Medium · The Versatility of __call__: A Python Developer’s Secret WeaponBy KitFu Coda

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

jsdev.space/howto/freeze-seal-

JavaScript Development BlogObject.freeze() and Object.seal() in JavaScriptLearn the key differences between Object.freeze() and Object.seal() in JavaScript. Discover how these methods control object mutability and prevent unwanted changes to your code.

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": archive.org/details/genera-ret

Internet ArchiveGenera Retrospective : Apple : Free Download, Borrow, and Streaming : Internet ArchiveA paper on Symbolics Genera by David A. Moon.Symbolics Genera was the world's first commercial object-oriented operating system. This paper describes a few...

Found an interesting article through Manuel Simoni: w3.org/People/Connolly/9703-we

"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."

www.w3.orgFrom the Editor -- Web Apps, Issue 2 Mar/Apr 1997

Java will be getting value classes 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

openjdk.orgJEP draft: Value Objects (Preview)

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!

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 refactoring.guru/design-patter 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.

refactoring.guruDesign PatternsDesign Patterns are typical solutions to commonly occurring problems in software design. They are blueprints that you can customize to solve a particular design problem in your code.