Many 14
We’ve talked about Zero, and One, so all that’s left of the big Three Numbers is “many”.
Many is more than one. More than one object that must be used in the same way, more than one implementation of an algorithm, more than one implementation of an interface. An API wrapper implemented once for production, and once for testing is Many. One real object and one mock is Many.
Many gives power to the Liskov Substitution Principle. If there are many (more than one) objects to be used in the same way, then it is imperative that an interface is created for them so that they may be used interchangeably (transparently) by the client.
Many objects of the same interface (“type”) may be used one-at-a-time (by reference) or in groups (containers and loops). We don’t write code that calls A and B and C in the same way because that would be “three” and we don’t believe in 3. We believe in Many. It’s a loop over a list. If we’re treating the objects similarly, we should exalt the similarity by putting them in a loop, rather than stress individuality by coding two statements for making the call.
By the way, don’t confuse Many with “two things with similar structure”. Many refers to “more than one thing with similar usage” in the LSP-compliant sense. It doesn’t demand that you create base classes to capture some essential similarities, only that you create interfaces and loops as required.
In a multi-generational GC, the theory is that some things by nature have short lifespans, and others by nature have long lifespans. Most objects are created and deleted, and a few may make it to the third-generation cache where they’re almost never examined (comparatively) for collection. Many has a similar theory. Objects that occur once are singular things, but once they start to multiply they are expected to multiply more in the future. Not only does the “interfaces & loops” keep the code clean, it recognizes the Many things as an extension point in the code. That’s double-benefit if we listen to our code as it goes from one to many.
Trackbacks
Use the following link to trackback from your own site:
http://blog.objectmentor.com/articles/trackback/6108
I first read zero-one-many when working closely with a system that had hard coded COBOL tables to a length of 7 in hundreds of modules because 7 insurance contracts fit on the green screen. In fact, most people have one or two contracts, but a few have ten and a couple groups slipped in with hundreds. Changing the system to use anything but 7 would have been … well it’s been 20 years and it never happened.
Yesterday I changed one of my classes from 2 inputs to n inputs and it was a major overhaul because I coded 2 instead of many the first time.
So I read zero-one-many first as related to building data structures. Reading it as polymorphism is new to me and very interesting. Thanks!
I first read zero-one-many when working closely with a system that had hard coded COBOL tables to a length of 7 in hundreds of modules because 7 insurance contracts fit on the green screen. In fact, most people have one or two contracts, but a few have ten and a couple groups slipped in with hundreds. Changing the system to use anything but 7 would have been … well it’s been 20 years and it never happened.
Yesterday I changed one of my classes from 2 inputs to n inputs and it was a major overhaul because I coded 2 instead of many the first time.
So I read zero-one-many first as related to building data structures. Reading it as polymorphism is new to me and very interesting. Thanks!
Most objects are created and deleted, and a few may make it to the third-generation cache where they’re almost never examined (comparatively) for collection.
So I read zero-one-many first as related to building data structures. Reading it as polymorphism is new to me and very interesting.
hey man,i am a first time visitor here and like your blog.
There exists obviously a whole lot to find out about this. I think you created some excellent points in Attributes also. Keep operating, excellent work!
very good…
Okey oynamak hiç bu kadar zevkli olmadi. Online ve 3 boyutlu okey oyunu oyna ve turnuvalara sende katil.
It’s a lucky day!I get one pair of women heels from http://www.aliexpress.com/fm-store/908014 ! It’s have beautiful appearance and very comfortable! Here’s your first look at the first Women’s Heels that I have ever seen. I do believe this is the first time our store has released a Women’s Heels in a high top form.
Thank you for posting. Waiting for updating.
thanks for share with us
thanks for share with us
thanks for share with us
555sql The longest road, step by step, also can go through, again a short road, not feet march cannot be reached.
Many of them. It is true.Well. Though I am not a good application developer. And I need do more hard work to improve myself. When I come to here. I know that I have come to the right place to learn something I need. Thanks for your good advice. And I will do the practice as possible as I can. Thanks.